ibm-cloud-sdk-core 3.20.6__py3-none-any.whl → 3.22.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.
Files changed (30) hide show
  1. ibm_cloud_sdk_core/__init__.py +2 -0
  2. ibm_cloud_sdk_core/authenticators/__init__.py +1 -0
  3. ibm_cloud_sdk_core/authenticators/authenticator.py +1 -0
  4. ibm_cloud_sdk_core/authenticators/basic_authenticator.py +7 -1
  5. ibm_cloud_sdk_core/authenticators/bearer_token_authenticator.py +6 -1
  6. ibm_cloud_sdk_core/authenticators/container_authenticator.py +1 -0
  7. ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py +5 -2
  8. ibm_cloud_sdk_core/authenticators/iam_assume_authenticator.py +146 -0
  9. ibm_cloud_sdk_core/authenticators/iam_request_based_authenticator.py +5 -1
  10. ibm_cloud_sdk_core/authenticators/mcsp_authenticator.py +5 -1
  11. ibm_cloud_sdk_core/authenticators/vpc_instance_authenticator.py +5 -1
  12. ibm_cloud_sdk_core/base_service.py +28 -10
  13. ibm_cloud_sdk_core/get_authenticator.py +22 -1
  14. ibm_cloud_sdk_core/logger.py +85 -0
  15. ibm_cloud_sdk_core/token_managers/container_token_manager.py +3 -3
  16. ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py +5 -0
  17. ibm_cloud_sdk_core/token_managers/iam_assume_token_manager.py +150 -0
  18. ibm_cloud_sdk_core/token_managers/iam_request_based_token_manager.py +8 -1
  19. ibm_cloud_sdk_core/token_managers/mcsp_token_manager.py +7 -1
  20. ibm_cloud_sdk_core/token_managers/token_manager.py +7 -0
  21. ibm_cloud_sdk_core/token_managers/vpc_instance_token_manager.py +4 -5
  22. ibm_cloud_sdk_core/utils.py +6 -2
  23. ibm_cloud_sdk_core/version.py +1 -1
  24. ibm_cloud_sdk_core-3.22.0.dist-info/METADATA +160 -0
  25. ibm_cloud_sdk_core-3.22.0.dist-info/RECORD +37 -0
  26. {ibm_cloud_sdk_core-3.20.6.dist-info → ibm_cloud_sdk_core-3.22.0.dist-info}/WHEEL +1 -1
  27. ibm_cloud_sdk_core-3.20.6.dist-info/METADATA +0 -124
  28. ibm_cloud_sdk_core-3.20.6.dist-info/RECORD +0 -34
  29. {ibm_cloud_sdk_core-3.20.6.dist-info → ibm_cloud_sdk_core-3.22.0.dist-info}/LICENSE +0 -0
  30. {ibm_cloud_sdk_core-3.20.6.dist-info → ibm_cloud_sdk_core-3.22.0.dist-info}/top_level.txt +0 -0
@@ -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):
@@ -86,6 +85,7 @@ class ContainerTokenManager(IAMRequestBasedTokenManager):
86
85
 
