Skip to content

Commit f817861

Browse files
authored
Merge branch 'master' into fix-attachment-actions
2 parents 9b904f9 + b5fb0d3 commit f817861

20 files changed

+222
-244
lines changed

docs/contributing.rst

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ Notes on the Test Suite
3131

3232
To test all the API endpoints, the account that you use for testing must be an *admin* user for your Webex Teams Organization. Additionally, you should know that that the testing process creates some test people, rooms, messages, teams, and etc. as part of executing the test suite. We strongly recommend *NOT* running the test suite using your personal Webex Teams account (not that you can't; it's just that you probably don't want it cluttering your account with all these test artifacts).
3333

34-
If you cannot create a test account with *admin* privileges or configure your environment to run the test suite locally, you may always submit your code via a pull request. Our GitHub/Travis CI setup runs the test suite against all pull requests. All tests must pass before your pull request is accepted.
34+
If you cannot create a test account with *admin* privileges or configure your environment to run the test suite locally, you may always submit your code via a pull request. We will test your code before merging and releasing the changes.
3535

3636

37-
Contributing Code - Using the CI Automated Testing
38-
--------------------------------------------------
37+
Contributing Code
38+
-----------------
3939

4040
1. Check for open `issues`_ or create a new *issue* for the item you want to work on and make sure to comment and let us know that you are working on it.
4141

@@ -57,54 +57,33 @@ Contributing Code - Using the CI Automated Testing
5757

5858
7. Commit your changes.
5959

60-
8. Submit a `pull request`_. The GitHub/Travis CI system runs the test suite against your pull request code. If any tests fail, please review your changes. If everything looks good, we will gladly merge your request!
61-
62-
63-
Contributing Code - Running the Test Suite Locally
64-
--------------------------------------------------
65-
66-
1. Check for open `issues`_ or create a new 'issue' for the item you want to work on and make sure to comment and let us know that you are working on it.
67-
68-
2. Fork a copy of the `repository`_ and clone your forked repository to your development environment.
69-
70-
Run ``script/setup`` to install the development dependencies and setup your environment.
71-
72-
3. Configure the following environment variables in your development environment:
60+
8. Submit a `pull request`_.
7361

74-
* ``WEBEX_TEAMS_ACCESS_TOKEN`` - Your test account's Webex Teams access token.
75-
76-
* ``WEBEX_TEAMS_TEST_DOMAIN`` - The test suite creates some users as part of the testing process. The test suite uses this domain name as the e-mail suffix of for the user's e-mail addresses.
77-
78-
* ``WEBEX_TEAMS_TEST_ID_START`` - The test suite uses this integer as the starting number for creating test user accounts (example: "test42@domain.com").
79-
80-
* ``WEBEX_TEAMS_TEST_FILE_URL`` - Configure this environment variable with a URL referencing a file that can be downloaded and posted to Webex Teams as part of the testing process.
8162

82-
*Example:*
63+
Running the Test Suite Locally
64+
------------------------------
8365

84-
.. code-block:: bash
66+
Configure the following environment variables in your development environment:
8567

86-
#!/usr/bin/env bash
87-
export WEBEX_TEAMS_ACCESS_TOKEN="<test account's access token>"
88-
export WEBEX_TEAMS_TEST_DOMAIN="domain.com"
89-
export WEBEX_TEAMS_TEST_ID_START=42
90-
export WEBEX_TEAMS_TEST_FILE_URL="https://www.webex.com/content/dam/wbx/us/images/dg-integ/teams_icon.png"
68+
* ``WEBEX_TEAMS_ACCESS_TOKEN`` - Your test account's Webex Teams access token.
9169

70+
* ``WEBEX_TEAMS_TEST_DOMAIN`` - The test suite creates some users as part of the testing process. The test suite uses this domain name as the e-mail suffix of for the user's e-mail addresses.
9271

93-
4. Add your code to your forked repository.
72+
* ``WEBEX_TEAMS_TEST_ID_START`` - The test suite uses this integer as the starting number for creating test user accounts (example: "test42@domain.com").
9473

95-
If you are creating some new feature or functionality (excellent!), please also write a `test`_ to verify that your code works as expected.
96-
97-
5. We follow `PEP8`_ reasonably strictly for this project. Please make sure your code passes the linter.
98-
99-
Run ``script/test lint`` or simply run ``flake8`` from the project root.
74+
* ``WEBEX_TEAMS_TEST_FILE_URL`` - Configure this environment variable with a URL referencing a file that can be downloaded and posted to Webex Teams as part of the testing process.
10075

101-
6. Commit your changes.
76+
*Example:*
10277

103-
7. Ensure your code passes all of the default tests.
78+
.. code-block:: bash
10479
105-
Run ``script/test`` and ensure all tests execute successfully.
80+
#!/usr/bin/env bash
81+
export WEBEX_TEAMS_ACCESS_TOKEN="<test account's access token>"
82+
export WEBEX_TEAMS_TEST_DOMAIN="domain.com"
83+
export WEBEX_TEAMS_TEST_ID_START=42
84+
export WEBEX_TEAMS_TEST_FILE_URL="https://www.webex.com/content/dam/wbx/us/images/dg-integ/teams_icon.png"
10685
107-
8. Submit a `pull request`_. If everything looks good, we will gladly merge your request!
86+
Ensure your code passes all of the default tests. Run ``script/test`` and ensure all tests execute successfully.
10887

10988

11089
.. _script: https://github.com/CiscoDevNet/webexteamssdk/tree/master/script

webexteamssdk/api/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
122122
access_token argument or an environment variable.
123123
124124
"""
125-
check_type(access_token, basestring)
126-
check_type(base_url, basestring)
127-
check_type(single_request_timeout, int)
128-
check_type(wait_on_rate_limit, bool)
129-
check_type(client_id, basestring, may_be_none=True)
130-
check_type(client_secret, basestring, may_be_none=True)
131-
check_type(oauth_code, basestring, may_be_none=True)
132-
check_type(redirect_uri, basestring, may_be_none=True)
133-
check_type(proxies, dict, may_be_none=True)
125+
check_type(access_token, basestring, optional=True)
126+
check_type(base_url, basestring, optional=True)
127+
check_type(single_request_timeout, int, optional=True)
128+
check_type(wait_on_rate_limit, bool, optional=True)
129+
check_type(client_id, basestring, optional=True)
130+
check_type(client_secret, basestring, optional=True)
131+
check_type(oauth_code, basestring, optional=True)
132+
check_type(redirect_uri, basestring, optional=True)
133+
check_type(proxies, dict, optional=True)
134134

135135
access_token = access_token or WEBEX_TEAMS_ACCESS_TOKEN
136136

webexteamssdk/api/access_tokens.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def __init__(self, base_url, object_factory, single_request_timeout=None):
7979
TypeError: If the parameter types are incorrect.
8080
8181
"""
82-
check_type(base_url, basestring, may_be_none=False)
83-
check_type(single_request_timeout, int)
82+
check_type(base_url, basestring)
83+
check_type(single_request_timeout, int, optional=True)
8484

8585
super(AccessTokensAPI, self).__init__()
8686

@@ -125,10 +125,10 @@ def get(self, client_id, client_secret, code, redirect_uri):
125125
ApiError: If the Webex Teams cloud returns an error.
126126
127127
"""
128-
check_type(client_id, basestring, may_be_none=False)
129-
check_type(client_secret, basestring, may_be_none=False)
130-
check_type(code, basestring, may_be_none=False)
131-
check_type(redirect_uri, basestring, may_be_none=False)
128+
check_type(client_id, basestring)
129+
check_type(client_secret, basestring)
130+
check_type(code, basestring)
131+
check_type(redirect_uri, basestring)
132132

133133
post_data = dict_from_items_with_values(
134134
grant_type="authorization_code",
@@ -166,9 +166,9 @@ def refresh(self, client_id, client_secret, refresh_token):
166166
ApiError: If the Webex Teams cloud returns an error.
167167
168168
"""
169-
check_type(client_id, basestring, may_be_none=False)
170-
check_type(client_secret, basestring, may_be_none=False)
171-
check_type(refresh_token, basestring, may_be_none=False)
169+
check_type(client_id, basestring)
170+
check_type(client_secret, basestring)
171+
check_type(refresh_token, basestring)
172172

173173
post_data = dict_from_items_with_values(
174174
grant_type="refresh_token",

webexteamssdk/api/attachment_actions.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,10 @@
3333
from builtins import *
3434

3535
from past.builtins import basestring
36-
from requests_toolbelt import MultipartEncoder
3736

38-
from ..generator_containers import generator_container
37+
from ..models.immutable import AttachmentAction
3938
from ..restsession import RestSession
40-
from ..utils import (
41-
check_type, dict_from_items_with_values, is_local_file, is_web_url,
42-
open_local_file,
43-
)
39+
from ..utils import check_type, dict_from_items_with_values
4440

4541

4642
API_ENDPOINT = 'attachment/actions'
@@ -56,7 +52,7 @@ class AttachmentActionsAPI(object):
5652
"""
5753

5854
def __init__(self, session, object_factory):
59-
"""Init a new AttachmentActionsAPI object with the provided RestSession.
55+
"""Initialize a new AttachmentActionsAPI object.
6056
6157
Args:
6258
session(RestSession): The RESTful session object to be used for
@@ -66,26 +62,25 @@ def __init__(self, session, object_factory):
6662
TypeError: If the parameter types are incorrect.
6763
6864
"""
69-
check_type(session, RestSession, may_be_none=False)
65+
check_type(session, RestSession)
7066
super(AttachmentActionsAPI, self).__init__()
7167
self._session = session
7268
self._object_factory = object_factory
7369

74-
def create(self, type=None, messageId=None, inputs=None,
75-
**request_parameters):
76-
"""Create an attachment action.
70+
def create(self, type, messageId, inputs, **request_parameters):
71+
"""Create a new attachment action.
7772
7873
Args:
79-
type(attachment action enum): The type of attachment action.
80-
messageId(basestring): The ID of parent message the attachment
81-
action is to be performed on.
82-
inputs(dict): inputs to attachment fields
74+
type(basestring): The type of action to perform.
75+
messageId(basestring): The ID of the message which contains the
76+
attachment.
77+
inputs(dict): The attachment action's inputs.
8378
**request_parameters: Additional request parameters (provides
8479
support for parameters that may be added in the future).
8580
8681
Returns:
87-
Attachment action: A attachment action object with the details
88-
of the created attachment action.
82+
AttachmentAction: A attachment action object with the details of
83+
the created attachment action.
8984
9085
Raises:
9186
TypeError: If the parameter types are incorrect.
@@ -95,10 +90,9 @@ def create(self, type=None, messageId=None, inputs=None,
9590
contain a valid URL or path to a local file.
9691
9792
"""
98-
99-
check_type(type, basestring, may_be_none=False)
100-
check_type(messageId, basestring, may_be_none=False)
101-
check_type(inputs, dict, may_be_none=False)
93+
check_type(type, basestring)
94+
check_type(messageId, basestring)
95+
check_type(inputs, dict)
10296

10397
post_data = dict_from_items_with_values(
10498
request_parameters,
@@ -128,7 +122,7 @@ def get(self, attachmentId):
128122
ApiError: If the Webex Teams cloud returns an error.
129123
130124
"""
131-
check_type(attachmentId, basestring, may_be_none=False)
125+
check_type(attachmentId, basestring)
132126

133127
# API request
134128
json_data = self._session.get(API_ENDPOINT + '/' + attachmentId)

webexteamssdk/api/events.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, session, object_factory):
6565
TypeError: If the parameter types are incorrect.
6666
6767
"""
68-
check_type(session, RestSession, may_be_none=False)
68+
check_type(session, RestSession)
6969

7070
super(EventsAPI, self).__init__()
7171

@@ -118,12 +118,12 @@ def list(self, resource=None, type=None, actorId=None, _from=None, to=None,
118118
ApiError: If the Webex Teams cloud returns an error.
119119
120120
"""
121-
check_type(resource, basestring)
122-
check_type(type, basestring)
123-
check_type(actorId, basestring)
124-
check_type(_from, basestring)
125-
check_type(to, basestring)
126-
check_type(max, int)
121+
check_type(resource, basestring, optional=True)
122+
check_type(type, basestring, optional=True)
123+
check_type(actorId, basestring, optional=True)
124+
check_type(_from, basestring, optional=True)
125+
check_type(to, basestring, optional=True)
126+
check_type(max, int, optional=True)
127127

128128
params = dict_from_items_with_values(
129129
request_parameters,
@@ -159,7 +159,7 @@ def get(self, eventId):
159159
ApiError: If the Webex Teams cloud returns an error.
160160
161161
"""
162-
check_type(eventId, basestring, may_be_none=False)
162+
check_type(eventId, basestring)
163163

164164
# API request
165165
json_data = self._session.get(API_ENDPOINT + '/' + eventId)

webexteamssdk/api/guest_issuer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def create(self, subject, displayName, issuerToken, expiration, secret):
9595
TypeError: If the parameter types are incorrect
9696
ApiError: If the webex teams cloud returns an error.
9797
"""
98-
check_type(subject, basestring)
99-
check_type(displayName, basestring)
100-
check_type(issuerToken, basestring)
101-
check_type(expiration, basestring)
102-
check_type(secret, basestring)
98+
check_type(subject, basestring, optional=True)
99+
check_type(displayName, basestring, optional=True)
100+
check_type(issuerToken, basestring, optional=True)
101+
check_type(expiration, basestring, optional=True)
102+
check_type(secret, basestring, optional=True)
103103

104104
payload = {
105105
"sub": subject,

webexteamssdk/api/licenses.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, session, object_factory):
6565
TypeError: If the input object is not a dictionary or string.
6666
6767
"""
68-
check_type(session, RestSession, may_be_none=False)
68+
check_type(session, RestSession)
6969

7070
super(LicensesAPI, self).__init__()
7171

@@ -93,7 +93,7 @@ def list(self, orgId=None, **request_parameters):
9393
ApiError: If the Webex Teams cloud returns an error.
9494
9595
"""
96-
check_type(orgId, basestring)
96+
check_type(orgId, basestring, optional=True)
9797

9898
params = dict_from_items_with_values(
9999
request_parameters,
@@ -122,7 +122,7 @@ def get(self, licenseId):
122122
ApiError: If the Webex Teams cloud returns an error.
123123
124124
"""
125-
check_type(licenseId, basestring, may_be_none=False)
125+
check_type(licenseId, basestring)
126126

127127
# API request
128128
json_data = self._session.get(API_ENDPOINT + '/' + licenseId)

webexteamssdk/api/memberships.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ def list(self, roomId=None, personId=None, personEmail=None, max=None,
115115
ApiError: If the Webex Teams cloud returns an error.
116116
117117
"""
118-
check_type(roomId, basestring)
119-
check_type(personId, basestring)
120-
check_type(personEmail, basestring)
121-
check_type(max, int)
118+
check_type(roomId, basestring, optional=True)
119+
check_type(personId, basestring, optional=True)
120+
check_type(personEmail, basestring, optional=True)
121+
check_type(max, int, optional=True)
122122

123123
params = dict_from_items_with_values(
124124
request_parameters,
@@ -159,10 +159,10 @@ def create(self, roomId, personId=None, personEmail=None,
159159
ApiError: If the Webex Teams cloud returns an error.
160160
161161
"""
162-
check_type(roomId, basestring, may_be_none=False)
163-
check_type(personId, basestring)
164-
check_type(personEmail, basestring)
165-
check_type(isModerator, bool)
162+
check_type(roomId, basestring)
163+
check_type(personId, basestring, optional=True)
164+
check_type(personEmail, basestring, optional=True)
165+
check_type(isModerator, bool, optional=True)
166166

167167
post_data = dict_from_items_with_values(
168168
request_parameters,
@@ -193,7 +193,7 @@ def get(self, membershipId):
193193
ApiError: If the Webex Teams cloud returns an error.
194194
195195
"""
196-
check_type(membershipId, basestring, may_be_none=False)
196+
check_type(membershipId, basestring)
197197

198198
# API request
199199
json_data = self._session.get(API_ENDPOINT + '/' + membershipId)
@@ -219,8 +219,8 @@ def update(self, membershipId, isModerator=None, **request_parameters):
219219
ApiError: If the Webex Teams cloud returns an error.
220220
221221
"""
222-
check_type(membershipId, basestring, may_be_none=False)
223-
check_type(isModerator, bool)
222+
check_type(membershipId, basestring)
223+
check_type(isModerator, bool, optional=True)
224224

225225
put_data = dict_from_items_with_values(
226226
request_parameters,

0 commit comments

Comments
 (0)