def list_all(self): """ :return: :rtype: """ return DigitalOceanAPI.get(self.api_object, 'volumes')
def create_new_volume(self, size_gb, name, desc, region, snapshot_id): """ Used for creating a new volume in block storage :param api_object: :param size_gb: :param name: :param desc: :param region: :param snapshot_id: :type api_object: object :type size_gb: integer :type name: string :type desc: string :type region: string :type snapshot_id: string :return: :rtype: string """ payload = { 'size_gigabytes': size_gb, 'name': name, 'description': desc, 'region': region, 'snapshot-id': snapshot_id } return DigitalOceanAPI.post(self.api_object, 'volumes', payload)
def retrieve_block_volume(self, volume_id): """ :param volume_id: :return: """ return DigitalOceanAPI.get(self.api_object, 'volumes/' + volume_id)
def list_all_actions(self, volume_id): """ :param volume_id: :return: """ return DigitalOceanAPI.get(self.api_object, 'volumes/' + volume_id + '/actions')
def list_snapshots(self, volume_id): """ :param volume_id: :return: """ return DigitalOceanAPI.get(self.api_object, 'volumes/' + volume_id + '/snapshots')
def get_volume_action(self, volume_id, action_id): """ :param volume_id: :param action_id: :return: """ return DigitalOceanAPI.get( self.api_object, 'volumes/' + volume_id + '/actions/' + action_id)
def create_snapshot_from_volume(self, volume_id, name): """ :param volume_id: :param name: :return: """ return DigitalOceanAPI.get(self.api_object, 'volumes/' + volume_id, {'name': name})
def delete_volume_by_name(self, name, region): """ :param name: :param region: :return: """ return DigitalOceanAPI.delete(self.api_object, 'volumes', { 'name': name, 'region': region })
def retrieve_block_volume_byname(self, name, region): """ :param name: :param region: :return: """ return DigitalOceanAPI.get(self.api_object, 'volumes', { 'name': name, 'region': region })
def rezise_volume(self, volume_id, size_gb, region, type='resize'): """ :param self: :param volume_id: :param size_gb: :param region: :param type: :return: """ return DigitalOceanAPI.post(self.api_object, 'volumes/' + volume_id + '/actions', { 'type': type, 'size_gigabytes': size_gb, 'region': region })
def remove_volume_from_droplet_byname(self, droplet_id, volume_name, region, type='attach'): """ :param droplet_id: :param volume_name: :param region: :return: """ return DigitalOceanAPI.post( self.api_object, 'volumes/' + 'actions', { 'type': type, 'droplet_id': droplet_id, 'volume_name': volume_name, 'region': region })
def attach_volume_to_droplet(self, volume_id, droplet_id, region, type='attach'): """ Used to attach a existing volume to a droplet :param volume_id: :param droplet_id: :param region: :param type: :return: :rtype: JSON object """ return DigitalOceanAPI.post(self.api_object, 'volumes/' + volume_id + '/actions', { 'type': type, 'droplet_id': droplet_id, 'region': region })
def attach_volume_to_droplet_by_name(self, droplet_id, volume_name, region, type='attach'): """ Used for attaching a volume to a droplet by a name :param droplet_id: :param volume_name: :param region: :param type: :return: :rtype: """ return DigitalOceanAPI.post( self.api_object, 'volumes/actions', { 'type': type, 'droplet_id': droplet_id, 'volume_name': volume_name, 'region': region })
def retrive_exisiting_action(api_object, action_id): return DigitalOceanAPI.get(api_object, 'actions/' + action_id)
def list_all_actions(api_object): return DigitalOceanAPI.get(api_object, 'actions')
from digitalocean_py import DigitalOceanAPI, v2 api = DigitalOceanAPI('Bearer token'); test_call = v2.account.get_user_info(DigitalOceanAPI)