Skip to content

Commit

Permalink
Handle the 'app_name' parameter in the client and restclient modules (#…
Browse files Browse the repository at this point in the history
…49)

Signed-off-by: Suneeth Kumar Byadara Halli <[email protected]>
  • Loading branch information
suneeth51 authored Apr 9, 2021
1 parent 631d5f5 commit 135429b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nimbleclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)

# Version for NimbleOS SDK client package
__version__ = "2.0.0"
__version__ = "1.2.1"

__all__ = [
"v1",
Expand Down
4 changes: 2 additions & 2 deletions nimbleclient/v1/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
class NimOSClient:
"""Nimble client for NimOS v1 REST API."""

def __init__(self, hostname, username, password, job_timeout=60, port=5392):
self._client = NimOSAPIClient(hostname, username, password, job_timeout, port)
def __init__(self, hostname, username, password, app_name=None, job_timeout=60, port=5392):
self._client = NimOSAPIClient(hostname, username, password, app_name, job_timeout, port)

@property
def access_control_records(self):
Expand Down
11 changes: 9 additions & 2 deletions nimbleclient/v1/restclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class NimOSAPIClient:
'witnesses': 'v1/witnesses',
}

def __init__(self, hostname, username, password, job_timeout=60, port=5392):
def __init__(self, hostname, username, password, app_name=None, job_timeout=60, port=5392):
"""Initialize a session to the NimOS REST API."""

connection_hash = str(uuid.uuid3(uuid.NAMESPACE_OID, f'{hostname}{port}{username}{password}'))
Expand All @@ -85,11 +85,18 @@ def __init__(self, hostname, username, password, job_timeout=60, port=5392):
self.port = port
self.job_timeout = job_timeout

if app_name is None:
self.app_info = f'NimOS Python SDK v{__version__}'
else:
self.app_info = app_name

logging.debug(f"Instantiating NimOS client for App '{self.app_info}'")

self.__auth = {
'data': {
'username': username,
'password': password,
'app_name': f'NimOS Python SDK v{__version__}'
'app_name': self.app_info
}
}
logging.debug(f"NimOSAPIClient created with [hostname: {hostname}], [job_timeout: {job_timeout} seconds], [port: {port}], [SDK Version: v{__version__}]")
Expand Down

0 comments on commit 135429b

Please sign in to comment.