ibm-cloud-sdk-core 3.20.6__py3-none-any.whl → 3.21.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ibm_cloud_sdk_core/authenticators/basic_authenticator.py +7 -1
- ibm_cloud_sdk_core/authenticators/bearer_token_authenticator.py +6 -1
- ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py +5 -2
- ibm_cloud_sdk_core/authenticators/iam_request_based_authenticator.py +5 -1
- ibm_cloud_sdk_core/authenticators/mcsp_authenticator.py +5 -1
- ibm_cloud_sdk_core/authenticators/vpc_instance_authenticator.py +5 -1
- ibm_cloud_sdk_core/base_service.py +27 -9
- ibm_cloud_sdk_core/get_authenticator.py +7 -1
- ibm_cloud_sdk_core/logger.py +85 -0
- ibm_cloud_sdk_core/token_managers/container_token_manager.py +2 -3
- ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py +5 -0
- ibm_cloud_sdk_core/token_managers/iam_request_based_token_manager.py +7 -1
- ibm_cloud_sdk_core/token_managers/mcsp_token_manager.py +7 -1
- ibm_cloud_sdk_core/token_managers/token_manager.py +7 -0
- ibm_cloud_sdk_core/token_managers/vpc_instance_token_manager.py +4 -5
- ibm_cloud_sdk_core/utils.py +6 -2
- ibm_cloud_sdk_core/version.py +1 -1
- ibm_cloud_sdk_core-3.21.0.dist-info/METADATA +159 -0
- {ibm_cloud_sdk_core-3.20.6.dist-info → ibm_cloud_sdk_core-3.21.0.dist-info}/RECORD +22 -21
- {ibm_cloud_sdk_core-3.20.6.dist-info → ibm_cloud_sdk_core-3.21.0.dist-info}/WHEEL +1 -1
- ibm_cloud_sdk_core-3.20.6.dist-info/METADATA +0 -124
- {ibm_cloud_sdk_core-3.20.6.dist-info → ibm_cloud_sdk_core-3.21.0.dist-info}/LICENSE +0 -0
- {ibm_cloud_sdk_core-3.20.6.dist-info → ibm_cloud_sdk_core-3.21.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
# Copyright 2019 IBM All Rights Reserved.
|
|
3
|
+
# Copyright 2019, 2024 IBM All Rights Reserved.
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
@@ -15,11 +15,15 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
|
|
17
17
|
import base64
|
|
18
|
+
|
|
18
19
|
from requests import Request
|
|
19
20
|
|
|
21
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
20
22
|
from .authenticator import Authenticator
|
|
21
23
|
from ..utils import has_bad_first_or_last_char
|
|
22
24
|
|
|
25
|
+
logger = get_logger()
|
|
26
|
+
|
|
23
27
|
|
|
24
28
|
class BasicAuthenticator(Authenticator):
|
|
25
29
|
"""The BasicAuthenticator is used to add basic authentication information to requests.
|
|
@@ -41,6 +45,7 @@ class BasicAuthenticator(Authenticator):
|
|
|
41
45
|
self.password = password
|
|
42
46
|
self.validate()
|
|
43
47
|
self.authorization_header = self.__construct_basic_auth_header()
|
|
48
|
+
logger.debug('Created new BasicAuthenticator instance!')
|
|
44
49
|
|
|
45
50
|
def authentication_type(self) -> str:
|
|
46
51
|
"""Returns this authenticator's type ('basic')."""
|
|
@@ -81,3 +86,4 @@ class BasicAuthenticator(Authenticator):
|
|
|
81
86
|
"""
|
|
82
87
|
headers = req.get('headers')
|
|
83
88
|
headers['Authorization'] = self.authorization_header
|
|
89
|
+
logger.debug('Authenticated outbound request (type=%s)', self.authentication_type())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
# Copyright 2019 IBM All Rights Reserved.
|
|
3
|
+
# Copyright 2019, 2024 IBM All Rights Reserved.
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
from requests import Request
|
|
18
18
|
|
|
19
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
19
20
|
from .authenticator import Authenticator
|
|
20
21
|
|
|
22
|
+
logger = get_logger()
|
|
23
|
+
|
|
21
24
|
|
|
22
25
|
class BearerTokenAuthenticator(Authenticator):
|
|
23
26
|
"""The BearerTokenAuthenticator will add a user-supplied bearer token
|
|
@@ -37,6 +40,7 @@ class BearerTokenAuthenticator(Authenticator):
|
|
|
37
40
|
def __init__(self, bearer_token: str) -> None:
|
|
38
41
|
self.bearer_token = bearer_token
|
|
39
42
|
self.validate()
|
|
43
|
+
logger.debug('Created BearerTokenAuthenticator instance!')
|
|
40
44
|
|
|
41
45
|
def authentication_type(self) -> str:
|
|
42
46
|
"""Returns this authenticator's type ('bearertoken')."""
|
|
@@ -66,6 +70,7 @@ class BearerTokenAuthenticator(Authenticator):
|
|
|
66
70
|
"""
|
|
67
71
|
headers = req.get('headers')
|
|
68
72
|
headers['Authorization'] = 'Bearer {0}'.format(self.bearer_token)
|
|
73
|
+
logger.debug('Authenticated outbound request (type=%s)', self.authentication_type())
|
|
69
74
|
|
|
70
75
|
def set_bearer_token(self, bearer_token: str) -> None:
|
|
71
76
|
"""Set a new bearer token to be sent in subsequent service operations.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
# Copyright 2019 IBM All Rights Reserved.
|
|
3
|
+
# Copyright 2019, 2024 IBM All Rights Reserved.
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
|
|
17
17
|
from typing import Dict, Optional
|
|
18
|
-
|
|
19
18
|
from requests import Request
|
|
20
19
|
|
|
20
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
21
21
|
from .authenticator import Authenticator
|
|
22
22
|
from ..token_managers.cp4d_token_manager import CP4DTokenManager
|
|
23
23
|
from ..utils import has_bad_first_or_last_char
|
|
24
24
|
|
|
25
|
+
logger = get_logger()
|
|
26
|
+
|
|
25
27
|
|
|
26
28
|
class CloudPakForDataAuthenticator(Authenticator):
|
|
27
29
|
"""The CloudPakForDataAuthenticator utilizes a username and password pair to
|
|
@@ -133,6 +135,7 @@ class CloudPakForDataAuthenticator(Authenticator):
|
|
|
133
135
|
headers = req.get('headers')
|
|
134
136
|
bearer_token = self.token_manager.get_token()
|
|
135
137
|
headers['Authorization'] = 'Bearer {0}'.format(bearer_token)
|
|
138
|
+
logger.debug('Authenticated outbound request (type=%s)', self.authentication_type())
|
|
136
139
|
|
|
137
140
|
def set_disable_ssl_verification(self, status: bool = False) -> None:
|
|
138
141
|
"""Set the flag that indicates whether verification of the server's SSL certificate should be
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
# Copyright 2019 IBM All Rights Reserved.
|
|
3
|
+
# Copyright 2019, 2024 IBM All Rights Reserved.
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,8 +18,11 @@ from typing import Dict
|
|
|
18
18
|
|
|
19
19
|
from requests import Request
|
|
20
20
|
|
|
21
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
21
22
|
from .authenticator import Authenticator
|
|
22
23
|
|
|
24
|
+
logger = get_logger()
|
|
25
|
+
|
|
23
26
|
|
|
24
27
|
class IAMRequestBasedAuthenticator(Authenticator):
|
|
25
28
|
"""The IAMRequestBasedAuthenticator class contains code that is common to all authenticators
|
|
@@ -60,6 +63,7 @@ class IAMRequestBasedAuthenticator(Authenticator):
|
|
|
60
63
|
headers = req.get('headers')
|
|
61
64
|
bearer_token = self.token_manager.get_token()
|
|
62
65
|
headers['Authorization'] = 'Bearer {0}'.format(bearer_token)
|
|
66
|
+
logger.debug('Authenticated outbound request (type=%s)', self.authentication_type())
|
|
63
67
|
|
|
64
68
|
def set_client_id_and_secret(self, client_id: str, client_secret: str) -> None:
|
|
65
69
|
"""Set the client_id and client_secret pair the token manager will use for IAM token requests.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
# Copyright 2023 IBM All Rights Reserved.
|
|
3
|
+
# Copyright 2023, 2024 IBM All Rights Reserved.
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,9 +18,12 @@ from typing import Dict, Optional
|
|
|
18
18
|
|
|
19
19
|
from requests import Request
|
|
20
20
|
|
|
21
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
21
22
|
from .authenticator import Authenticator
|
|
22
23
|
from ..token_managers.mcsp_token_manager import MCSPTokenManager
|
|
23
24
|
|
|
25
|
+
logger = get_logger()
|
|
26
|
+
|
|
24
27
|
|
|
25
28
|
class MCSPAuthenticator(Authenticator):
|
|
26
29
|
"""The MCSPAuthenticator uses an apikey to obtain an access token from the MCSP token server.
|
|
@@ -98,6 +101,7 @@ class MCSPAuthenticator(Authenticator):
|
|
|
98
101
|
headers = req.get('headers')
|
|
99
102
|
bearer_token = self.token_manager.get_token()
|
|
100
103
|
headers['Authorization'] = 'Bearer {0}'.format(bearer_token)
|
|
104
|
+
logger.debug('Authenticated outbound request (type=%s)', self.authentication_type())
|
|
101
105
|
|
|
102
106
|
def set_disable_ssl_verification(self, status: bool = False) -> None:
|
|
103
107
|
"""Set the flag that indicates whether verification of the server's SSL certificate should be
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
# Copyright 2021 IBM All Rights Reserved.
|
|
3
|
+
# Copyright 2021, 2024 IBM All Rights Reserved.
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,9 +18,12 @@ from typing import Optional
|
|
|
18
18
|
|
|
19
19
|
from requests import Request
|
|
20
20
|
|
|
21
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
21
22
|
from ..token_managers.vpc_instance_token_manager import VPCInstanceTokenManager
|
|
22
23
|
from .authenticator import Authenticator
|
|
23
24
|
|
|
25
|
+
logger = get_logger()
|
|
26
|
+
|
|
24
27
|
|
|
25
28
|
class VPCInstanceAuthenticator(Authenticator):
|
|
26
29
|
"""VPCInstanceAuthenticator implements an authentication scheme in which it
|
|
@@ -89,6 +92,7 @@ class VPCInstanceAuthenticator(Authenticator):
|
|
|
89
92
|
headers = req.get('headers')
|
|
90
93
|
bearer_token = self.token_manager.get_token()
|
|
91
94
|
headers['Authorization'] = 'Bearer {0}'.format(bearer_token)
|
|
95
|
+
logger.debug('Authenticated outbound request (type=%s)', self.authentication_type())
|
|
92
96
|
|
|
93
97
|
def set_iam_profile_crn(self, iam_profile_crn: str) -> None:
|
|
94
98
|
"""Sets CRN of the IAM profile.
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
|
|
17
17
|
import gzip
|
|
18
18
|
import io
|
|
19
|
-
import json as json_import
|
|
20
19
|
import logging
|
|
20
|
+
import json as json_import
|
|
21
21
|
from http.cookiejar import CookieJar
|
|
22
|
+
from http import client
|
|
22
23
|
from os.path import basename
|
|
23
24
|
from typing import Dict, List, Optional, Tuple, Union
|
|
24
25
|
from urllib3.util.retry import Retry
|
|
@@ -42,13 +43,12 @@ from .utils import (
|
|
|
42
43
|
GzipStream,
|
|
43
44
|
)
|
|
44
45
|
from .private_helpers import _build_user_agent
|
|
46
|
+
from .logger import (
|
|
47
|
+
get_logger,
|
|
48
|
+
LoggingFilter,
|
|
49
|
+
)
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
# import http.client as http_client
|
|
48
|
-
# http_client.HTTPConnection.debuglevel = 1
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
logger = logging.getLogger(__name__)
|
|
51
|
+
logger = get_logger()
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
# pylint: disable=too-many-instance-attributes
|
|
@@ -92,7 +92,7 @@ class BaseService:
|
|
|
92
92
|
self,
|
|
93
93
|
*,
|
|
94
94
|
service_url: str = None,
|
|
95
|
-
authenticator: Authenticator = None,
|
|
95
|
+
authenticator: Optional[Authenticator] = None,
|
|
96
96
|
disable_ssl_verification: bool = False,
|
|
97
97
|
enable_gzip_compression: bool = False,
|
|
98
98
|
) -> None:
|
|
@@ -114,6 +114,12 @@ class BaseService:
|
|
|
114
114
|
|
|
115
115
|
self.http_client.mount('http://', self.http_adapter)
|
|
116
116
|
self.http_client.mount('https://', self.http_adapter)
|
|
117
|
+
# If debug logging is requested, then trigger HTTP message logging as well.
|
|
118
|
+
if logger.isEnabledFor(logging.DEBUG):
|
|
119
|
+
client.HTTPConnection.debuglevel = 1
|
|
120
|
+
# Replace the `print` function in the HTTPClient module to
|
|
121
|
+
# use the debug logger instead of the bare Python print.
|
|
122
|
+
client.print = lambda *args: logger.debug(LoggingFilter.filter_message(" ".join(args)))
|
|
117
123
|
|
|
118
124
|
def enable_retries(self, max_retries: int = 4, retry_interval: float = 30.0) -> None:
|
|
119
125
|
"""Enable automatic retries on the underlying http client used by the BaseService instance.
|
|
@@ -141,6 +147,7 @@ class BaseService:
|
|
|
141
147
|
)
|
|
142
148
|
self.http_client.mount('http://', self.http_adapter)
|
|
143
149
|
self.http_client.mount('https://', self.http_adapter)
|
|
150
|
+
logger.debug('Enabled retries; max_retries=%d, max_retry_interval=%f', max_retries, retry_interval)
|
|
144
151
|
|
|
145
152
|
def disable_retries(self):
|
|
146
153
|
"""Remove retry config from http_adapter"""
|
|
@@ -148,6 +155,7 @@ class BaseService:
|
|
|
148
155
|
self.http_adapter = SSLHTTPAdapter(_disable_ssl_verification=self.disable_ssl_verification)
|
|
149
156
|
self.http_client.mount('http://', self.http_adapter)
|
|
150
157
|
self.http_client.mount('https://', self.http_adapter)
|
|
158
|
+
logger.debug('Disabled retries')
|
|
151
159
|
|
|
152
160
|
def configure_service(self, service_name: str) -> None:
|
|
153
161
|
"""Look for external configuration of a service. Set service properties.
|
|
@@ -166,6 +174,8 @@ class BaseService:
|
|
|
166
174
|
if not isinstance(service_name, str):
|
|
167
175
|
raise ValueError('Service_name must be of type string.')
|
|
168
176
|
|
|
177
|
+
logger.debug('Configuring BaseService instance with service name: %s', service_name)
|
|
178
|
+
|
|
169
179
|
config = read_external_sources(service_name)
|
|
170
180
|
if config.get('URL'):
|
|
171
181
|
self.set_service_url(config.get('URL'))
|
|
@@ -184,6 +194,7 @@ class BaseService:
|
|
|
184
194
|
|
|
185
195
|
def _set_user_agent_header(self, user_agent_string: str) -> None:
|
|
186
196
|
self.user_agent_header = {'User-Agent': user_agent_string}
|
|
197
|
+
logger.debug('Set User-Agent: %s', user_agent_string)
|
|
187
198
|
|
|
188
199
|
def set_http_config(self, http_config: dict) -> None:
|
|
189
200
|
"""Sets the http config dictionary.
|
|
@@ -225,6 +236,7 @@ class BaseService:
|
|
|
225
236
|
)
|
|
226
237
|
self.http_client.mount('http://', self.http_adapter)
|
|
227
238
|
self.http_client.mount('https://', self.http_adapter)
|
|
239
|
+
logger.debug('Disabled SSL verification in HTTP client')
|
|
228
240
|
|
|
229
241
|
def set_service_url(self, service_url: str) -> None:
|
|
230
242
|
"""Set the url the service will make HTTP requests too.
|
|
@@ -243,6 +255,7 @@ class BaseService:
|
|
|
243
255
|
if service_url is not None:
|
|
244
256
|
service_url = service_url.rstrip('/')
|
|
245
257
|
self.service_url = service_url
|
|
258
|
+
logger.debug('Set service URL: %s', service_url)
|
|
246
259
|
|
|
247
260
|
def get_http_client(self) -> requests.sessions.Session:
|
|
248
261
|
"""Get the http client session currently used by the service.
|
|
@@ -305,7 +318,7 @@ class BaseService:
|
|
|
305
318
|
# Check to see if the caller specified the 'stream' argument.
|
|
306
319
|
stream_response = kwargs.get('stream') or False
|
|
307
320
|
|
|
308
|
-
# Remove the keys we set manually, don't let the user
|
|
321
|
+
# Remove the keys we set manually, don't let the user overwrite these.
|
|
309
322
|
reserved_keys = ['method', 'url', 'headers', 'params', 'cookies']
|
|
310
323
|
silent_keys = ['headers']
|
|
311
324
|
for key in reserved_keys:
|
|
@@ -314,8 +327,12 @@ class BaseService:
|
|
|
314
327
|
if key not in silent_keys:
|
|
315
328
|
logger.warning('"%s" has been removed from the request', key)
|
|
316
329
|
try:
|
|
330
|
+
logger.debug('Sending HTTP request message')
|
|
331
|
+
|
|
317
332
|
response = self.http_client.request(**request, cookies=self.jar, **kwargs)
|
|
318
333
|
|
|
334
|
+
logger.debug('Received HTTP response message, status code %d', response.status_code)
|
|
335
|
+
|
|
319
336
|
# Process a "success" response.
|
|
320
337
|
if 200 <= response.status_code <= 299:
|
|
321
338
|
if response.status_code == 204 or request['method'] == 'HEAD':
|
|
@@ -455,6 +472,7 @@ class BaseService:
|
|
|
455
472
|
file_tuple = (filename, file_tuple[1], file_tuple[2])
|
|
456
473
|
new_files.append((part_name, file_tuple))
|
|
457
474
|
request['files'] = new_files
|
|
475
|
+
logger.debug('Prepared request [%s %s]', request['method'], request['url'])
|
|
458
476
|
return request
|
|
459
477
|
|
|
460
478
|
@staticmethod
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
# Copyright 2019 IBM All Rights Reserved.
|
|
3
|
+
# Copyright 2019, 2024 IBM All Rights Reserved.
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
@@ -26,6 +26,9 @@ from .authenticators import (
|
|
|
26
26
|
MCSPAuthenticator,
|
|
27
27
|
)
|
|
28
28
|
from .utils import read_external_sources
|
|
29
|
+
from .logger import get_logger
|
|
30
|
+
|
|
31
|
+
logger = get_logger()
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
def get_authenticator_from_environment(service_name: str) -> Authenticator:
|
|
@@ -42,10 +45,13 @@ def get_authenticator_from_environment(service_name: str) -> Authenticator:
|
|
|
42
45
|
Returns:
|
|
43
46
|
The authenticator found from service information.
|
|
44
47
|
"""
|
|
48
|
+
logger.debug('Get authenticator from environment, key=%s', service_name)
|
|
45
49
|
authenticator = None
|
|
46
50
|
config = read_external_sources(service_name)
|
|
47
51
|
if config:
|
|
48
52
|
authenticator = __construct_authenticator(config)
|
|
53
|
+
if authenticator is not None:
|
|
54
|
+
logger.debug('Returning authenticator, type=%s', authenticator.authentication_type())
|
|
49
55
|
return authenticator
|
|
50
56
|
|
|
51
57
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# Copyright 2024 IBM All Rights Reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
import logging
|
|
18
|
+
import re
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# This is the name of the primary logger used by the library.
|
|
22
|
+
LOGGER_NAME = 'ibm-cloud-sdk-core'
|
|
23
|
+
# Keywords that are redacted.
|
|
24
|
+
REDACTED_KEYWORDS = [
|
|
25
|
+
"apikey",
|
|
26
|
+
"api_key",
|
|
27
|
+
"passcode",
|
|
28
|
+
"password",
|
|
29
|
+
"token",
|
|
30
|
+
"aadClientId",
|
|
31
|
+
"aadClientSecret",
|
|
32
|
+
"auth",
|
|
33
|
+
"auth_provider_x509_cert_url",
|
|
34
|
+
"auth_uri",
|
|
35
|
+
"client_email",
|
|
36
|
+
"client_id",
|
|
37
|
+
"client_x509_cert_url",
|
|
38
|
+
"key",
|
|
39
|
+
"project_id",
|
|
40
|
+
"secret",
|
|
41
|
+
"subscriptionId",
|
|
42
|
+
"tenantId",
|
|
43
|
+
"thumbprint",
|
|
44
|
+
"token_uri",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class LoggingFilter:
|
|
49
|
+
"""Functions used to filter messages before they are logged."""
|
|
50
|
+
|
|
51
|
+
redacted_tokens = "|".join(REDACTED_KEYWORDS)
|
|
52
|
+
auth_header_pattern = re.compile(r"(?m)(Authorization|X-Auth\S*): ((.*?)(\r\n.*)|(.*))")
|
|
53
|
+
property_settings_pattern = re.compile(r"(?i)(" + redacted_tokens + r")=[^&]*(&|$)")
|
|
54
|
+
json_field_pattern = re.compile(r'(?i)"([^"]*(' + redacted_tokens + r')[^"_]*)":\s*"[^\,]*"')
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def redact_secrets(cls, text: str) -> str:
|
|
58
|
+
"""Replaces values of potential secret keywords with a placeholder value.
|
|
59
|
+
Args:
|
|
60
|
+
text (str): the string to check and process
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
str: the safe, redacted string with all secrets masked out
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
placeholder = "[redacted]"
|
|
67
|
+
redacted = cls.auth_header_pattern.sub(r"\1: " + placeholder + r"\4", text)
|
|
68
|
+
redacted = cls.property_settings_pattern.sub(r"\1=" + placeholder + r"\2", redacted)
|
|
69
|
+
redacted = cls.json_field_pattern.sub(r'"\1":"' + placeholder + r'"', redacted)
|
|
70
|
+
return redacted
|
|
71
|
+
|
|
72
|
+
@classmethod
|
|
73
|
+
def filter_message(cls, s: str) -> str:
|
|
74
|
+
"""Filters 's' prior to logging it as a debug message"""
|
|
75
|
+
# Redact secrets
|
|
76
|
+
s = LoggingFilter.redact_secrets(s)
|
|
77
|
+
|
|
78
|
+
# Replace CRLF characters with an actual newline to make the message more readable.
|
|
79
|
+
s = s.replace('\\r\\n', '\n')
|
|
80
|
+
return s
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def get_logger() -> logging.Logger:
|
|
84
|
+
"""Returns the primary logger object instance used by the library."""
|
|
85
|
+
return logging.getLogger(LOGGER_NAME)
|
|
@@ -14,14 +14,13 @@
|
|
|
14
14
|
# See the License for the specific language governing permissions and
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
|
|
17
|
-
import logging
|
|
18
17
|
from typing import Dict, Optional
|
|
19
18
|
|
|
19
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
20
20
|
from .iam_request_based_token_manager import IAMRequestBasedTokenManager
|
|
21
21
|
from ..private_helpers import _build_user_agent
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
logger = logging.getLogger(__name__)
|
|
23
|
+
logger = get_logger()
|
|
25
24
|
|
|
26
25
|
|
|
27
26
|
class ContainerTokenManager(IAMRequestBasedTokenManager):
|
|
@@ -17,9 +17,12 @@
|
|
|
17
17
|
import json
|
|
18
18
|
from typing import Dict, Optional
|
|
19
19
|
|
|
20
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
20
21
|
from ..private_helpers import _build_user_agent
|
|
21
22
|
from .jwt_token_manager import JWTTokenManager
|
|
22
23
|
|
|
24
|
+
logger = get_logger()
|
|
25
|
+
|
|
23
26
|
|
|
24
27
|
class CP4DTokenManager(JWTTokenManager):
|
|
25
28
|
"""Token Manager of CloudPak for data.
|
|
@@ -89,6 +92,7 @@ class CP4DTokenManager(JWTTokenManager):
|
|
|
89
92
|
request_headers.update(self.headers)
|
|
90
93
|
request_headers.update(required_headers)
|
|
91
94
|
|
|
95
|
+
logger.debug('Invoking CP4D token service operation: %s', self.url)
|
|
92
96
|
response = self._request(
|
|
93
97
|
method='POST',
|
|
94
98
|
headers=request_headers,
|
|
@@ -97,6 +101,7 @@ class CP4DTokenManager(JWTTokenManager):
|
|
|
97
101
|
proxies=self.proxies,
|
|
98
102
|
verify=self.verify,
|
|
99
103
|
)
|
|
104
|
+
logger.debug('Returned from CP4D token service operation')
|
|
100
105
|
return response
|
|
101
106
|
|
|
102
107
|
def set_headers(self, headers: Dict[str, str]) -> None:
|
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
from typing import Dict, Optional
|
|
18
18
|
|
|
19
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
19
20
|
from .jwt_token_manager import JWTTokenManager
|
|
20
21
|
|
|
22
|
+
logger = get_logger()
|
|
23
|
+
|
|
21
24
|
|
|
22
25
|
# pylint: disable=too-many-instance-attributes
|
|
23
26
|
class IAMRequestBasedTokenManager(JWTTokenManager):
|
|
@@ -118,14 +121,17 @@ class IAMRequestBasedTokenManager(JWTTokenManager):
|
|
|
118
121
|
if self.client_id and self.client_secret:
|
|
119
122
|
auth_tuple = (self.client_id, self.client_secret)
|
|
120
123
|
|
|
124
|
+
request_url = (self.url + self.OPERATION_PATH) if self.url else self.url
|
|
125
|
+
logger.debug('Invoking IAM get_token operation: %s', request_url)
|
|
121
126
|
response = self._request(
|
|
122
127
|
method='POST',
|
|
123
|
-
url=
|
|
128
|
+
url=request_url,
|
|
124
129
|
headers=request_headers,
|
|
125
130
|
data=data,
|
|
126
131
|
auth_tuple=auth_tuple,
|
|
127
132
|
proxies=self.proxies,
|
|
128
133
|
)
|
|
134
|
+
logger.debug('Returned from IAM get_token operation')
|
|
129
135
|
return response
|
|
130
136
|
|
|
131
137
|
def set_client_id_and_secret(self, client_id: str, client_secret: str) -> None:
|
|
@@ -17,9 +17,12 @@
|
|
|
17
17
|
import json
|
|
18
18
|
from typing import Dict, Optional
|
|
19
19
|
|
|
20
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
20
21
|
from ..private_helpers import _build_user_agent
|
|
21
22
|
from .jwt_token_manager import JWTTokenManager
|
|
22
23
|
|
|
24
|
+
logger = get_logger()
|
|
25
|
+
|
|
23
26
|
|
|
24
27
|
class MCSPTokenManager(JWTTokenManager):
|
|
25
28
|
"""The MCSPTokenManager accepts a user-supplied apikey and performs the necessary interactions with
|
|
@@ -68,13 +71,16 @@ class MCSPTokenManager(JWTTokenManager):
|
|
|
68
71
|
request_headers.update(self.headers)
|
|
69
72
|
request_headers.update(required_headers)
|
|
70
73
|
|
|
74
|
+
request_url = self.url + self.OPERATION_PATH
|
|
75
|
+
logger.debug('Invoking MCSP token service operation: %s', request_url)
|
|
71
76
|
response = self._request(
|
|
72
77
|
method='POST',
|
|
73
78
|
headers=request_headers,
|
|
74
|
-
url=
|
|
79
|
+
url=request_url,
|
|
75
80
|
data=json.dumps({"apikey": self.apikey}),
|
|
76
81
|
proxies=self.proxies,
|
|
77
82
|
)
|
|
83
|
+
logger.debug('Returned from MCSP token service operation')
|
|
78
84
|
return response
|
|
79
85
|
|
|
80
86
|
def set_headers(self, headers: Dict[str, str]) -> None:
|
|
@@ -21,8 +21,11 @@ from threading import Lock
|
|
|
21
21
|
|
|
22
22
|
import requests
|
|
23
23
|
|
|
24
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
24
25
|
from ..api_exception import ApiException
|
|
25
26
|
|
|
27
|
+
logger = get_logger()
|
|
28
|
+
|
|
26
29
|
|
|
27
30
|
# pylint: disable=too-many-instance-attributes
|
|
28
31
|
class TokenManager(ABC):
|
|
@@ -75,11 +78,15 @@ class TokenManager(ABC):
|
|
|
75
78
|
str: A valid access token
|
|
76
79
|
"""
|
|
77
80
|
if self._is_token_expired():
|
|
81
|
+
logger.debug('Performing synchronous token fetch')
|
|
78
82
|
self.paced_request_token()
|
|
79
83
|
|
|
80
84
|
if self._token_needs_refresh():
|
|
85
|
+
logger.debug('Performing background asynchronous token fetch')
|
|
81
86
|
token_response = self.request_token()
|
|
82
87
|
self._save_token_info(token_response)
|
|
88
|
+
else:
|
|
89
|
+
logger.debug('Using cached access token')
|
|
83
90
|
|
|
84
91
|
return self.access_token
|
|
85
92
|
|
|
@@ -15,14 +15,13 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
|
|
17
17
|
import json
|
|
18
|
-
import logging
|
|
19
18
|
from typing import Optional
|
|
20
19
|
|
|
20
|
+
from ibm_cloud_sdk_core.logger import get_logger
|
|
21
21
|
from ..private_helpers import _build_user_agent
|
|
22
22
|
from .jwt_token_manager import JWTTokenManager
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
logger = logging.getLogger(__name__)
|
|
24
|
+
logger = get_logger()
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
class VPCInstanceTokenManager(JWTTokenManager):
|
|
@@ -105,7 +104,7 @@ class VPCInstanceTokenManager(JWTTokenManager):
|
|
|
105
104
|
params={'version': self.METADATA_SERVICE_VERSION},
|
|
106
105
|
data=json.dumps(request_payload) if request_payload else None,
|
|
107
106
|
)
|
|
108
|
-
logger.debug('Returned from VPC \'create_iam_token\' operation.
|
|
107
|
+
logger.debug('Returned from VPC \'create_iam_token\' operation.')
|
|
109
108
|
|
|
110
109
|
return response
|
|
111
110
|
|
|
@@ -154,7 +153,7 @@ class VPCInstanceTokenManager(JWTTokenManager):
|
|
|
154
153
|
params={'version': self.METADATA_SERVICE_VERSION},
|
|
155
154
|
data=json.dumps(request_body),
|
|
156
155
|
)
|
|
157
|
-
logger.debug('Returned from VPC \'create_access_token\' operation.
|
|
156
|
+
logger.debug('Returned from VPC \'create_access_token\' operation.')
|
|
158
157
|
|
|
159
158
|
return response['access_token']
|
|
160
159
|
|
ibm_cloud_sdk_core/utils.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
# Copyright 2019,
|
|
3
|
+
# Copyright 2019, 2024 IBM All Rights Reserved.
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
@@ -25,6 +25,9 @@ from typing import List, Union
|
|
|
25
25
|
from urllib.parse import urlparse, parse_qs
|
|
26
26
|
|
|
27
27
|
import dateutil.parser as date_parser
|
|
28
|
+
from .logger import get_logger
|
|
29
|
+
|
|
30
|
+
logger = get_logger()
|
|
28
31
|
|
|
29
32
|
|
|
30
33
|
class GzipStream(io.RawIOBase):
|
|
@@ -343,6 +346,7 @@ def read_external_sources(service_name: str) -> dict:
|
|
|
343
346
|
Returns:
|
|
344
347
|
A dictionary containing relevant configuration for the service if found.
|
|
345
348
|
"""
|
|
349
|
+
logger.debug('Retrieving config properties for service \'%s\'', service_name)
|
|
346
350
|
config = {}
|
|
347
351
|
|
|
348
352
|
config = __read_from_credential_file(service_name)
|
|
@@ -352,7 +356,7 @@ def read_external_sources(service_name: str) -> dict:
|
|
|
352
356
|
|
|
353
357
|
if not config:
|
|
354
358
|
config = __read_from_vcap_services(service_name)
|
|
355
|
-
|
|
359
|
+
logger.debug('Retrieved %d properties', len(config))
|
|
356
360
|
return config
|
|
357
361
|
|
|
358
362
|
|
ibm_cloud_sdk_core/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '3.
|
|
1
|
+
__version__ = '3.21.0'
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ibm-cloud-sdk-core
|
|
3
|
+
Version: 3.21.0
|
|
4
|
+
Summary: Core library used by SDKs for IBM Cloud Services
|
|
5
|
+
Author-email: IBM <devxsdk@us.ibm.com>
|
|
6
|
+
Project-URL: Repository, https://github.com/IBM/python-sdk-core
|
|
7
|
+
Project-URL: Documentation, https://github.com/IBM/python-sdk-core/blob/main/README.md
|
|
8
|
+
Project-URL: Issues, https://github.com/IBM/python-sdk-core/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/IBM/python-sdk-core/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Contributing, https://github.com/IBM/python-sdk-core/blob/main/CONTRIBUTING.md
|
|
11
|
+
Project-URL: License, https://github.com/IBM/python-sdk-core/blob/main/LICENSE
|
|
12
|
+
Keywords: ibm,cloud,ibm cloud services
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
21
|
+
Classifier: Environment :: Console
|
|
22
|
+
Classifier: Intended Audience :: Developers
|
|
23
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
24
|
+
Classifier: Operating System :: OS Independent
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
28
|
+
Requires-Python: >=3.8
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Requires-Dist: requests <3.0.0,>=2.31.0
|
|
32
|
+
Requires-Dist: urllib3 <3.0.0,>=2.1.0
|
|
33
|
+
Requires-Dist: python-dateutil <3.0.0,>=2.8.2
|
|
34
|
+
Requires-Dist: PyJWT <3.0.0,>=2.8.0
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: coverage <8.0.0,>=7.3.2 ; extra == 'dev'
|
|
37
|
+
Requires-Dist: pylint <4.0.0,>=3.0.0 ; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest <8.0.0,>=7.4.2 ; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest-cov <5.0.0,>=4.1.0 ; extra == 'dev'
|
|
40
|
+
Requires-Dist: responses <1.0.0,>=0.23.3 ; extra == 'dev'
|
|
41
|
+
Requires-Dist: black <25.0.0,>=24.0.0 ; extra == 'dev'
|
|
42
|
+
Provides-Extra: publish
|
|
43
|
+
Requires-Dist: build ; extra == 'publish'
|
|
44
|
+
Requires-Dist: twine ; extra == 'publish'
|
|
45
|
+
|
|
46
|
+
[](https://app.travis-ci.com/IBM/python-sdk-core)
|
|
47
|
+
[](https://pypi.org/project/ibm-cloud-sdk-core/)
|
|
48
|
+
[](https://pypi.python.org/pypi/ibm-cloud-sdk-core)
|
|
49
|
+
[](https://cla-assistant.io/ibm/python-sdk-core)
|
|
50
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
51
|
+
|
|
52
|
+
# IBM Python SDK Core Version 3.21.0
|
|
53
|
+
This project contains core functionality required by Python code generated by the IBM Cloud OpenAPI SDK Generator
|
|
54
|
+
(openapi-sdkgen).
|
|
55
|
+
|
|
56
|
+
# Python Version
|
|
57
|
+
The current minimum Python version supported is 3.8.
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
To install, use `pip`:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
python -m pip install --upgrade ibm-cloud-sdk-core
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Authentication
|
|
68
|
+
The python-sdk-core project supports the following types of authentication:
|
|
69
|
+
- Basic Authentication
|
|
70
|
+
- Bearer Token Authentication
|
|
71
|
+
- Identity and Access Management (IAM) Authentication
|
|
72
|
+
- Container Authentication
|
|
73
|
+
- VPC Instance Authentication
|
|
74
|
+
- Cloud Pak for Data Authentication
|
|
75
|
+
- No Authentication (for testing)
|
|
76
|
+
|
|
77
|
+
For more information about the various authentication types and how to use them with your services, click [here](Authentication.md).
|
|
78
|
+
|
|
79
|
+
## Issues
|
|
80
|
+
|
|
81
|
+
If you encounter an issue with this project, you are welcome to submit a [bug report](https://github.com/IBM/python-sdk-core/issues).
|
|
82
|
+
Before opening a new issue, please search for similar issues. It's possible that someone has already reported it.
|
|
83
|
+
|
|
84
|
+
## Logging
|
|
85
|
+
|
|
86
|
+
This library uses Python's built-in `logging` module to perform logging of error,
|
|
87
|
+
warning, informational and debug messages.
|
|
88
|
+
The components within the SDK Core library use a single logger named `ibm-cloud-sdk-core`.
|
|
89
|
+
|
|
90
|
+
For complete information on the logging facility, please see: [Logging facility for Python](https://docs.python.org/3/library/logging.html).
|
|
91
|
+
|
|
92
|
+
### Enable logging
|
|
93
|
+
|
|
94
|
+
There are various ways to configure and enable the logging facility.
|
|
95
|
+
|
|
96
|
+
The code example below demonstrates a simple way to enable debug logging by invoking
|
|
97
|
+
the `logging.basicConfig()` function.
|
|
98
|
+
|
|
99
|
+
Note that, as a convenience, if you set the logging level to `DEBUG`, then HTTP request/response message logging
|
|
100
|
+
is also enabled.
|
|
101
|
+
|
|
102
|
+
The following code example shows how debug logging can be enabled:
|
|
103
|
+
```python
|
|
104
|
+
import logging
|
|
105
|
+
|
|
106
|
+
# Create a basic logging configuration that:
|
|
107
|
+
# 1. Defines a handler to display messages on the console.
|
|
108
|
+
# 2. Sets the root logger's logging level to DEBUG.
|
|
109
|
+
# 3. Sets the 'format' string used to display messages.
|
|
110
|
+
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(name)s:%(levelname)s] %(message)s', force=True)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
When running your application, you should see output like this if debug logging is enabled:
|
|
114
|
+
```
|
|
115
|
+
2024-09-16 15:44:45,174 [ibm-cloud-sdk-core:DEBUG] Get authenticator from environment, key=global_search
|
|
116
|
+
2024-09-16 15:44:45,175 [ibm-cloud-sdk-core:DEBUG] Set service URL: https://api.global-search-tagging.cloud.ibm.com
|
|
117
|
+
2024-09-16 15:44:45,175 [ibm-cloud-sdk-core:DEBUG] Set User-Agent: ibm-python-sdk-core-3.21.0 os.name=Linux os.version=6.10.9-100.fc39.x86_64 python.version=3.12.5
|
|
118
|
+
2024-09-16 15:44:45,181 [ibm-cloud-sdk-core:DEBUG] Configuring BaseService instance with service name: global_search
|
|
119
|
+
2024-09-16 15:44:45,181 [ibm-cloud-sdk-core:DEBUG] Performing synchronous token fetch
|
|
120
|
+
2024-09-16 15:44:45,182 [ibm-cloud-sdk-core:DEBUG] Invoking IAM get_token operation: https://iam.cloud.ibm.com/identity/token
|
|
121
|
+
2024-09-16 15:44:45,182 [urllib3.connectionpool:DEBUG] Starting new HTTPS connection (1): iam.cloud.ibm.com:443
|
|
122
|
+
send: b'POST /identity/token HTTP/1.1\r\nHost: iam.cloud.ibm.com\r\nUser-Agent: ibm-python-sdk-core/iam-authenticator-3.21.0 os.name=Linux os.version=6.10.9-100.fc39.x86_64 python.version=3.12.5\r\nAccept-Encoding: gzip, deflate\r\nAccept: application/json\r\nConnection: keep-alive\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 135\r\n\r\n'
|
|
123
|
+
send: b'grant_type=urn%3Aibm%3Aparams%3Aoauth%3Agrant-type%3Aapikey&apikey=[redacted]&response_type=cloud_iam'
|
|
124
|
+
reply: 'HTTP/1.1 200 OK\r\n'
|
|
125
|
+
header: Content-Type: application/json
|
|
126
|
+
header: Content-Language: en-US
|
|
127
|
+
header: Content-Encoding: gzip
|
|
128
|
+
header: Date: Mon, 16 Sep 2024 20:44:45 GMT
|
|
129
|
+
header: Content-Length: 983
|
|
130
|
+
header: Connection: keep-alive
|
|
131
|
+
2024-09-16 15:44:45,670 [urllib3.connectionpool:DEBUG] https://iam.cloud.ibm.com:443 "POST /identity/token HTTP/11" 200 983
|
|
132
|
+
2024-09-16 15:44:45,672 [ibm-cloud-sdk-core:DEBUG] Returned from IAM get_token operation
|
|
133
|
+
2024-09-16 15:44:45,673 [ibm-cloud-sdk-core:DEBUG] Authenticated outbound request (type=iam)
|
|
134
|
+
2024-09-16 15:44:45,673 [ibm-cloud-sdk-core:DEBUG] Prepared request [POST https://api.global-search-tagging.cloud.ibm.com/v3/resources/search]
|
|
135
|
+
2024-09-16 15:44:45,673 [ibm-cloud-sdk-core:DEBUG] Sending HTTP request message
|
|
136
|
+
2024-09-16 15:44:45,674 [urllib3.connectionpool:DEBUG] Starting new HTTPS connection (1): api.global-search-tagging.cloud.ibm.com:443
|
|
137
|
+
send: b'POST /v3/resources/search?limit=1 HTTP/1.1\r\nHost: api.global-search-tagging.cloud.ibm.com\r\nUser-Agent: platform-services-python-sdk/0.57.0 (lang=python; os.name=Linux; os.version=6.10.9-100.fc39.x86_64; python.version=3.12.5)\r\nAccept-Encoding: gzip, deflate\r\nAccept: application/json\r\nConnection: keep-alive\r\ncontent-type: application/json\r\nAuthorization: [redacted]\r\nContent-Length: 39\r\n\r\n'
|
|
138
|
+
send: b'{"query": "GST-sdk-*", "fields": ["*"]}'
|
|
139
|
+
reply: 'HTTP/1.1 200 OK\r\n'
|
|
140
|
+
header: Content-Type: application/json
|
|
141
|
+
header: Content-Length: 22
|
|
142
|
+
header: Date: Mon, 16 Sep 2024 20:44:46 GMT
|
|
143
|
+
header: Connection: keep-alive
|
|
144
|
+
2024-09-16 15:44:46,079 [urllib3.connectionpool:DEBUG] https://api.global-search-tagging.cloud.ibm.com:443 "POST /v3/resources/search?limit=1 HTTP/11" 200 22
|
|
145
|
+
2024-09-16 15:44:46,080 [ibm-cloud-sdk-core:DEBUG] Received HTTP response message, status code 200
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Open source @ IBM
|
|
149
|
+
|
|
150
|
+
Find more open source projects on the [IBM Github Page](http://github.com/IBM)
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
This library is licensed under Apache 2.0. Full license text is
|
|
155
|
+
available in [LICENSE](LICENSE).
|
|
156
|
+
|
|
157
|
+
## Contributing
|
|
158
|
+
|
|
159
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
ibm_cloud_sdk_core/__init__.py,sha256=Ef7P3r-KmVwoYQV9bP0zvaDSlgJtjaTcDYQXmVvm0Zs,2853
|
|
2
2
|
ibm_cloud_sdk_core/api_exception.py,sha256=YNd7Dg_yiwcHk-AA-suNlivgyrA9A32Do1qtYeKzuWc,3654
|
|
3
|
-
ibm_cloud_sdk_core/base_service.py,sha256=
|
|
3
|
+
ibm_cloud_sdk_core/base_service.py,sha256=7gpq0w4B8t8NYYJ07WYwZkhwy97oO89bbDyYOH2NMqI,22094
|
|
4
4
|
ibm_cloud_sdk_core/detailed_response.py,sha256=agLMQ-Mh3bU_lLnSnSO1SwjuNBPQj8plO8ew2xXWL6I,3101
|
|
5
|
-
ibm_cloud_sdk_core/get_authenticator.py,sha256=
|
|
5
|
+
ibm_cloud_sdk_core/get_authenticator.py,sha256=GNUPJBt9YL4n3m2OluIwdekFUOLpHO3YAVszUHbLc-c,4842
|
|
6
6
|
ibm_cloud_sdk_core/http_adapter.py,sha256=nRUvt7hbSC8Vyhqe_oA5k_NKoRMM-S4VCSAZVQ-AHQU,1075
|
|
7
|
+
ibm_cloud_sdk_core/logger.py,sha256=sdDNAA9LlpynadFxTRsCWfqSNBrN6uKMxVsFuo2PnIo,2708
|
|
7
8
|
ibm_cloud_sdk_core/private_helpers.py,sha256=5ei9gNwuN-inNJ2WqMXcXEPfLM1NALOLi4ucLMcYohY,1181
|
|
8
|
-
ibm_cloud_sdk_core/utils.py,sha256=
|
|
9
|
-
ibm_cloud_sdk_core/version.py,sha256=
|
|
9
|
+
ibm_cloud_sdk_core/utils.py,sha256=13sHWir3xvp5eJ2JE7FIdAXgQHOKCLlKGk_R-R5W2Ms,15828
|
|
10
|
+
ibm_cloud_sdk_core/version.py,sha256=DtTATt0aAO_SxEzHuw5gF87WyPXFdJ1GM3czmj0ovp4,23
|
|
10
11
|
ibm_cloud_sdk_core/authenticators/__init__.py,sha256=Ze_ArDqMWk1Xr311dXpHTtJUJYN2u8jCphoGTLBow9M,2133
|
|
11
12
|
ibm_cloud_sdk_core/authenticators/authenticator.py,sha256=dyTQDEAhlcN4y-wybTgMycSO5dC2pLntx3KCJTJGHdQ,1979
|
|
12
|
-
ibm_cloud_sdk_core/authenticators/basic_authenticator.py,sha256
|
|
13
|
-
ibm_cloud_sdk_core/authenticators/bearer_token_authenticator.py,sha256=
|
|
13
|
+
ibm_cloud_sdk_core/authenticators/basic_authenticator.py,sha256=-VETJqCwAj77_RNhokAp8rLqN0lkGj3TPF6xU1_lpY8,3366
|
|
14
|
+
ibm_cloud_sdk_core/authenticators/bearer_token_authenticator.py,sha256=McSziK-DUj64TpFyzNps6XR2IjRvyzOR_8C7V1pIfwE,2861
|
|
14
15
|
ibm_cloud_sdk_core/authenticators/container_authenticator.py,sha256=GKYHTflLiKhm9xF5KZAcjYXPN3yE2PztdEr2bOZUwKE,7042
|
|
15
|
-
ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py,sha256=
|
|
16
|
+
ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py,sha256=LNW9NYY7upiwxlKm633XokmXacEfxPLBPev1yirpx4w,6922
|
|
16
17
|
ibm_cloud_sdk_core/authenticators/iam_authenticator.py,sha256=ozrFBdVah1y8gcLL68fmReXCFEAltOGLCIuA6PuWLSY,4597
|
|
17
|
-
ibm_cloud_sdk_core/authenticators/iam_request_based_authenticator.py,sha256=
|
|
18
|
-
ibm_cloud_sdk_core/authenticators/mcsp_authenticator.py,sha256=
|
|
18
|
+
ibm_cloud_sdk_core/authenticators/iam_request_based_authenticator.py,sha256=0k-rtfaYV3KXxNCEOq8njNDAC4KmUJSbVxOPjbhIxWc,4686
|
|
19
|
+
ibm_cloud_sdk_core/authenticators/mcsp_authenticator.py,sha256=z3fFZf-iW0hsZ9qfJ1y-jKQ3DtNPGf9M9QNgu0gfMoA,5350
|
|
19
20
|
ibm_cloud_sdk_core/authenticators/no_auth_authenticator.py,sha256=dzuU6IJC19SocVHy7Fyln6xrfGvlqnXGeUNR9llspYo,979
|
|
20
|
-
ibm_cloud_sdk_core/authenticators/vpc_instance_authenticator.py,sha256=
|
|
21
|
+
ibm_cloud_sdk_core/authenticators/vpc_instance_authenticator.py,sha256=48Cq9YRRRXmPjhHvnW8-uNgqP8NfNTAG_ajxwg1Mdw0,5414
|
|
21
22
|
ibm_cloud_sdk_core/token_managers/__init__.py,sha256=NEiims6qB8doxq6wtlTBYCIdwf2wRiMTrV0bgfv7WAg,606
|
|
22
|
-
ibm_cloud_sdk_core/token_managers/container_token_manager.py,sha256=
|
|
23
|
-
ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py,sha256=
|
|
24
|
-
ibm_cloud_sdk_core/token_managers/iam_request_based_token_manager.py,sha256=
|
|
23
|
+
ibm_cloud_sdk_core/token_managers/container_token_manager.py,sha256=79ECLjuwh94JmexB9YSQju0rowPptdZrEGRQyMrMeeo,9523
|
|
24
|
+
ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py,sha256=ETYOpcSPXZtffFgdx4Dq8WYeIXoc0d1iACFabt53Cwk,5163
|
|
25
|
+
ibm_cloud_sdk_core/token_managers/iam_request_based_token_manager.py,sha256=7BxUEm3HCw34uUUeDRY00i4BRxNwwV3YL6w9P7nulhc,8556
|
|
25
26
|
ibm_cloud_sdk_core/token_managers/iam_token_manager.py,sha256=bG94h0Io6XaneLUcSuJzLlKSpFLdKH49TieRNAY7fvA,4358
|
|
26
27
|
ibm_cloud_sdk_core/token_managers/jwt_token_manager.py,sha256=FDBdvirmUcJu5vIb5pdhqoQeFS6j0GBSDsF0HtLjg48,3785
|
|
27
|
-
ibm_cloud_sdk_core/token_managers/mcsp_token_manager.py,sha256=
|
|
28
|
-
ibm_cloud_sdk_core/token_managers/token_manager.py,sha256=
|
|
29
|
-
ibm_cloud_sdk_core/token_managers/vpc_instance_token_manager.py,sha256=
|
|
30
|
-
ibm_cloud_sdk_core-3.
|
|
31
|
-
ibm_cloud_sdk_core-3.
|
|
32
|
-
ibm_cloud_sdk_core-3.
|
|
33
|
-
ibm_cloud_sdk_core-3.
|
|
34
|
-
ibm_cloud_sdk_core-3.
|
|
28
|
+
ibm_cloud_sdk_core/token_managers/mcsp_token_manager.py,sha256=jaVwmqPnWF0ZG3lGOL33Q8wXj2tOQX52VYvle5sE_zM,4244
|
|
29
|
+
ibm_cloud_sdk_core/token_managers/token_manager.py,sha256=7vSaSctmy46o5OVnmvVafBAGKzoNjA7kJEzd-rrcLWM,7993
|
|
30
|
+
ibm_cloud_sdk_core/token_managers/vpc_instance_token_manager.py,sha256=0oYXV-Y2o5L3_70r53CxtJLS6Y2pIkzbi1CW1z-QR4Y,7014
|
|
31
|
+
ibm_cloud_sdk_core-3.21.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
32
|
+
ibm_cloud_sdk_core-3.21.0.dist-info/METADATA,sha256=_f1vpF8g_4SPhouDwJbxPW3ErjBsIz13N24jX6Sa3l4,8535
|
|
33
|
+
ibm_cloud_sdk_core-3.21.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
34
|
+
ibm_cloud_sdk_core-3.21.0.dist-info/top_level.txt,sha256=otLtvxe-8ugPRmPqeSnbaOjnAl0qjDRZ1HSkC3aeLpI,19
|
|
35
|
+
ibm_cloud_sdk_core-3.21.0.dist-info/RECORD,,
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: ibm-cloud-sdk-core
|
|
3
|
-
Version: 3.20.6
|
|
4
|
-
Summary: Core library used by SDKs for IBM Cloud Services
|
|
5
|
-
Author-email: IBM <devxsdk@us.ibm.com>
|
|
6
|
-
Project-URL: Repository, https://github.com/IBM/python-sdk-core
|
|
7
|
-
Project-URL: Documentation, https://github.com/IBM/python-sdk-core/blob/main/README.md
|
|
8
|
-
Project-URL: Issues, https://github.com/IBM/python-sdk-core/issues
|
|
9
|
-
Project-URL: Changelog, https://github.com/IBM/python-sdk-core/blob/main/CHANGELOG.md
|
|
10
|
-
Project-URL: Contributing, https://github.com/IBM/python-sdk-core/blob/main/CONTRIBUTING.md
|
|
11
|
-
Project-URL: License, https://github.com/IBM/python-sdk-core/blob/main/LICENSE
|
|
12
|
-
Keywords: ibm,cloud,ibm cloud services
|
|
13
|
-
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
21
|
-
Classifier: Environment :: Console
|
|
22
|
-
Classifier: Intended Audience :: Developers
|
|
23
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
24
|
-
Classifier: Operating System :: OS Independent
|
|
25
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
26
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
-
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
28
|
-
Requires-Python: >=3.8
|
|
29
|
-
Description-Content-Type: text/markdown
|
|
30
|
-
License-File: LICENSE
|
|
31
|
-
Requires-Dist: requests <3.0.0,>=2.31.0
|
|
32
|
-
Requires-Dist: urllib3 <3.0.0,>=2.1.0
|
|
33
|
-
Requires-Dist: python-dateutil <3.0.0,>=2.8.2
|
|
34
|
-
Requires-Dist: PyJWT <3.0.0,>=2.8.0
|
|
35
|
-
Provides-Extra: dev
|
|
36
|
-
Requires-Dist: coverage <8.0.0,>=7.3.2 ; extra == 'dev'
|
|
37
|
-
Requires-Dist: pylint <4.0.0,>=3.0.0 ; extra == 'dev'
|
|
38
|
-
Requires-Dist: pytest <8.0.0,>=7.4.2 ; extra == 'dev'
|
|
39
|
-
Requires-Dist: pytest-cov <5.0.0,>=4.1.0 ; extra == 'dev'
|
|
40
|
-
Requires-Dist: responses <1.0.0,>=0.23.3 ; extra == 'dev'
|
|
41
|
-
Requires-Dist: black <25.0.0,>=24.0.0 ; extra == 'dev'
|
|
42
|
-
Provides-Extra: publish
|
|
43
|
-
Requires-Dist: build ; extra == 'publish'
|
|
44
|
-
Requires-Dist: twine ; extra == 'publish'
|
|
45
|
-
|
|
46
|
-
[](https://app.travis-ci.com/IBM/python-sdk-core)
|
|
47
|
-
[](https://pypi.org/project/ibm-cloud-sdk-core/)
|
|
48
|
-
[](https://pypi.python.org/pypi/ibm-cloud-sdk-core)
|
|
49
|
-
[](https://cla-assistant.io/ibm/python-sdk-core)
|
|
50
|
-
[](https://github.com/semantic-release/semantic-release)
|
|
51
|
-
|
|
52
|
-
# IBM Python SDK Core Version 3.20.6
|
|
53
|
-
This project contains core functionality required by Python code generated by the IBM Cloud OpenAPI SDK Generator
|
|
54
|
-
(openapi-sdkgen).
|
|
55
|
-
|
|
56
|
-
# Python Version
|
|
57
|
-
The current minimum Python version supported is 3.8.
|
|
58
|
-
|
|
59
|
-
## Installation
|
|
60
|
-
|
|
61
|
-
To install, use `pip`:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
python -m pip install --upgrade ibm-cloud-sdk-core
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Authentication
|
|
68
|
-
The python-sdk-core project supports the following types of authentication:
|
|
69
|
-
- Basic Authentication
|
|
70
|
-
- Bearer Token Authentication
|
|
71
|
-
- Identity and Access Management (IAM) Authentication
|
|
72
|
-
- Container Authentication
|
|
73
|
-
- VPC Instance Authentication
|
|
74
|
-
- Cloud Pak for Data Authentication
|
|
75
|
-
- No Authentication (for testing)
|
|
76
|
-
|
|
77
|
-
For more information about the various authentication types and how to use them with your services, click [here](Authentication.md).
|
|
78
|
-
|
|
79
|
-
## Issues
|
|
80
|
-
|
|
81
|
-
If you encounter an issue with this project, you are welcome to submit a [bug report](https://github.com/IBM/python-sdk-core/issues).
|
|
82
|
-
Before opening a new issue, please search for similar issues. It's possible that someone has already reported it.
|
|
83
|
-
|
|
84
|
-
## Logging
|
|
85
|
-
|
|
86
|
-
### Enable logging
|
|
87
|
-
|
|
88
|
-
```python
|
|
89
|
-
import logging
|
|
90
|
-
logging.basicConfig(level=logging.DEBUG)
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
This would show output of the form:
|
|
94
|
-
```
|
|
95
|
-
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): iam.cloud.ibm.com:443
|
|
96
|
-
DEBUG:urllib3.connectionpool:https://iam.cloud.ibm.com:443 "POST /identity/token HTTP/1.1" 200 1809
|
|
97
|
-
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): gateway.watsonplatform.net:443
|
|
98
|
-
DEBUG:urllib3.connectionpool:https://gateway.watsonplatform.net:443 "POST /assistant/api/v1/workspaces?version=2018-07-10 HTTP/1.1" 201 None
|
|
99
|
-
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): gateway.watsonplatform.net:443
|
|
100
|
-
DEBUG:urllib3.connectionpool:https://gateway.watsonplatform.net:443 "GET /assistant/api/v1/workspaces/883a2a44-eb5f-4b1a-96b0-32a90b475ea8?version=2018-07-10&export=true HTTP/1.1" 200 None
|
|
101
|
-
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): gateway.watsonplatform.net:443
|
|
102
|
-
DEBUG:urllib3.connectionpool:https://gateway.watsonplatform.net:443 "DELETE /assistant/api/v1/workspaces/883a2a44-eb5f-4b1a-96b0-32a90b475ea8?version=2018-07-10 HTTP/1.1" 200 28
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Low level request and response dump
|
|
106
|
-
To get low level information of the requests/ responses:
|
|
107
|
-
|
|
108
|
-
```python
|
|
109
|
-
from http.client import HTTPConnection
|
|
110
|
-
HTTPConnection.debuglevel = 1
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Open source @ IBM
|
|
114
|
-
|
|
115
|
-
Find more open source projects on the [IBM Github Page](http://github.com/IBM)
|
|
116
|
-
|
|
117
|
-
## License
|
|
118
|
-
|
|
119
|
-
This library is licensed under Apache 2.0. Full license text is
|
|
120
|
-
available in [LICENSE](LICENSE).
|
|
121
|
-
|
|
122
|
-
## Contributing
|
|
123
|
-
|
|
124
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
File without changes
|
|
File without changes
|