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 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 })