def _get_block_storage(kwargs): ''' Construct a block storage instance from passed arguments ''' if kwargs is None: kwargs = {} block_storage_name = kwargs.get('name', None) block_storage_size = kwargs.get('size', None) block_storage_description = kwargs.get('description', None) datacenter_id = kwargs.get('datacenter_id', None) server_id = kwargs.get('server_id', None) block_storage = BlockStorage(name=block_storage_name, size=block_storage_size) if block_storage_description: block_storage.description = block_storage_description if datacenter_id: block_storage.datacenter_id = datacenter_id if server_id: block_storage.server_id = server_id return block_storage
def _get_block_storage(kwargs): """ Construct a block storage instance from passed arguments """ if kwargs is None: kwargs = {} block_storage_name = kwargs.get("name", None) block_storage_size = kwargs.get("size", None) block_storage_description = kwargs.get("description", None) datacenter_id = kwargs.get("datacenter_id", None) server_id = kwargs.get("server_id", None) block_storage = BlockStorage(name=block_storage_name, size=block_storage_size) if block_storage_description: block_storage.description = block_storage_description if datacenter_id: block_storage.datacenter_id = datacenter_id if server_id: block_storage.server_id = server_id return block_storage
# Create a block storage from oneandone.client import OneAndOneService, BlockStorage client = OneAndOneService('<API-TOKEN>') block_storage = BlockStorage(name='My new block storage', description='My block storage description', size=20, datacenter_id='908DC2072407C94C8054610AD5A53B8C') response = client.create_block_storage(block_storage) # List all block storages from oneandone.client import OneAndOneService, BlockStorage client = OneAndOneService('<API-TOKEN>') response = client.list_block_storages() # Retrieve a single block storage from oneandone.client import OneAndOneService client = OneAndOneService('<API-TOKEN>') response = client.get_block_storage(block_storage_id='') # Modify a block storage from oneandone.client import OneAndOneService client = OneAndOneService('<API-TOKEN>')