Skip to content

Commit

Permalink
1.8.2: support for configurable azure sas tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Kish committed Dec 28, 2018
1 parent 132fe6a commit ffef150
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions cogniac/common.py
Expand Up @@ -27,6 +27,9 @@ def __init__(self, message, status_code=None):
if status_code is not None:
self.status_code = status_code

def __str__(self):
return self.message


def credential_error(exception):
return isinstance(exception, CredentialError)
Expand Down
18 changes: 13 additions & 5 deletions cogniac/tenant.py
Expand Up @@ -9,7 +9,9 @@
from retrying import retry
from common import *

immutable_fields = ['aws_region', 'created_at', 'created_by', 'modified_at', 'modified_by', 'tenant_type', 'tenant_id']
immutable_fields = ['region', 'created_at', 'created_by', 'modified_at', 'modified_by', 'tenant_id']

mutable_keys = ['name', 'description', 'azure_sas_tokens']

##
# CogniacTenant
Expand All @@ -20,9 +22,10 @@ class CogniacTenant(object):
@retry(stop_max_attempt_number=8, wait_exponential_multiplier=500, retry_on_exception=server_error)
def get(cls, connection):
resp = connection._get("/tenants/current")
return CogniacTenant(json.loads(resp.content))
return CogniacTenant(connection, json.loads(resp.content))

def __init__(self, tenant_dict):
def __init__(self, connection, tenant_dict):
self._cc = connection
for k, v in tenant_dict.items():
super(CogniacTenant, self).__setattr__(k, v)

Expand All @@ -35,5 +38,10 @@ def __repr__(self):
def __setattr__(self, name, value):
if name in immutable_fields:
raise AttributeError("%s is immutable" % name)
if name in ['name', 'description']:
raise AttributeError("sdk does not support editing tenant objects")
if name in mutable_keys:
data = {name: value}
resp = self._cc._post("/tenants/%s" % self.tenant_id, json=data)
for k, v in resp.json().items():
super(CogniacTenant, self).__setattr__(k, v)
return
super(CogniacTenant, self).__setattr__(name, value)
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -3,7 +3,7 @@
from distutils.core import setup

setup(name='cogniac',
version='1.8.1',
version='1.8.2',
description='Python SDK for Cogniac Public API',
packages=['cogniac'],
author = 'Cogniac Corporation',
Expand Down

0 comments on commit ffef150

Please sign in to comment.