Skip to content

Commit

Permalink
Feature - remove unused endpoint and added functionality for google I…
Browse files Browse the repository at this point in the history
…AM volumes
  • Loading branch information
Stevan Pejak committed Oct 7, 2021
2 parents 7141e61 + 0608975 commit b3e1401
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 41 deletions.
13 changes: 5 additions & 8 deletions sevenbridges/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down
24 changes: 0 additions & 24 deletions sevenbridges/models/billing_breakdown.py

This file was deleted.

7 changes: 0 additions & 7 deletions sevenbridges/models/billing_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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):
"""
Expand Down
46 changes: 44 additions & 2 deletions sevenbridges/models/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b3e1401

Please sign in to comment.