Skip to content

Commit 535136a

Browse files
author
PureCloud Jenkins
committed
227.0.0
1 parent 6c7a4a8 commit 535136a

File tree

5,723 files changed

+28891
-19644
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,723 files changed

+28891
-19644
lines changed

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
Documentation can be found at https://mypurecloud.github.io/platform-client-sdk-python/
77

8-
Documentation version PureCloudPlatformClientV2 226.0.0
8+
Documentation version PureCloudPlatformClientV2 227.0.0
99

1010
## Preview APIs
1111

@@ -379,6 +379,39 @@ worktype_update.default_queue_id = PureCloudPlatformClientV2.ApiNullValue()
379379
task_api.patch_taskmanagement_worktype(worktype_id, worktype_update)
380380
```
381381

382+
### Managing updates in Platform API Enumerations
383+
384+
The Platform API Client SDKs (Java, Javascript/NodeJs, Python, Go, .Net, iOS/Swift) are automatically generated using the Platform API OpenAPI v2 definition.
385+
The Platform API definition file is downloaded at the time of the SDK build and is used to generate operations (i.e. API methods) and definitions (i.e. classes for the different models, enumerations, ...) in the different SDK languages.
386+
387+
The Python Platform API Client SDK implements the following strategy to manage the introduction of new enumeration values in the Platform API (i.e. in a version of the SDK which doesn't include these changes):
388+
* If an unknown enumeration value is received (i.e. a new enumeration value, introduced in Platform API, after the SDK version you are using was built), the SDK will map it to a `outdated_sdk_version` string value. This is to prevent errors during deserialization when an unknown enumeration value is received from Genesys Cloud.
389+
390+
## Inject Custom HTTP Client
391+
By default, the SDK uses the urllib3 library as the default HTTP client. If you want to inject a new third-party/custom implementation of the client, you can set the HTTP client instance.
392+
393+
The CustomHttpClient should be a class that inherits from AbstractHttpClient defined in the SDK and implements the request method. Here's an example:
394+
395+
```python
396+
from PureCloudPlatformClientV2 import AbstractHttpClient
397+
import requests
398+
399+
class CustomHttpClient(AbstractHttpClient):
400+
def __init__(self):
401+
super().__init__()
402+
self._session = requests.Session()
403+
404+
def request(self, options):
405+
return self._session.request(**options)
406+
407+
# Initialize the API client
408+
api_client = PureCloudPlatformClientV2.api_client.ApiClient()
409+
410+
# Create and set custom HTTP client
411+
http_client = CustomHttpClient()
412+
api_client.set_http_client(http_client)
413+
414+
382415
## SDK Source Code Generation
383416

384417
The SDK is automatically regenerated and published from the API's definition after each API release. For more information on the build process, see the [platform-client-sdk-common](https://github.com/MyPureCloud/platform-client-sdk-common) project.
@@ -391,4 +424,4 @@ The SDK's version is incremented according to the [Semantic Versioning Specifica
391424

392425
This package is intended to be forwards compatible with v2 of Genesys Cloud's Platform API. While the general policy for the API is not to introduce breaking changes, there are certain additions and changes to the API that cause breaking changes for the SDK, often due to the way the API is expressed in its swagger definition. Because of this, the SDK can have a major version bump while the API remains at major version 2. While the SDK is intended to be forward compatible, patches will only be released to the latest version. For these reasons, it is strongly recommended that all applications using this SDK are kept up to date and use the latest version of the SDK.
393426

