summaryrefslogtreecommitdiffstats
path: root/sms-client/python/onapsmsclient
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2018-09-13 12:32:54 -0700
committerKiran Kamineni <kiran.k.kamineni@intel.com>2018-09-13 15:37:04 -0700
commit88cd97fec2a7efd47d578e7a03ac23e3cd764a27 (patch)
treee24fb2040412ae5f0ccbb4f5585a3b950aa4e0cd /sms-client/python/onapsmsclient
parent06b13854c14d4a88b56218d458034f4a1ac4ba65 (diff)
Fix python client to handle UUID
Python client does not support UUID based query right now. This patch addresses that issue Issue-ID: AAF-494 Change-Id: Ied45ba6b593a68b7570f76fb9fdbb9173a005b72 Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'sms-client/python/onapsmsclient')
-rw-r--r--sms-client/python/onapsmsclient/onapsmsclient/__init__.py50
1 files changed, 26 insertions, 24 deletions
diff --git a/sms-client/python/onapsmsclient/onapsmsclient/__init__.py b/sms-client/python/onapsmsclient/onapsmsclient/__init__.py
index 9f31c3e..69900c7 100644
--- a/sms-client/python/onapsmsclient/onapsmsclient/__init__.py
+++ b/sms-client/python/onapsmsclient/onapsmsclient/__init__.py
@@ -16,9 +16,9 @@ import requests
import requests.exceptions
try:
- from urllib.parse import urlparse
+ from urllib.parse import urljoin
except ImportError:
- from urlparse import urlparse
+ from urlparse import urljoin
name = "onapsmsclient"
@@ -114,7 +114,7 @@ class Client(object):
else:
verify = self.cacert
- url = urlparse.urljoin(self.base_url, url)
+ url = urljoin(self.base_url, url)
response = self.session.request(method, url, headers=headers,
allow_redirects=False, verify=verify,
timeout=self.timeout, **kwargs)
@@ -131,7 +131,9 @@ class Client(object):
"""Returns Status of SMS Service
Returns:
- bool: True or False depending on if SMS Service is ready.
+ bool: True or False depending on if SMS Service is Sealed or not.
+ True - Sealed
+ False - Unsealed and ready for operations
"""
url = self._urlJoin(self._base_api_url, 'quorum', 'status')
@@ -156,45 +158,45 @@ class Client(object):
response = self._request('post', url, json=data)
return response.json()['uuid']
- def deleteDomain(self, domainName):
+ def deleteDomain(self, domainUUID):
"""Deletes a Secret Domain
Args:
- domainName (str): Name of the secret domain to delete
+ domainUUID (str): UUID of the secret domain to delete
Returns:
bool: True. An exception will be raised if delete failed.
"""
- domainName = domainName.strip()
- url = self._urlJoin(self._base_api_url, 'domain', domainName)
+ domainUUID = domainUUID.strip()
+ url = self._urlJoin(self._base_api_url, 'domain', domainUUID)
self._request('delete', url)
return True
- def getSecretNames(self, domainName):
+ def getSecretNames(self, domainUUID):
"""Get all Secret Names in Domain
Args:
- domainName (str): Name of the secret domain
+ domainUUID (str): UUID of the secret domain
Returns:
string[]: List of strings each corresponding to a
Secret's Name in this Domain.
"""
- domainName = domainName.strip()
- url = self._urlJoin(self._base_api_url, 'domain', domainName,
+ domainUUID = domainUUID.strip()
+ url = self._urlJoin(self._base_api_url, 'domain', domainUUID,
'secret')
response = self._request('get', url)
return response.json()['secretnames']
- def storeSecret(self, domainName, secretName, values):
+ def storeSecret(self, domainUUID, secretName, values):
"""Store a Secret in given Domain
Args:
- domainName (str): Name of the secret domain
+ domainUUID (str): UUID of the secret domain
secretName (str): Name for the Secret
values (dict): A dict containing name-value pairs which
form the secret
@@ -203,9 +205,9 @@ class Client(object):
bool: True. An exception will be raised if store failed.
"""
- domainName = domainName.strip()
+ domainUUID = domainUUID.strip()
secretName = secretName.strip()
- url = self._urlJoin(self._base_api_url, 'domain', domainName,
+ url = self._urlJoin(self._base_api_url, 'domain', domainUUID,
'secret')
if not isinstance(values, dict):
@@ -215,11 +217,11 @@ class Client(object):
self._request('post', url, json=data)
return True
- def getSecret(self, domainName, secretName):
+ def getSecret(self, domainUUID, secretName):
"""Get a particular Secret from Domain.
Args:
- domainName (str): Name of the secret domain
+ domainUUID (str): UUID of the secret domain
secretName (str): Name of the secret
Returns:
@@ -227,28 +229,28 @@ class Client(object):
which form the secret
"""
- domainName = domainName.strip()
+ domainUUID = domainUUID.strip()
secretName = secretName.strip()
- url = self._urlJoin(self._base_api_url, 'domain', domainName,
+ url = self._urlJoin(self._base_api_url, 'domain', domainUUID,
'secret', secretName)
response = self._request('get', url)
return response.json()['values']
- def deleteSecret(self, domainName, secretName):
+ def deleteSecret(self, domainUUID, secretName):
"""Delete a particular Secret from Domain.
Args:
- domainName (str): Name of the secret domain
+ domainUUID (str): UUID of the secret domain
secretName (str): Name of the secret
Returns:
bool: True. An exception will be raised if delete failed.
"""
- domainName = domainName.strip()
+ domainUUID = domainUUID.strip()
secretName = secretName.strip()
- url = self._urlJoin(self._base_api_url, 'domain', domainName,
+ url = self._urlJoin(self._base_api_url, 'domain', domainUUID,
'secret', secretName)
self._request('delete', url)