本文整理汇总了Python中sevenbridges.meta.transformer.Transform.to_volume方法的典型用法代码示例。如果您正苦于以下问题:Python Transform.to_volume方法的具体用法?Python Transform.to_volume怎么用?Python Transform.to_volume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sevenbridges.meta.transformer.Transform
的用法示例。
在下文中一共展示了Transform.to_volume方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: submit_export
# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_volume [as 别名]
def submit_export(cls, file, volume, location, properties=None,
overwrite=False, copy_only=False, api=None):
"""
Submit new export job.
:param file: File to be exported.
:param volume: Volume identifier.
:param location: Volume location.
:param properties: Properties dictionary.
:param overwrite: If true it will overwrite file if exists
:param copy_only: If true files are kept on SevenBridges bucket.
:param api: Api Instance.
:return: Export object.
"""
data = {}
params = {}
volume = Transform.to_volume(volume)
file = Transform.to_file(file)
destination = {
'volume': volume,
'location': location
}
source = {
'file': file
}
if properties:
data['properties'] = properties
data['source'] = source
data['destination'] = destination
data['overwrite'] = overwrite
extra = {
'resource': cls.__name__,
'query': data
}
logger.info('Submitting export', extra=extra)
api = api if api else cls._API
if copy_only:
params['copy_only'] = True
_export = api.post(
cls._URL['query'], data=data, params=params).json()
else:
_export = api.post(
cls._URL['query'], data=data).json()
return Export(api=api, **_export)
示例2: query
# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_volume [as 别名]
def query(cls, volume=None, state=None, offset=None,
limit=None, api=None):
"""
Query (List) exports.
:param volume: Optional volume identifier.
:param state: Optional import sate.
:param api: Api instance.
:return: Collection object.
"""
api = api or cls._API
if volume:
volume = Transform.to_volume(volume)
return super(Export, cls)._query(
url=cls._URL['query'], volume=volume, state=state, offset=offset,
limit=limit, fields='_all', api=api
)
示例3: bulk_submit
# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_volume [as 别名]
def bulk_submit(cls, exports, copy_only=False, api=None):
"""
Create exports in bulk.
:param exports: Exports to be submitted in bulk.
:param copy_only: If true files are kept on SevenBridges bucket.
:param api: Api instance.
:return: list of ExportBulkRecord objects.
"""
if not exports:
raise SbgError('Exports are required')
api = api or cls._API
items = []
for export in exports:
file_ = Transform.to_file(export.get('file'))
volume = Transform.to_volume(export.get('volume'))
location = Transform.to_location(export.get('location'))
properties = export.get('properties', {})
overwrite = export.get('overwrite', False)
item = {
'source': {
'file': file_
},
'destination': {
'volume': volume,
'location': location
},
'properties': properties,
'overwrite': overwrite
}
items.append(item)
data = {'items': items}
params = {'copy_only': copy_only}
response = api.post(
url=cls._URL['bulk_create'], params=params, data=data
)
return ExportBulkRecord.parse_records(response=response, api=api)
示例4: test_transform_volume_invalid_values
# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_volume [as 别名]
def test_transform_volume_invalid_values(volume):
with pytest.raises(SbgError):
Transform.to_volume(volume)
示例5: test_transform_volume
# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_volume [as 别名]
def test_transform_volume(volume):
Transform.to_volume(volume)