87
86
  def __init__(
88
87
  self,
88
+ *,
89
89
  cr_token_filename: Optional[str] = None,
90
90
  iam_profile_name: Optional[str] = None,
91
91
  iam_profile_id: Optional[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 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:
@@ -0,0 +1,150 @@
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
+ from typing import Any, Dict, Optional
18
+
19
+ from ibm_cloud_sdk_core.token_managers.iam_token_manager import IAMTokenManager
20
+
21
+ from .iam_request_based_token_manager import IAMRequestBasedTokenManager
22
+ from ..private_helpers import _build_user_agent
23
+
24
+
25
+ # pylint: disable=too-many-instance-attributes
26
+ class IAMAssumeTokenManager(IAMRequestBasedTokenManager):
27
+ """The IAMAssumeTokenManager takes an api key and information about a trusted profile then performs the necessary
28
+ interactions with the IAM token service to obtain and store a suitable bearer token. This token "assumes" the
29
+ identity of the provided trusted profile.
30
+
31
+ Attributes:
32
+ iam_profile_id (str): the ID of the trusted profile
33
+ iam_profile_crn (str): the CRN of the trusted profile
34
+ iam_profile_name (str): the name of the trusted profile (must be used together with `iam_account_id`)
35
+ iam_account_id (str): the ID of the trusted profile (must be used together with `iam_profile_name`)
36
+ iam_delegate (IAMTokenManager): an IAMTokenManager instance used to obtain the user's IAM access token
37
+ from the `apikey`.
38
+ url (str): The IAM endpoint to token requests.
39
+ headers (dict): Default headers to be sent with every IAM token request.
40
+ proxies (dict): Proxies to use for communicating with IAM.
41
+ proxies.http (str): The proxy endpoint to use for HTTP requests.
42
+ proxies.https (str): The proxy endpoint to use for HTTPS requests.
43
+ http_config (dict): A dictionary containing values that control the timeout, proxies, and etc of HTTP requests.
44
+
45
+ Args:
46
+ apikey: A generated APIKey from IBM Cloud.
47
+
48
+ Keyword Args:
49
+ iam_profile_id: the ID of the trusted profile
50
+ iam_profile_crn: the CRN of the trusted profile
51
+ iam_profile_name: the name of the trusted profile (must be used together with `iam_account_id`)
52
+ iam_account_id: the ID of the trusted profile (must be used together with `iam_profile_name`)
53
+ url: The IAM endpoint to token requests. Defaults to None.
54
+ client_id: The client_id and client_secret fields are used to form
55
+ a "basic auth" Authorization header for interactions with the IAM token server.
56
+ Defaults to None.
57
+ client_secret: The client_id and client_secret fields are used to form
58
+ a "basic auth" Authorization header for interactions with the IAM token server.
59
+ Defaults to None.
60
+ disable_ssl_verification: A flag that indicates whether verification of
61
+ the server's SSL certificate should be disabled or not. Defaults to False.
62
+ headers: Default headers to be sent with every IAM token request. Defaults to None.
63
+ proxies: Proxies to use for communicating with IAM. Defaults to None.
64
+ proxies.http: The proxy endpoint to use for HTTP requests.
65
+ proxies.https: The proxy endpoint to use for HTTPS requests.
66
+ scope: The "scope" to use when fetching the bearer token from the IAM token server.
67
+ This can be used to obtain an access token with a specific scope.
68
+ """
69
+
70
+ def __init__(
71
+ self,
72
+ apikey: str,
73
+ *,
74
+ iam_profile_id: Optional[str] = None,
75
+ iam_profile_crn: Optional[str] = None,
76
+ iam_profile_name: Optional[str] = None,
77
+ iam_account_id: Optional[str] = None,
78
+ url: Optional[str] = None,
79
+ client_id: Optional[str] = None,
80
+ client_secret: Optional[str] = None,
81
+ disable_ssl_verification: bool = False,
82
+ headers: Optional[Dict[str, str]] = None,
83
+ proxies: Optional[Dict[str, str]] = None,
84
+ scope: Optional[str] = None,
85
+ ) -> None:
86
+ super().__init__(
87
+ url=url,
88
+ disable_ssl_verification=disable_ssl_verification,
89
+ headers=headers,
90
+ proxies=proxies,
91
+ )
92
+
93
+ self.iam_profile_id = iam_profile_id
94
+ self.iam_profile_crn = iam_profile_crn
95
+ self.iam_profile_name = iam_profile_name
96
+ self.iam_account_id = iam_account_id
97
+
98
+ # Create an IAMTokenManager instance that will be used to obtain an IAM access token
99
+ # for the IAM "assume" token exchange. We use the same configuration that's provided
100
+ # for this class, as they have a lot in common.
101
+ self.iam_delegate = IAMTokenManager(
102
+ apikey=apikey,
103
+ url=url,
104
+ client_id=client_id,
105
+ client_secret=client_secret,
106
+ disable_ssl_verification=disable_ssl_verification,
107
+ headers=headers,
108
+ proxies=proxies,
109
+ scope=scope,
110
+ )
111
+
112
+ self.request_payload['grant_type'] = 'urn:ibm:params:oauth:grant-type:assume'
113
+ self._set_user_agent(_build_user_agent('iam-assume-authenticator'))
114
+
115
+ # Disable all setter methods, inherited from the parent class.
116
+ def __getattribute__(self, name: str) -> Any:
117
+ if name.startswith("set_"):
118
+ raise AttributeError(f"'{self.__class__.__name__}' has no attribute '{name}'")
119
+
120
+ return super().__getattribute__(name)
121
+
122
+ def request_token(self) -> Dict:
123
+ """Retrieves a standard IAM access token by using the IAM token manager
124
+ then obtains another access token for the assumed identity.
125
+
126
+ Returns:
127
+ A dictionary that contains the access token of the assumed IAM identity.
128
+ """
129
+ # Fetch the user's original IAM access token before trying to assume.
130
+ self.request_payload['access_token'] = self.iam_delegate.get_token()
131
+
132
+ if self.iam_profile_crn:
133
+ self.request_payload['profile_crn'] = self.iam_profile_crn
134
+ if self.iam_profile_id:
135
+ self.request_payload['profile_id'] = self.iam_profile_id
136
+ else:
137
+ self.request_payload['profile_name'] = self.iam_profile_name
138
+ self.request_payload['account'] = self.iam_account_id
139
+
140
+ # Make sure that the unsupported attributes will never be included in the requests.
141
+ self.client_id = None
142
+ self.client_secret = None
143
+ self.scope = None
144
+
145
+ return super().request_token()
146
+
147
+ def _save_token_info(self, token_response: Dict) -> None:
148
+ super()._save_token_info(token_response)
149
+ # Set refresh token to None unconditionally.
150
+ self.refresh_token = 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):
@@ -67,6 +70,7 @@ class IAMRequestBasedTokenManager(JWTTokenManager):
67
70
 
68
71
  def __init__(
69
72
  self,
73
+ *,
70
74
  url: Optional[str] = None,
71
75
  client_id: Optional[str] = None,
72
76
  client_secret: Optional[str] = None,
@@ -118,14 +122,17 @@ class IAMRequestBasedTokenManager(JWTTokenManager):
118
122
  if self.client_id and self.client_secret:
119
123
  auth_tuple = (self.client_id, self.client_secret)
120
124
 
125
+ request_url = (self.url + self.OPERATION_PATH) if self.url else self.url
126
+ logger.debug('Invoking IAM get_token operation: %s', request_url)
121
127
  response = self._request(
122
128
  method='POST',
123
- url=(self.url + self.OPERATION_PATH) if self.url else self.url,
129
+ url=request_url,
124
130
  headers=request_headers,
125
131
  data=data,
126
132
  auth_tuple=auth_tuple,
127
133
  proxies=self.proxies,
128
134
  )
135
+ logger.debug('Returned from IAM get_token operation')
129
136
  return response
130
137
 
131
138
  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=self.url + self.OPERATION_PATH,
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
 
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- # Copyright 2019, 2021 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.
@@ -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
 
@@ -1 +1 @@
1
- __version__ = '3.20.6'
1
+ __version__ = '3.22.0'
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.1
2
+ Name: ibm-cloud-sdk-core
3
+ Version: 3.22.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
+ [![Build Status](https://app.travis-ci.com/IBM/python-sdk-core.svg?branch=main)](https://app.travis-ci.com/IBM/python-sdk-core)
47
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ibm-cloud-sdk-core)](https://pypi.org/project/ibm-cloud-sdk-core/)
48
+ [![Latest Stable Version](https://img.shields.io/pypi/v/ibm-cloud-sdk-core.svg)](https://pypi.python.org/pypi/ibm-cloud-sdk-core)
49
+ [![CLA assistant](https://cla-assistant.io/readme/badge/ibm/python-sdk-core)](https://cla-assistant.io/ibm/python-sdk-core)
50
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
51
+
52
+ # IBM Python SDK Core Version 3.22.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 (grant type: apikey)
72
+ - Identity and Access Management (IAM) Authentication (grant type: assume)
73
+ - Container Authentication
74
+ - VPC Instance Authentication
75
+ - Cloud Pak for Data Authentication
76
+ - No Authentication (for testing)
77
+
78
+ For more information about the various authentication types and how to use them with your services, click [here](Authentication.md).
79
+
80
+ ## Issues
81
+
82
+ If you encounter an issue with this project, you are welcome to submit a [bug report](https://github.com/IBM/python-sdk-core/issues).
83
+ Before opening a new issue, please search for similar issues. It's possible that someone has already reported it.
84
+
85
+ ## Logging
86
+
87
+ This library uses Python's built-in `logging` module to perform logging of error,
88
+ warning, informational and debug messages.
89
+ The components within the SDK Core library use a single logger named `ibm-cloud-sdk-core`.
90
+
91
+ For complete information on the logging facility, please see: [Logging facility for Python](https://docs.python.org/3/library/logging.html).
92
+
93
+ ### Enable logging
94
+
95
+ There are various ways to configure and enable the logging facility.
96
+
97
+ The code example below demonstrates a simple way to enable debug logging by invoking
98
+ the `logging.basicConfig()` function.
99
+
100
+ Note that, as a convenience, if you set the logging level to `DEBUG`, then HTTP request/response message logging
101
+ is also enabled.
102
+
103
+ The following code example shows how debug logging can be enabled:
104
+ ```python
105
+ import logging
106
+
107
+ # Create a basic logging configuration that:
108
+ # 1. Defines a handler to display messages on the console.
109
+ # 2. Sets the root logger's logging level to DEBUG.
110
+ # 3. Sets the 'format' string used to display messages.
111
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(name)s:%(levelname)s] %(message)s', force=True)
112
+ ```
113
+
114
+ When running your application, you should see output like this if debug logging is enabled:
115
+ ```
116
+ 2024-09-16 15:44:45,174 [ibm-cloud-sdk-core:DEBUG] Get authenticator from environment, key=global_search
117
+ 2024-09-16 15:44:45,175 [ibm-cloud-sdk-core:DEBUG] Set service URL: https://api.global-search-tagging.cloud.ibm.com
118
+ 2024-09-16 15:44:45,175 [ibm-cloud-sdk-core:DEBUG] Set User-Agent: ibm-python-sdk-core-3.22.0 os.name=Linux os.version=6.10.9-100.fc39.x86_64 python.version=3.12.5
119
+ 2024-09-16 15:44:45,181 [ibm-cloud-sdk-core:DEBUG] Configuring BaseService instance with service name: global_search
120
+ 2024-09-16 15:44:45,181 [ibm-cloud-sdk-core:DEBUG] Performing synchronous token fetch
121
+ 2024-09-16 15:44:45,182 [ibm-cloud-sdk-core:DEBUG] Invoking IAM get_token operation: https://iam.cloud.ibm.com/identity/token
122
+ 2024-09-16 15:44:45,182 [urllib3.connectionpool:DEBUG] Starting new HTTPS connection (1): iam.cloud.ibm.com:443
123
+ send: b'POST /identity/token HTTP/1.1\r\nHost: iam.cloud.ibm.com\r\nUser-Agent: ibm-python-sdk-core/iam-authenticator-3.22.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'
124
+ send: b'grant_type=urn%3Aibm%3Aparams%3Aoauth%3Agrant-type%3Aapikey&apikey=[redacted]&response_type=cloud_iam'
125
+ reply: 'HTTP/1.1 200 OK\r\n'
126
+ header: Content-Type: application/json
127
+ header: Content-Language: en-US
128
+ header: Content-Encoding: gzip
129
+ header: Date: Mon, 16 Sep 2024 20:44:45 GMT
130
+ header: Content-Length: 983
131
+ header: Connection: keep-alive
132
+ 2024-09-16 15:44:45,670 [urllib3.connectionpool:DEBUG] https://iam.cloud.ibm.com:443 "POST /identity/token HTTP/11" 200 983
133
+ 2024-09-16 15:44:45,672 [ibm-cloud-sdk-core:DEBUG] Returned from IAM get_token operation
134
+ 2024-09-16 15:44:45,673 [ibm-cloud-sdk-core:DEBUG] Authenticated outbound request (type=iam)
135
+ 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]
136
+ 2024-09-16 15:44:45,673 [ibm-cloud-sdk-core:DEBUG] Sending HTTP request message
137
+ 2024-09-16 15:44:45,674 [urllib3.connectionpool:DEBUG] Starting new HTTPS connection (1): api.global-search-tagging.cloud.ibm.com:443
138
+ 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'
139
+ send: b'{"query": "GST-sdk-*", "fields": ["*"]}'
140
+ reply: 'HTTP/1.1 200 OK\r\n'
141
+ header: Content-Type: application/json
142
+ header: Content-Length: 22
143
+ header: Date: Mon, 16 Sep 2024 20:44:46 GMT
144
+ header: Connection: keep-alive
145
+ 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
146
+ 2024-09-16 15:44:46,080 [ibm-cloud-sdk-core:DEBUG] Received HTTP response message, status code 200
147
+ ```
148
+
149
+ ## Open source @ IBM
150
+
151
+ Find more open source projects on the [IBM Github Page](http://github.com/IBM)
152
+
153
+ ## License
154
+
155
+ This library is licensed under Apache 2.0. Full license text is
156
+ available in [LICENSE](LICENSE).
157
+
158
+ ## Contributing
159
+
160
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -0,0 +1,37 @@
1
+ ibm_cloud_sdk_core/__init__.py,sha256=eC0K027znbykBluNB7Vd3PlBAvxlH0VG3DexknrlKfc,3028
2
+ ibm_cloud_sdk_core/api_exception.py,sha256=YNd7Dg_yiwcHk-AA-suNlivgyrA9A32Do1qtYeKzuWc,3654
3
+ ibm_cloud_sdk_core/base_service.py,sha256=Xn36CiuH4Dhm34Uf8D82p2QDmSlO9bKvJ2DwgqwJHtg,22081
4
+ ibm_cloud_sdk_core/detailed_response.py,sha256=agLMQ-Mh3bU_lLnSnSO1SwjuNBPQj8plO8ew2xXWL6I,3101
5
+ ibm_cloud_sdk_core/get_authenticator.py,sha256=Ozw0JVjnzXQAoUAJQ_gg780AZTg08O2JKlJSkTZuSnU,5581
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
8
+ ibm_cloud_sdk_core/private_helpers.py,sha256=5ei9gNwuN-inNJ2WqMXcXEPfLM1NALOLi4ucLMcYohY,1181
9
+ ibm_cloud_sdk_core/utils.py,sha256=13sHWir3xvp5eJ2JE7FIdAXgQHOKCLlKGk_R-R5W2Ms,15828
10
+ ibm_cloud_sdk_core/version.py,sha256=6fKOiHifsHZJA3QQ4OO4RR3RWQlVQ3Q_VL_B6rmtaoE,23
11
+ ibm_cloud_sdk_core/authenticators/__init__.py,sha256=hIlEbbNC_OLwnD5C8p752CFhE_W45X4IsTc9LvOaRr4,2194
12
+ ibm_cloud_sdk_core/authenticators/authenticator.py,sha256=ml3JFqZPmARESdT-F1qqYfZcvyLc3-1WU5CGNwKi78U,2017
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
15
+ ibm_cloud_sdk_core/authenticators/container_authenticator.py,sha256=Ex0bH5sCZoIK30SGlwajE6o-LjuGWZPvqBozbm5QCd0,7053
16
+ ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py,sha256=LNW9NYY7upiwxlKm633XokmXacEfxPLBPev1yirpx4w,6922
17
+ ibm_cloud_sdk_core/authenticators/iam_assume_authenticator.py,sha256=MxMJnB6YvkB6uSFPWPjRz1Ofl8sRUf-tYGADgASomDo,6772
18
+ ibm_cloud_sdk_core/authenticators/iam_authenticator.py,sha256=ozrFBdVah1y8gcLL68fmReXCFEAltOGLCIuA6PuWLSY,4597
19
+ ibm_cloud_sdk_core/authenticators/iam_request_based_authenticator.py,sha256=0k-rtfaYV3KXxNCEOq8njNDAC4KmUJSbVxOPjbhIxWc,4686
20
+ ibm_cloud_sdk_core/authenticators/mcsp_authenticator.py,sha256=z3fFZf-iW0hsZ9qfJ1y-jKQ3DtNPGf9M9QNgu0gfMoA,5350
21
+ ibm_cloud_sdk_core/authenticators/no_auth_authenticator.py,sha256=dzuU6IJC19SocVHy7Fyln6xrfGvlqnXGeUNR9llspYo,979
22
+ ibm_cloud_sdk_core/authenticators/vpc_instance_authenticator.py,sha256=48Cq9YRRRXmPjhHvnW8-uNgqP8NfNTAG_ajxwg1Mdw0,5414
23
+ ibm_cloud_sdk_core/token_managers/__init__.py,sha256=NEiims6qB8doxq6wtlTBYCIdwf2wRiMTrV0bgfv7WAg,606
24
+ ibm_cloud_sdk_core/token_managers/container_token_manager.py,sha256=bJKn4DwANgEO1L2YuedNV4Jm-srwqpHUNX0jgeD4Quk,9534
25
+ ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py,sha256=ETYOpcSPXZtffFgdx4Dq8WYeIXoc0d1iACFabt53Cwk,5163
26
+ ibm_cloud_sdk_core/token_managers/iam_assume_token_manager.py,sha256=MrUq_Zfk_lwwpnPL8pferT_pOgDqK8DJguV1zaOPWbk,6913
27
+ ibm_cloud_sdk_core/token_managers/iam_request_based_token_manager.py,sha256=DMFhlivC-wi2YGitR8-61xKy8KAkXXnQXLh2MAkBVaw,8567
28
+ ibm_cloud_sdk_core/token_managers/iam_token_manager.py,sha256=bG94h0Io6XaneLUcSuJzLlKSpFLdKH49TieRNAY7fvA,4358
29
+ ibm_cloud_sdk_core/token_managers/jwt_token_manager.py,sha256=FDBdvirmUcJu5vIb5pdhqoQeFS6j0GBSDsF0HtLjg48,3785
30
+ ibm_cloud_sdk_core/token_managers/mcsp_token_manager.py,sha256=jaVwmqPnWF0ZG3lGOL33Q8wXj2tOQX52VYvle5sE_zM,4244
31
+ ibm_cloud_sdk_core/token_managers/token_manager.py,sha256=7vSaSctmy46o5OVnmvVafBAGKzoNjA7kJEzd-rrcLWM,7993
32
+ ibm_cloud_sdk_core/token_managers/vpc_instance_token_manager.py,sha256=0oYXV-Y2o5L3_70r53CxtJLS6Y2pIkzbi1CW1z-QR4Y,7014
33
+ ibm_cloud_sdk_core-3.22.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
34
+ ibm_cloud_sdk_core-3.22.0.dist-info/METADATA,sha256=CUN0lKavU2Q05Wo-6YIxGhIV7eRwRTwQ6vs0DmT2EzU,8631
35
+ ibm_cloud_sdk_core-3.22.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
36
+ ibm_cloud_sdk_core-3.22.0.dist-info/top_level.txt,sha256=otLtvxe-8ugPRmPqeSnbaOjnAl0qjDRZ1HSkC3aeLpI,19
37
+ ibm_cloud_sdk_core-3.22.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.1.0)
2
+ Generator: setuptools (75.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5