ibm-cloud-sdk-core 3.20.6__tar.gz → 3.21.0__tar.gz

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 (67) hide show
  1. ibm_cloud_sdk_core-3.21.0/PKG-INFO +159 -0
  2. ibm_cloud_sdk_core-3.21.0/README.md +114 -0
  3. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/basic_authenticator.py +7 -1
  4. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/bearer_token_authenticator.py +6 -1
  5. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py +5 -2
  6. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/iam_request_based_authenticator.py +5 -1
  7. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/mcsp_authenticator.py +5 -1
  8. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/vpc_instance_authenticator.py +5 -1
  9. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/base_service.py +27 -9
  10. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/get_authenticator.py +7 -1
  11. ibm_cloud_sdk_core-3.21.0/ibm_cloud_sdk_core/logger.py +85 -0
  12. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/token_managers/container_token_manager.py +2 -3
  13. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py +5 -0
  14. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/token_managers/iam_request_based_token_manager.py +7 -1
  15. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/token_managers/mcsp_token_manager.py +7 -1
  16. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/token_managers/token_manager.py +7 -0
  17. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/token_managers/vpc_instance_token_manager.py +4 -5
  18. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/utils.py +6 -2
  19. ibm_cloud_sdk_core-3.21.0/ibm_cloud_sdk_core/version.py +1 -0
  20. ibm_cloud_sdk_core-3.21.0/ibm_cloud_sdk_core.egg-info/PKG-INFO +159 -0
  21. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core.egg-info/SOURCES.txt +2 -0
  22. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/pyproject.toml +1 -1
  23. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_api_exception.py +4 -0
  24. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_base_service.py +9 -0
  25. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_basic_authenticator.py +4 -0
  26. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_bearer_authenticator.py +4 -0
  27. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_container_token_manager.py +4 -0
  28. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_cp4d_authenticator.py +4 -0
  29. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_cp4d_token_manager.py +4 -0
  30. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_http_adapter.py +9 -41
  31. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_iam_authenticator.py +4 -0
  32. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_iam_token_manager.py +4 -0
  33. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_jwt_token_manager.py +4 -0
  34. ibm_cloud_sdk_core-3.21.0/test/test_logger.py +94 -0
  35. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_mcsp_authenticator.py +4 -0
  36. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_mcsp_token_manager.py +4 -0
  37. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_utils.py +5 -1
  38. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_vpc_instance_authenticator.py +4 -0
  39. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_vpc_instance_token_manager.py +9 -58
  40. ibm_cloud_sdk_core-3.20.6/PKG-INFO +0 -124
  41. ibm_cloud_sdk_core-3.20.6/README.md +0 -79
  42. ibm_cloud_sdk_core-3.20.6/ibm_cloud_sdk_core/version.py +0 -1
  43. ibm_cloud_sdk_core-3.20.6/ibm_cloud_sdk_core.egg-info/PKG-INFO +0 -124
  44. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/LICENSE +0 -0
  45. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/MANIFEST.in +0 -0
  46. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/__init__.py +0 -0
  47. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/api_exception.py +0 -0
  48. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/__init__.py +0 -0
  49. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/authenticator.py +0 -0
  50. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/container_authenticator.py +0 -0
  51. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/iam_authenticator.py +0 -0
  52. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/authenticators/no_auth_authenticator.py +0 -0
  53. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/detailed_response.py +0 -0
  54. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/http_adapter.py +0 -0
  55. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/private_helpers.py +0 -0
  56. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/token_managers/__init__.py +0 -0
  57. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/token_managers/iam_token_manager.py +0 -0
  58. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core/token_managers/jwt_token_manager.py +0 -0
  59. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core.egg-info/dependency_links.txt +0 -0
  60. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core.egg-info/requires.txt +0 -0
  61. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/ibm_cloud_sdk_core.egg-info/top_level.txt +0 -0
  62. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/setup.cfg +0 -0
  63. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_authenticator.py +0 -0
  64. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_container_authenticator.py +0 -0
  65. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_detailed_response.py +0 -0
  66. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_no_auth_authenticator.py +0 -0
  67. {ibm_cloud_sdk_core-3.20.6 → ibm_cloud_sdk_core-3.21.0}/test/test_token_manager.py +0 -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
