Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
cmlccie committed Jun 20, 2017
2 parents 8c438b7 + cbed76f commit e249eb6
Show file tree
Hide file tree
Showing 30 changed files with 178 additions and 290 deletions.
7 changes: 3 additions & 4 deletions ciscosparkapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
unicode_literals,
)
from builtins import *

from past.builtins import basestring

import os
Expand Down Expand Up @@ -101,10 +100,10 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
via one of these two methods.
Args:
access_token(str): The access token to be used for API
access_token(basestring): The access token to be used for API
calls to the Cisco Spark service. Defaults to checking for a
SPARK_ACCESS_TOKEN environment variable.
base_url(str): The base URL to be prefixed to the
base_url(basestring): The base URL to be prefixed to the
individual API endpoint suffixes.
Defaults to ciscosparkapi.DEFAULT_BASE_URL.
timeout(int): Timeout (in seconds) for RESTful HTTP requests.
Expand All @@ -122,7 +121,7 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
"""
# Process args
assert access_token is None or isinstance(access_token, basestring)
assert isinstance(base_url, str)
assert isinstance(base_url, basestring)
assert isinstance(timeout, int)
spark_access_token = os.environ.get(ACCESS_TOKEN_ENVIRONMENT_VARIABLE)
access_token = access_token if access_token else spark_access_token
Expand Down
35 changes: 18 additions & 17 deletions ciscosparkapi/api/accesstokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
unicode_literals,
)
from builtins import *
from past.builtins import basestring
from future import standard_library
standard_library.install_aliases()

Expand Down Expand Up @@ -50,7 +51,7 @@ def __init__(self, json):
"""Init a new AccessToken data object from a JSON dictionary or string.
Args:
json(dict, str): Input JSON object.
json(dict, basestring): Input JSON object.
Raises:
TypeError: If the input object is not a dictionary or string.
Expand Down Expand Up @@ -91,14 +92,14 @@ def __init__(self, base_url, timeout=None):
"""Init a new AccessTokensAPI object with the provided RestSession.
Args:
base_url(str): The base URL the API endpoints.
base_url(basestring): The base URL the API endpoints.
timeout(int): Timeout in seconds for the API requests.
Raises:
AssertionError: If the parameter types are incorrect.
"""
assert isinstance(base_url, str)
assert isinstance(base_url, basestring)
assert timeout is None or isinstance(timeout, int)
super(AccessTokensAPI, self).__init__()
self._base_url = str(validate_base_url(base_url))
Expand All @@ -122,13 +123,13 @@ def get(self, client_id, client_secret, code, redirect_uri):
invoke the APIs.
Args:
client_id(str): Provided when you created your
client_id(basestring): Provided when you created your
integration.
client_secret(str): Provided when you created your
client_secret(basestring): Provided when you created your
integration.
code(str): The Authorization Code provided by the user
code(basestring): The Authorization Code provided by the user
OAuth process.
redirect_uri(str): The redirect URI used in the user OAuth
redirect_uri(basestring): The redirect URI used in the user OAuth
process.
Returns:
Expand All @@ -141,10 +142,10 @@ def get(self, client_id, client_secret, code, redirect_uri):
"""
# Process args
assert isinstance(client_id, str)
assert isinstance(client_secret, str)
assert isinstance(code, str)
assert isinstance(redirect_uri, str)
assert isinstance(client_id, basestring)
assert isinstance(client_secret, basestring)
assert isinstance(code, basestring)
assert isinstance(redirect_uri, basestring)
# Build request parameters
data = {}
data["grant_type"] = "authorization_code"
Expand All @@ -164,11 +165,11 @@ def refresh(self, client_id, client_secret, refresh_token):
"""Return a refreshed Access Token via the provided refresh_token.
Args:
client_id(str): Provided when you created your
client_id(basestring): Provided when you created your
integration.
client_secret(str): Provided when you created your
client_secret(basestring): Provided when you created your
integration.
refresh_token(str): Provided when you requested the Access
refresh_token(basestring): Provided when you requested the Access
Token.
Returns:
Expand All @@ -181,9 +182,9 @@ def refresh(self, client_id, client_secret, refresh_token):
"""
# Process args
assert isinstance(client_id, str)
assert isinstance(client_secret, str)
assert isinstance(refresh_token, str)
assert isinstance(client_id, basestring)
assert isinstance(client_secret, basestring)
assert isinstance(refresh_token, basestring)
# Build request parameters
data = {}
data["grant_type"] = "refresh_token"
Expand Down
11 changes: 6 additions & 5 deletions ciscosparkapi/api/licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
unicode_literals,
)
from builtins import *
from past.builtins import basestring

from ciscosparkapi.utils import generator_container
from ciscosparkapi.restsession import RestSession
Expand All @@ -36,7 +37,7 @@ def __init__(self, json):
"""Init a new License data object from a dict or JSON string.
Args:
json(dict, str): Input JSON object.
json(dict, basestring): Input JSON object.
Raises:
TypeError: If the input object is not a dictionary or string.
Expand Down Expand Up @@ -105,7 +106,7 @@ def list(self, orgId=None, max=None):
container.
Args:
orgId(str): Filters the returned licenses to only include
orgId(basestring): Filters the returned licenses to only include
those liceses associated with the specified Organization
(orgId).
max(int): Limits the maximum number of entries returned from the
Expand All @@ -122,7 +123,7 @@ def list(self, orgId=None, max=None):
"""
# Process args
assert orgId is None or isinstance(orgId, str)
assert orgId is None or isinstance(orgId, basestring)
assert max is None or isinstance(max, int)
params = {}
if orgId:
Expand All @@ -139,7 +140,7 @@ def get(self, licenseId):
"""Get the details of a License, by id.
Args:
licenseId(str): The id of the License.
licenseId(basestring): The id of the License.
Returns:
License: With the details of the requested License.
Expand All @@ -150,7 +151,7 @@ def get(self, licenseId):
"""
# Process args
assert isinstance(licenseId, str)
assert isinstance(licenseId, basestring)
# API request
json_obj = self._session.get('licenses/' + licenseId)
# Return a License object created from the returned JSON object
Expand Down
39 changes: 20 additions & 19 deletions ciscosparkapi/api/memberships.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
unicode_literals,
)
from builtins import *
from past.builtins import basestring

from ciscosparkapi.exceptions import ciscosparkapiException
from ciscosparkapi.utils import generator_container
Expand All @@ -38,7 +39,7 @@ def __init__(self, json):
"""Init a new Membership data object from a JSON dictionary or string.
Args:
json(dict, str): Input JSON object.
json(dict, basestring): Input JSON object.
Raises:
TypeError: If the input object is not a dictionary or string.
Expand Down Expand Up @@ -126,10 +127,10 @@ def list(self, roomId=None, personId=None, personEmail=None, max=None):
container.
Args:
roomId(str): List memberships for the room with roomId.
personId(str): Filter results to include only those with
roomId(basestring): List memberships for the room with roomId.
personId(basestring): Filter results to include only those with
personId.
personEmail(str): Filter results to include only those
personEmail(basestring): Filter results to include only those
with personEmail.
max(int): Limits the maximum number of memberships returned from
the Spark service per request.
Expand All @@ -147,9 +148,9 @@ def list(self, roomId=None, personId=None, personEmail=None, max=None):
"""
# Process args
assert roomId is None or isinstance(roomId, str)
assert personId is None or isinstance(personId, str)
assert personEmail is None or isinstance(personEmail, str)
assert roomId is None or isinstance(roomId, basestring)
assert personId is None or isinstance(personId, basestring)
assert personEmail is None or isinstance(personEmail, basestring)
assert max is None or isinstance(max, int)
params = {}
if roomId:
Expand Down Expand Up @@ -180,10 +181,10 @@ def create(self, roomId, personId=None, personEmail=None,
making them a moderator.
Args:
roomId(str): ID of the room to which the person will be
roomId(basestring): ID of the room to which the person will be
added.
personId(str): ID of the person to be added to the room.
personEmail(str): Email address of the person to be added
personId(basestring): ID of the person to be added to the room.
personEmail(basestring): Email address of the person to be added
to the room.
isModerator(bool): If True, adds the person as a moderator for the
room. If False, adds the person as normal member of the room.
Expand All @@ -199,9 +200,9 @@ def create(self, roomId, personId=None, personEmail=None,
"""
# Process args
assert isinstance(roomId, str)
assert personId is None or isinstance(personId, str)
assert personEmail is None or isinstance(personEmail, str)
assert isinstance(roomId, basestring)
assert personId is None or isinstance(personId, basestring)
assert personEmail is None or isinstance(personEmail, basestring)
assert isModerator is None or isinstance(isModerator, bool)
post_data = {}
post_data['roomId'] = roomId
Expand All @@ -223,7 +224,7 @@ def get(self, membershipId):
"""Get details for a membership by ID.
Args:
membershipId(str): The membershipId of the membership.
membershipId(basestring): The membershipId of the membership.
Returns:
Membership: With the details of the requested membership.
Expand All @@ -234,7 +235,7 @@ def get(self, membershipId):
"""
# Process args
assert isinstance(membershipId, str)
assert isinstance(membershipId, basestring)
# API request
json_obj = self._session.get('memberships/' + membershipId)
# Return a Membership object created from the response JSON data
Expand All @@ -244,7 +245,7 @@ def update(self, membershipId, **update_attributes):
"""Update details for a membership.
Args:
membershipId(str): The membershipId of the membership to
membershipId(basestring): The membershipId of the membership to
be updated.
isModerator(bool): If True, sets the person as a moderator for the
room. If False, removes the person as a moderator for the room.
Expand All @@ -259,7 +260,7 @@ def update(self, membershipId, **update_attributes):
"""
# Process args
assert isinstance(membershipId, str)
assert isinstance(membershipId, basestring)
# Process update_attributes keyword arguments
if not update_attributes:
error_message = "At least one **update_attributes keyword " \
Expand All @@ -275,7 +276,7 @@ def delete(self, membershipId):
"""Delete a membership, by ID.
Args:
membershipId(str): The membershipId of the membership to
membershipId(basestring): The membershipId of the membership to
be deleted.
Raises:
Expand All @@ -284,6 +285,6 @@ def delete(self, membershipId):
"""
# Process args
assert isinstance(membershipId, str)
assert isinstance(membershipId, basestring)
# API request
self._session.delete('memberships/' + membershipId)
Loading

0 comments on commit e249eb6

Please sign in to comment.