394-
For any issues, questions, or suggestions for the SDK, visit the [Genesys Cloud Developer Forum](https://developer.genesys.cloud/forum/).
427+
For any issues, questions, or suggestions for the SDK, visit the [Genesys Cloud Developer Community](https://community.genesys.com/communities/community-home1/digestviewer?CommunityKey=a39cc4d6-857e-43cb-be7b-019581ab9f38).

build/.openapi-generator/FILES

Lines changed: 88 additions & 32 deletions
Large diffs are not rendered by default.

build/APIData.json

Lines changed: 67 additions & 9 deletions
Large diffs are not rendered by default.

build/PureCloudPlatformClientV2/__init__.py

Lines changed: 43 additions & 16 deletions
Large diffs are not rendered by default.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from abc import ABC, abstractmethod
2+
3+
class AbstractHttpClient(ABC):
4+
def __init__(self):
5+
self.timeout = 16000
6+
self.https_agent = None #it is a http proxy agent will be used later
7+
8+
def set_timeout(self, timeout):
9+
if not isinstance(timeout, (int, float)):
10+
raise ValueError("The 'timeout' property must be a number")
11+
self.timeout = timeout
12+
13+
@abstractmethod
14+
def request(self, http_request_options):
15+
raise NotImplementedError("method must be implemented")

build/PureCloudPlatformClientV2/api_client.py

Lines changed: 62 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
from __future__ import absolute_import
2222
from . import models
23-
from .rest import RESTClientObject
23+
from .abstract_http_client import AbstractHttpClient
24+
from .default_http_client import DefaultHttpClient
25+
from .http_request_options import HttpRequestOptions
2426
from .rest import ApiException
2527
from .api_null_value import ApiNullValue
2628

@@ -76,7 +78,7 @@ def __init__(self, host=None, header_name=None, header_value=None, cookie=None):
7678
"""
7779
Constructor of the class.
7880
"""
79-
self.rest_client = RESTClientObject()
81+
self.http_client = None
8082
self.default_headers = {}
8183
if header_name is not None:
8284
self.default_headers[header_name] = header_value
@@ -133,6 +135,21 @@ def get_conf_url(self, path_type, base_path):
133135
url = url + "/" + self.gateway_configuration.path_params_api
134136
return url
135137

138+
def get_http_client(self):
139+
if self.http_client is None:
140+
self.http_client = DefaultHttpClient()
141+
142+
return self.http_client
143+
144+
def set_http_client(self, http_client):
145+
if http_client is None:
146+
raise ValueError("http_client cannot be None")
147+
148+
if not isinstance(http_client, AbstractHttpClient):
149+
raise ValueError("http_client must be an instance of AbstractHttpClient")
150+
151+
self.http_client = http_client
152+
136153
def get_client_credentials_token(self, client_id, client_secret):
137154
"""
138155
:param client_id: Client ID to authenticate with
@@ -155,10 +172,13 @@ def get_client_credentials_token(self, client_id, client_secret):
155172
header_params = self.sanitize_for_serialization(header_params)
156173
post_params = self.sanitize_for_serialization(post_params)
157174

158-
response = self.request("POST", url,
159-
query_params=query_params,
160-
headers=header_params,
161-
post_params=post_params, body=body);
175+
request_options = HttpRequestOptions(url = url, method = "POST",
176+
headers = header_params,
177+
post_params = post_params,
178+
body = body)
179+
http_client = self.get_http_client()
180+
response = http_client.request(request_options)
181+
162182
data = json.loads('[' + response.data + ']')
163183
self.access_token = data[0]["access_token"]
164184
return self;
@@ -190,10 +210,13 @@ def get_saml2bearer_token(self,client_id,client_secret,org_name,assertion):
190210
header_params = self.sanitize_for_serialization(header_params)
191211
post_params = self.sanitize_for_serialization(post_params)
192212

193-
response = self.request("POST", url,
194-
query_params=query_params,
195-
headers=header_params,
196-
post_params=post_params, body=body);
213+
request_options = HttpRequestOptions(url = url, method = "POST",
214+
headers = header_params,
215+
post_params = post_params,
216+
body = body)
217+
http_client = self.get_http_client()
218+
response = http_client.request(request_options)
219+
197220
data = json.loads('[' + response.data + ']')
198221
self.access_token = data[0]["access_token"]
199222
return self;
@@ -228,12 +251,14 @@ def get_code_authorization_token(self,client_id,client_secret,auth_code,redirect
228251
header_params = self.sanitize_for_serialization(header_params)
229252
post_params = self.sanitize_for_serialization(post_params)
230253

231-
response = self.request("POST", url,
232-
query_params=query_params,
233-
headers=header_params,
234-
post_params=post_params, body=body)
235-
data = json.loads('[' + response.data + ']')
254+
request_options = HttpRequestOptions(url = url, method = "POST",
255+
headers = header_params,
256+
post_params = post_params,
257+
body = body)
258+
http_client = self.get_http_client()
259+
response = http_client.request(request_options)
236260

261+
data = json.loads('[' + response.data + ']')
237262
self.access_token = data[0]["access_token"]
238263
self.refresh_token = data[0]["refresh_token"]
239264

@@ -264,12 +289,14 @@ def refresh_code_authorization_token(self,client_id,client_secret,refresh_token)
264289
header_params = self.sanitize_for_serialization(header_params)
265290
post_params = self.sanitize_for_serialization(post_params)
266291

267-
response = self.request("POST", url,
268-
query_params=query_params,
269-
headers=header_params,
270-
post_params=post_params, body=body)
271-
data = json.loads('[' + response.data + ']')
292+
request_options = HttpRequestOptions(url = url, method = "POST",
293+
headers = header_params,
294+
post_params = post_params,
295+
body = body)
296+
http_client = self.get_http_client()
297+
response = http_client.request(request_options)
272298

299+
data = json.loads('[' + response.data + ']')
273300
self.access_token = data[0]["access_token"]
274301
self.refresh_token = data[0]["refresh_token"]
275302

@@ -325,12 +352,14 @@ def get_pkce_token(self,client_id,code_verifier,auth_code,redirect_uri):
325352
header_params = self.sanitize_for_serialization(header_params)
326353
post_params = self.sanitize_for_serialization(post_params)
327354

328-
response = self.request("POST", url,
329-
query_params=query_params,
330-
headers=header_params,
331-
post_params=post_params, body=body)
332-
data = json.loads('[' + response.data + ']')
355+
request_options = HttpRequestOptions(url = url, method = "POST",
356+
headers = header_params,
357+
post_params = post_params,
358+
body = body)
359+
http_client = self.get_http_client()
360+
response = http_client.request(request_options)
333361

362+
data = json.loads('[' + response.data + ']')
334363
self.access_token = data[0]["access_token"]
335364

336365
return self, data[0]
@@ -390,7 +419,7 @@ def __call_api(self, resource_path, method,
390419
header_params['Cookie'] = self.cookie
391420
if header_params:
392421
header_params = self.sanitize_for_serialization(header_params)
393-
header_params['purecloud-sdk'] = '226.0.0'
422+
header_params['purecloud-sdk'] = '227.0.0'
394423

395424
# path parameters
396425
if path_params:
@@ -435,8 +464,13 @@ def __call_api(self, resource_path, method,
435464

436465
try:
437466
# perform request and return response
438-
response_data = self.request(method, url, query_params=query_params,
439-
headers=header_params, post_params=post_params, body=body)
467+
request_options = HttpRequestOptions(url = url, method = method,
468+
headers = header_params,
469+
query_params = query_params,
470+
post_params = post_params,
471+
body = body)
472+
http_client = self.get_http_client()
473+
response_data = http_client.request(request_options)
440474
Configuration().logger.trace(method, log_url, body, response_data.status, header_params, response_data.getheaders())
441475
Configuration().logger.debug(method, log_url, body, response_data.status, header_params)
442476
except ApiException as e:
@@ -645,54 +679,6 @@ def call_api(self, resource_path, method,
645679
thread.start()
646680
return thread
647681

648-
def request(self, method, url, query_params=None, headers=None,
649-
post_params=None, body=None):
650-
"""
651-
Makes the HTTP request using RESTClient.
652-
"""
653-
if method == "GET":
654-
return self.rest_client.GET(url,
655-
query_params=query_params,
656-
headers=headers)
657-
elif method == "HEAD":
658-
return self.rest_client.HEAD(url,
659-
query_params=query_params,
660-
headers=headers)
661-
elif method == "OPTIONS":
662-
return self.rest_client.OPTIONS(url,
663-
query_params=query_params,
664-
headers=headers,
665-
post_params=post_params,
666-
body=body)
667-
elif method == "POST":
668-
return self.rest_client.POST(url,
669-
query_params=query_params,
670-
headers=headers,
671-
post_params=post_params,
672-
body=body)
673-
elif method == "PUT":
674-
return self.rest_client.PUT(url,
675-
query_params=query_params,
676-
headers=headers,
677-
post_params=post_params,
678-
body=body)
679-
elif method == "PATCH":
680-
return self.rest_client.PATCH(url,
681-
query_params=query_params,
682-
headers=headers,
683-
post_params=post_params,
684-
body=body)
685-
elif method == "DELETE":
686-
return self.rest_client.DELETE(url,
687-
query_params=query_params,
688-
headers=headers,
689-
body=body)
690-
else:
691-
raise ValueError(
692-
"http method must be `GET`, `HEAD`,"
693-
" `POST`, `PATCH`, `PUT` or `DELETE`."
694-
)
695-
696682
def prepare_post_parameters(self, post_params=None, files=None):
697683
"""
698684
Builds form parameters.

build/PureCloudPlatformClientV2/apis/chat_api.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from ..models import RoomParticipantsResponse
5252
from ..models import RoomUpdateRequest
5353
from ..models import SendMessageBody
54+
from ..models import UserSettingsForChat
5455

5556
class ChatApi(object):
5657
"""
@@ -1463,7 +1464,7 @@ def get_chats_user_settings(self, user_id: str, **kwargs) -> 'ChatUserSettings':
14631464
callback=params.get('callback'))
14641465
return response
14651466

1466-
def get_chats_users_me_settings(self, **kwargs) -> 'ChatUserSettings':
1467+
def get_chats_users_me_settings(self, **kwargs) -> 'UserSettingsForChat':
14671468
"""
14681469
Get a user's chat settings
14691470
@@ -1478,7 +1479,7 @@ def get_chats_users_me_settings(self, **kwargs) -> 'ChatUserSettings':
14781479
14791480
:param callback function: The callback function
14801481
for asynchronous request. (optional)
1481-
:return: ChatUserSettings
1482+
:return: UserSettingsForChat
14821483
If the method is called asynchronously,
14831484
returns the request thread.
14841485
"""
@@ -1530,7 +1531,7 @@ def get_chats_users_me_settings(self, **kwargs) -> 'ChatUserSettings':
15301531
body=body_params,
15311532
post_params=form_params,
15321533
files=local_var_files,
1533-
response_type='ChatUserSettings',
1534+
response_type='UserSettingsForChat',
15341535
auth_settings=auth_settings,
15351536
callback=params.get('callback'))
15361537
return response
@@ -1961,7 +1962,7 @@ def patch_chats_user_settings(self, user_id: str, body: 'ChatUserSettings', **kw
19611962
callback=params.get('callback'))
19621963
return response
19631964

1964-
def patch_chats_users_me_settings(self, body: 'ChatUserSettings', **kwargs) -> 'ChatUserSettings':
1965+
def patch_chats_users_me_settings(self, body: 'UserSettingsForChat', **kwargs) -> 'UserSettingsForChat':
19651966
"""
19661967
Update a user's chat settings
19671968
@@ -1976,8 +1977,8 @@ def patch_chats_users_me_settings(self, body: 'ChatUserSettings', **kwargs) -> '
19761977
19771978
:param callback function: The callback function
19781979
for asynchronous request. (optional)
1979-
:param ChatUserSettings body: (required)
1980-
:return: ChatUserSettings
1980+
:param UserSettingsForChat body: (required)
1981+
:return: UserSettingsForChat
19811982
If the method is called asynchronously,
19821983
returns the request thread.
19831984
"""
@@ -2034,7 +2035,7 @@ def patch_chats_users_me_settings(self, body: 'ChatUserSettings', **kwargs) -> '
20342035
body=body_params,
20352036
post_params=form_params,
20362037
files=local_var_files,
2037-
response_type='ChatUserSettings',
2038+
response_type='UserSettingsForChat',
20382039
auth_settings=auth_settings,
20392040
callback=params.get('callback'))
20402041
return response

0 commit comments

Comments
 (0)