OXIESEC PANEL
- Current Dir:
/
/
snap
/
certbot-dns-digitalocean
/
4356
/
lib
/
python3.12
/
site-packages
/
digitalocean
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
06/12/2025 06:18:03 PM
rwxr-xr-x
📄
Account.py
904 bytes
06/12/2025 06:17:59 PM
rw-r--r--
📄
Action.py
2.22 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Balance.py
847 bytes
06/12/2025 06:17:59 PM
rw-r--r--
📄
Certificate.py
4.28 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Domain.py
5.22 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Droplet.py
20.65 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Firewall.py
8.26 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
FloatingIP.py
3.02 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Image.py
5.55 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Kernel.py
328 bytes
06/12/2025 06:17:59 PM
rw-r--r--
📄
LoadBalancer.py
15.47 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Manager.py
14.09 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Metadata.py
1.3 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Project.py
4.91 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Record.py
3.92 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Region.py
386 bytes
06/12/2025 06:17:59 PM
rw-r--r--
📄
SSHKey.py
2.55 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Size.py
453 bytes
06/12/2025 06:17:59 PM
rw-r--r--
📄
Snapshot.py
1.17 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Tag.py
5.71 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
VPC.py
3.73 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
Volume.py
6.62 KB
06/12/2025 06:17:59 PM
rw-r--r--
📄
__init__.py
1.1 KB
06/12/2025 06:17:59 PM
rw-r--r--
📁
__pycache__
-
06/12/2025 06:18:03 PM
rwxr-xr-x
📄
baseapi.py
7.94 KB
06/12/2025 06:17:59 PM
rw-r--r--
Editing: Volume.py
Close
# -*- coding: utf-8 -*- from .baseapi import BaseAPI, POST, DELETE from .Snapshot import Snapshot class Volume(BaseAPI): def __init__(self, *args, **kwargs): self.id = None self.name = None self.droplet_ids = [] self.region = None self.description = None self.size_gigabytes = None self.created_at = None self.snapshot_id = None self.filesystem_type = None self.filesystem_label = None self.tags = None super(Volume, self).__init__(*args, **kwargs) @classmethod def get_object(cls, api_token, volume_id): """ Class method that will return an Volume object by ID. """ volume = cls(token=api_token, id=volume_id) volume.load() return volume def load(self): data = self.get_data("volumes/%s" % self.id) volume_dict = data['volume'] # Setting the attribute values for attr in volume_dict.keys(): setattr(self, attr, volume_dict[attr]) return self def create(self, *args, **kwargs): """ Creates a Block Storage volume Note: Every argument and parameter given to this method will be assigned to the object. Args: name: string - a name for the volume region: string - slug identifier for the region size_gigabytes: int - size of the Block Storage volume in GiB filesystem_type: string, optional - name of the filesystem type the volume will be formatted with ('ext4' or 'xfs') filesystem_label: string, optional - the label to be applied to the filesystem, only used in conjunction with filesystem_type Optional Args: description: string - text field to describe a volume tags: List[string], optional - the tags to be applied to the volume """ data = self.get_data('volumes/', type=POST, params={'name': self.name, 'region': self.region, 'size_gigabytes': self.size_gigabytes, 'description': self.description, 'filesystem_type': self.filesystem_type, 'filesystem_label': self.filesystem_label, 'tags': self.tags, }) if data: self.id = data['volume']['id'] self.created_at = data['volume']['created_at'] return self def create_from_snapshot(self, *args, **kwargs): """ Creates a Block Storage volume Note: Every argument and parameter given to this method will be assigned to the object. Args: name: string - a name for the volume snapshot_id: string - unique identifier for the volume snapshot size_gigabytes: int - size of the Block Storage volume in GiB filesystem_type: string, optional - name of the filesystem type the volume will be formatted with ('ext4' or 'xfs') filesystem_label: string, optional - the label to be applied to the filesystem, only used in conjunction with filesystem_type Optional Args: description: string - text field to describe a volume tags: List[string], optional - the tags to be applied to the volume """ data = self.get_data('volumes/', type=POST, params={'name': self.name, 'snapshot_id': self.snapshot_id, 'region': self.region, 'size_gigabytes': self.size_gigabytes, 'description': self.description, 'filesystem_type': self.filesystem_type, 'filesystem_label': self.filesystem_label, 'tags': self.tags, }) if data: self.id = data['volume']['id'] self.created_at = data['volume']['created_at'] return self def destroy(self): """ Destroy a volume """ return self.get_data("volumes/%s/" % self.id, type=DELETE) def attach(self, droplet_id, region): """ Attach a Volume to a Droplet. Args: droplet_id: int - droplet id region: string - slug identifier for the region """ return self.get_data( "volumes/%s/actions/" % self.id, type=POST, params={"type": "attach", "droplet_id": droplet_id, "region": region} ) def detach(self, droplet_id, region): """ Detach a Volume to a Droplet. Args: droplet_id: int - droplet id region: string - slug identifier for the region """ return self.get_data( "volumes/%s/actions/" % self.id, type=POST, params={"type": "detach", "droplet_id": droplet_id, "region": region} ) def resize(self, size_gigabytes, region): """ Detach a Volume to a Droplet. Args: size_gigabytes: int - size of the Block Storage volume in GiB region: string - slug identifier for the region """ return self.get_data( "volumes/%s/actions/" % self.id, type=POST, params={"type": "resize", "size_gigabytes": size_gigabytes, "region": region} ) def snapshot(self, name): """ Create a snapshot of the volume. Args: name: string - a human-readable name for the snapshot """ return self.get_data( "volumes/%s/snapshots/" % self.id, type=POST, params={"name": name} ) def get_snapshots(self): """ Retrieve the list of snapshots that have been created from a volume. Args: """ data = self.get_data("volumes/%s/snapshots/" % self.id) snapshots = list() for jsond in data[u'snapshots']: snapshot = Snapshot(**jsond) snapshot.token = self.tokens snapshots.append(snapshot) return snapshots def __str__(self): return "<Volume: %s %s %s>" % (self.id, self.name, self.size_gigabytes)