diff --git a/sevenbridges/__init__.py b/sevenbridges/__init__.py index 6e85a60..6dac720 100644 --- a/sevenbridges/__init__.py +++ b/sevenbridges/__init__.py @@ -15,9 +15,7 @@ from sevenbridges.config import Config from sevenbridges.models.invoice import Invoice -from sevenbridges.models.billing_group import ( - BillingGroup, BillingGroupBreakdown -) +from sevenbridges.models.billing_group import BillingGroup from sevenbridges.models.user import User from sevenbridges.models.endpoints import Endpoints from sevenbridges.models.project import Project @@ -59,11 +57,10 @@ __all__ = [ # Models 'Api', 'AsyncJob', 'Automation', 'AutomationRun', 'AutomationMember', - 'AutomationPackage', 'Config', 'Invoice', 'BillingGroup', - 'BillingGroupBreakdown', 'User', 'Endpoints', 'Project', 'Task', 'App', - 'Member', 'Permissions', 'File', 'Export', 'Import', 'Volume', - 'VolumeObject', 'Marker', 'Division', 'Team', 'TeamMember', 'Dataset', - 'DRSImportBulk', 'BulkRecord', + 'AutomationPackage', 'Config', 'Invoice', 'BillingGroup', 'User', + 'Endpoints', 'Project', 'Task', 'App', 'Member', 'Permissions', 'File', + 'Export', 'Import', 'Volume', 'VolumeObject', 'Marker', 'Division', 'Team', + 'TeamMember', 'Dataset', 'DRSImportBulk', 'BulkRecord', # Enums 'AppCopyStrategy', 'AppRawFormat', 'AppCopyStrategy', 'AsyncFileOperations', 'AsyncJobStates', 'AutomationRunActions', diff --git a/sevenbridges/models/billing_breakdown.py b/sevenbridges/models/billing_breakdown.py deleted file mode 100644 index b7f3d2e..0000000 --- a/sevenbridges/models/billing_breakdown.py +++ /dev/null @@ -1,24 +0,0 @@ -from sevenbridges.meta.resource import Resource -from sevenbridges.models.compound.price import Price -from sevenbridges.models.compound.billing.project_breakdown import ( - ProjectBreakdown -) -from sevenbridges.meta.fields import ( - HrefField, CompoundListField, CompoundField -) - - -class BillingGroupBreakdown(Resource): - """ - Central resource for managing billing group breakdowns. - """ - _URL = { - 'get': '/billing/groups/{id}/breakdown' - } - - href = HrefField(read_only=True) - project_breakdown = CompoundListField(ProjectBreakdown, read_only=True) - total_spending = CompoundField(Price, read_only=True) - - def __str__(self): - return '' diff --git a/sevenbridges/models/billing_group.py b/sevenbridges/models/billing_group.py index 5340343..0752976 100644 --- a/sevenbridges/models/billing_group.py +++ b/sevenbridges/models/billing_group.py @@ -5,7 +5,6 @@ from sevenbridges.models.billing_analysis_breakdown import ( BillingGroupAnalysisBreakdown ) -from sevenbridges.models.billing_breakdown import BillingGroupBreakdown from sevenbridges.models.billing_storage_breakdown import ( BillingGroupStorageBreakdown ) @@ -55,12 +54,6 @@ def query(cls, offset=None, limit=None, api=None): api=api ) - def breakdown(self): - """ - Get Billing group breakdown for the current billing group. - """ - return BillingGroupBreakdown.get(self.id, self._api) - def analysis_breakdown(self, date_from=None, date_to=None, invoice_id=None, fields=None, offset=0, limit=50): """ diff --git a/sevenbridges/models/volume.py b/sevenbridges/models/volume.py index f6c429a..d894e57 100644 --- a/sevenbridges/models/volume.py +++ b/sevenbridges/models/volume.py @@ -41,7 +41,7 @@ class Volume(Resource): service = CompoundField(VolumeService, read_only=False) created_on = DateTimeField(read_only=True) modified_on = DateTimeField(read_only=True) - active = BooleanField(read_only=True) + active = BooleanField(read_only=False) def __eq__(self, other): if type(other) is not type(self): @@ -161,7 +161,7 @@ def create_google_volume(cls, name, bucket, client_email, private_key, properties=None, api=None): """ - Create s3 volume. + Create google volume. :param name: Volume name. :param bucket: Referenced bucket. :param client_email: Google client email. @@ -200,6 +200,48 @@ def create_google_volume(cls, name, bucket, client_email, private_key, response = api.post(url=cls._URL['query'], data=data).json() return Volume(api=api, **response) + @classmethod + def create_google_iam_volume(cls, name, bucket, configuration, access_mode, + description=None, prefix=None, + properties=None, api=None): + + """ + Create google volume. + :param name: Volume name. + :param bucket: Referenced bucket. + :param configuration: Google configuration. + :param access_mode: Access Mode. + :param description: Volume description. + :param prefix: Volume prefix. + :param properties: Volume properties. + :param api: Api instance. + :return: Volume object. + """ + service = {'type': VolumeType.GOOGLE, + 'bucket': bucket, + 'credentials': {'configuration': configuration} + } + if prefix: + service['prefix'] = prefix + if properties: + service['properties'] = properties + + data = {'name': name, + 'service': service, + 'access_mode': access_mode + } + if description: + data['description'] = description + api = api or cls._API + + extra = { + 'resource': cls.__name__, + 'query': data + } + logger.info('Creating google volume', extra=extra) + response = api.post(url=cls._URL['query'], data=data).json() + return Volume(api=api, **response) + @classmethod def create_oss_volume(cls, name, bucket, endpoint, access_key_id, secret_access_key, access_mode, description=None,