+ [![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.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).
@@ -0,0 +1,114 @@
1
+ [![Build Status](https://app.travis-ci.com/IBM/python-sdk-core.svg?branch=main)](https://app.travis-ci.com/IBM/python-sdk-core)
2
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ibm-cloud-sdk-core)](https://pypi.org/project/ibm-cloud-sdk-core/)
3
+ [![Latest Stable Version](https://img.shields.io/pypi/v/ibm-cloud-sdk-core.svg)](https://pypi.python.org/pypi/ibm-cloud-sdk-core)
4
+ [![CLA assistant](https://cla-assistant.io/readme/badge/ibm/python-sdk-core)](https://cla-assistant.io/ibm/python-sdk-core)
5
+ [![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)
6
+
7
+ # IBM Python SDK Core Version 3.21.0
8
+ This project contains core functionality required by Python code generated by the IBM Cloud OpenAPI SDK Generator
9
+ (openapi-sdkgen).
10
+
11
+ # Python Version
12
+ The current minimum Python version supported is 3.8.
13
+
14
+ ## Installation
15
+
16
+ To install, use `pip`:
17
+
18
+ ```bash
19
+ python -m pip install --upgrade ibm-cloud-sdk-core
20
+ ```
21
+
22
+ ## Authentication
23
+ The python-sdk-core project supports the following types of authentication:
24
+ - Basic Authentication
25
+ - Bearer Token Authentication
26
+ - Identity and Access Management (IAM) Authentication
27
+ - Container Authentication
28
+ - VPC Instance Authentication
29
+ - Cloud Pak for Data Authentication
30
+ - No Authentication (for testing)
31
+
32
+ For more information about the various authentication types and how to use them with your services, click [here](Authentication.md).
33
+
34
+ ## Issues
35
+
36
+ If you encounter an issue with this project, you are welcome to submit a [bug report](https://github.com/IBM/python-sdk-core/issues).
37
+ Before opening a new issue, please search for similar issues. It's possible that someone has already reported it.
38
+
39
+ ## Logging
40
+
41
+ This library uses Python's built-in `logging` module to perform logging of error,
42
+ warning, informational and debug messages.
43
+ The components within the SDK Core library use a single logger named `ibm-cloud-sdk-core`.
44
+
45
+ For complete information on the logging facility, please see: [Logging facility for Python](https://docs.python.org/3/library/logging.html).
46
+
47
+ ### Enable logging
48
+
49
+ There are various ways to configure and enable the logging facility.
50
+
51
+ The code example below demonstrates a simple way to enable debug logging by invoking
52
+ the `logging.basicConfig()` function.
53
+
54
+ Note that, as a convenience, if you set the logging level to `DEBUG`, then HTTP request/response message logging
55
+ is also enabled.
56
+
57
+ The following code example shows how debug logging can be enabled:
58
+ ```python
59
+ import logging
60
+
61
+ # Create a basic logging configuration that:
62
+ # 1. Defines a handler to display messages on the console.
63
+ # 2. Sets the root logger's logging level to DEBUG.
64
+ # 3. Sets the 'format' string used to display messages.
65
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(name)s:%(levelname)s] %(message)s', force=True)
66
+ ```
67
+
68
+ When running your application, you should see output like this if debug logging is enabled:
69
+ ```
70
+ 2024-09-16 15:44:45,174 [ibm-cloud-sdk-core:DEBUG] Get authenticator from environment, key=global_search
71
+ 2024-09-16 15:44:45,175 [ibm-cloud-sdk-core:DEBUG] Set service URL: https://api.global-search-tagging.cloud.ibm.com
72
+ 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
73
+ 2024-09-16 15:44:45,181 [ibm-cloud-sdk-core:DEBUG] Configuring BaseService instance with service name: global_search
74
+ 2024-09-16 15:44:45,181 [ibm-cloud-sdk-core:DEBUG] Performing synchronous token fetch
75
+ 2024-09-16 15:44:45,182 [ibm-cloud-sdk-core:DEBUG] Invoking IAM get_token operation: https://iam.cloud.ibm.com/identity/token
76
+ 2024-09-16 15:44:45,182 [urllib3.connectionpool:DEBUG] Starting new HTTPS connection (1): iam.cloud.ibm.com:443
77
+ 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'
78
+ send: b'grant_type=urn%3Aibm%3Aparams%3Aoauth%3Agrant-type%3Aapikey&apikey=[redacted]&response_type=cloud_iam'
79
+ reply: 'HTTP/1.1 200 OK\r\n'
80
+ header: Content-Type: application/json
81
+ header: Content-Language: en-US
82
+ header: Content-Encoding: gzip
83
+ header: Date: Mon, 16 Sep 2024 20:44:45 GMT
84
+ header: Content-Length: 983
85
+ header: Connection: keep-alive
86
+ 2024-09-16 15:44:45,670 [urllib3.connectionpool:DEBUG] https://iam.cloud.ibm.com:443 "POST /identity/token HTTP/11" 200 983
87
+ 2024-09-16 15:44:45,672 [ibm-cloud-sdk-core:DEBUG] Returned from IAM get_token operation
88
+ 2024-09-16 15:44:45,673 [ibm-cloud-sdk-core:DEBUG] Authenticated outbound request (type=iam)
89
+ 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]
90
+ 2024-09-16 15:44:45,673 [ibm-cloud-sdk-core:DEBUG] Sending HTTP request message
91
+ 2024-09-16 15:44:45,674 [urllib3.connectionpool:DEBUG] Starting new HTTPS connection (1): api.global-search-tagging.cloud.ibm.com:443
92
+ 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'
93
+ send: b'{"query": "GST-sdk-*", "fields": ["*"]}'
94
+ reply: 'HTTP/1.1 200 OK\r\n'
95
+ header: Content-Type: application/json
96
+ header: Content-Length: 22
97
+ header: Date: Mon, 16 Sep 2024 20:44:46 GMT
98
+ header: Connection: keep-alive
99
+ 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
100
+ 2024-09-16 15:44:46,080 [ibm-cloud-sdk-core:DEBUG] Received HTTP response message, status code 200
101
+ ```
102
+
103
+ ## Open source @ IBM
104
+
105
+ Find more open source projects on the [IBM Github Page](http://github.com/IBM)
106
+
107
+ ## License
108
+
109
+ This library is licensed under Apache 2.0. Full license text is
110
+ available in [LICENSE](LICENSE).
111
+
112
+ ## Contributing
113
+
114
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -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
- # Uncomment this to enable http debugging
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 to overwrite these.
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