splitio-configs 1.0.0b1__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 (32) hide show
  1. splitio_configs-1.0.0b1/LICENSE.txt +202 -0
  2. splitio_configs-1.0.0b1/NOTICE +5 -0
  3. splitio_configs-1.0.0b1/PKG-INFO +88 -0
  4. splitio_configs-1.0.0b1/README.md +65 -0
  5. splitio_configs-1.0.0b1/setup.cfg +32 -0
  6. splitio_configs-1.0.0b1/setup.py +63 -0
  7. splitio_configs-1.0.0b1/splitio_configs/__init__.py +17 -0
  8. splitio_configs-1.0.0b1/splitio_configs/api/__init__.py +1 -0
  9. splitio_configs-1.0.0b1/splitio_configs/api/auth.py +125 -0
  10. splitio_configs-1.0.0b1/splitio_configs/api/configs.py +170 -0
  11. splitio_configs-1.0.0b1/splitio_configs/api/impressions.py +87 -0
  12. splitio_configs-1.0.0b1/splitio_configs/client/__init__.py +5 -0
  13. splitio_configs-1.0.0b1/splitio_configs/client/configs_client.py +987 -0
  14. splitio_configs-1.0.0b1/splitio_configs/client/configs_client_settings.py +137 -0
  15. splitio_configs-1.0.0b1/splitio_configs/client/util.py +49 -0
  16. splitio_configs-1.0.0b1/splitio_configs/models/__init__.py +9 -0
  17. splitio_configs-1.0.0b1/splitio_configs/models/config.py +40 -0
  18. splitio_configs-1.0.0b1/splitio_configs/models/configs.py +84 -0
  19. splitio_configs-1.0.0b1/splitio_configs/models/events_type.py +12 -0
  20. splitio_configs-1.0.0b1/splitio_configs/models/fallback_config.py +59 -0
  21. splitio_configs-1.0.0b1/splitio_configs/models/target.py +30 -0
  22. splitio_configs-1.0.0b1/splitio_configs/models/variant.py +28 -0
  23. splitio_configs-1.0.0b1/splitio_configs/storage/__init__.py +1 -0
  24. splitio_configs-1.0.0b1/splitio_configs/storage/inmemory.py +65 -0
  25. splitio_configs-1.0.0b1/splitio_configs/sync/__init__.py +0 -0
  26. splitio_configs-1.0.0b1/splitio_configs/sync/config.py +242 -0
  27. splitio_configs-1.0.0b1/splitio_configs/version.py +1 -0
  28. splitio_configs-1.0.0b1/splitio_configs.egg-info/PKG-INFO +88 -0
  29. splitio_configs-1.0.0b1/splitio_configs.egg-info/SOURCES.txt +31 -0
  30. splitio_configs-1.0.0b1/splitio_configs.egg-info/dependency_links.txt +1 -0
  31. splitio_configs-1.0.0b1/splitio_configs.egg-info/requires.txt +34 -0
  32. splitio_configs-1.0.0b1/splitio_configs.egg-info/top_level.txt +1 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ Harness Feature Management Python Configs SDK Copyright 2024-2026 Harness Inc.
2
+
3
+ This product includes software developed at Harness Inc. (https://harness.io/).
4
+
5
+ This product includes software originally developed by Split Software, Inc. (https://www.split.io/). Copyright 2015-2024 Split Software, Inc.
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.1
2
+ Name: splitio_configs
3
+ Version: 1.0.0b1
4
+ Summary: Harness.io Python Configs Client
5
+ Home-page: https://github.com/splitio/python-configs-client
6
+ Download-URL: https://github.com/splitio/python-copnfigs-client/tarball/1.0.0-beta1
7
+ Author: Bilal Al-Shahwany
8
+ Author-email: bilal.al-shahwany@harness.io
9
+ License: Apache License 2.0
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 2
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Description-Content-Type: text/markdown
17
+ Provides-Extra: test
18
+ Provides-Extra: uwsgi
19
+ Provides-Extra: cpphash
20
+ Provides-Extra: asyncio
21
+ License-File: LICENSE.txt
22
+ License-File: NOTICE
23
+
24
+ # Harness FME Python Configs SDK
25
+ ## Overview
26
+ Harness FME Python Configs SDK is designed to serve standalone, versioned configuration objects in Python applications.
27
+
28
+ ## Compatibility
29
+ This SDK is compatible with **Python 3.7 and higher**.
30
+
31
+ ## Getting started
32
+ Below is a simple example that describes the instantiation and most basic usage of our SDK:
33
+
34
+ Run `pip install splitio_configs_client`
35
+
36
+ ```python
37
+ from splitio_configs import ConfigsClient, TimeoutException, Target
38
+
39
+ client = ConfigsClient('YOUR_SDK_KEY')
40
+ try:
41
+ client.block_until_ready()
42
+ except TimeoutException:
43
+ # SDK_READY_TIMED_OUT: evaluations will return the fallback config or a Config with variant "control".
44
+ pass
45
+
46
+ # Without target: returns the default variant of the config
47
+ default_config = client.get_config('CONFIG_NAME')
48
+ print(default_config.variant) # example: 'v1'
49
+ print(default_config.value) # example: {'prompt': 'Hello world', 'temperature': 0.5}
50
+
51
+ # With target: evaluates targeting rules for the given key
52
+ target = Target('user-123')
53
+ config = client.get_config('CONFIG_NAME', target)
54
+ print(config.variant, config.value)
55
+ ```
56
+
57
+ The SDK also support asyncio, see below example:
58
+ ```python
59
+ from splitio_configs import ConfigsClientAsync, TimeoutException, Target
60
+
61
+ async def main():
62
+ client = ConfigsClientAsync('YOUR_SDK_KEY')
63
+ try:
64
+ await client.block_until_ready()
65
+ except TimeoutException:
66
+ # SDK_READY_TIMED_OUT: evaluations will return the fallback config or a Config with variant "control".
67
+ pass
68
+
69
+ # Without target: returns the default variant of the config
70
+ default_config = await client.get_config('CONFIG_NAME')
71
+ print(default_config.variant) # example: 'v1'
72
+ print(default_config.value) # example: {'prompt': 'Hello world', 'temperature': 0.5}
73
+
74
+ # With target: evaluates targeting rules for the given key
75
+ target = Target('user-123')
76
+ config = await client.get_config('CONFIG_NAME', target)
77
+ print(config.variant, config.value)
78
+
79
+ asyncio.run(main())
80
+ ```
81
+
82
+ Please refer to [our official docs](TBD) to learn about all the functionality provided by our SDK and the configuration options available for tailoring it to your current application setup.
83
+
84
+ ## Submitting issues
85
+ The Split team monitors all issues submitted to this [issue tracker](https://github.com/splitio/python-configs-client/issues). We encourage you to use this issue tracker to submit any bug reports, feedback, and feature enhancements. We'll do our best to respond in a timely manner.
86
+
87
+ ## License
88
+ Licensed under the Apache License, Version 2.0. See: [Apache License](http://www.apache.org/licenses/).
@@ -0,0 +1,65 @@
1
+ # Harness FME Python Configs SDK
2
+ ## Overview
3
+ Harness FME Python Configs SDK is designed to serve standalone, versioned configuration objects in Python applications.
4
+
5
+ ## Compatibility
6
+ This SDK is compatible with **Python 3.7 and higher**.
7
+
8
+ ## Getting started
9
+ Below is a simple example that describes the instantiation and most basic usage of our SDK:
10
+
11
+ Run `pip install splitio_configs_client`
12
+
13
+ ```python
14
+ from splitio_configs import ConfigsClient, TimeoutException, Target
15
+
16
+ client = ConfigsClient('YOUR_SDK_KEY')
17
+ try:
18
+ client.block_until_ready()
19
+ except TimeoutException:
20
+ # SDK_READY_TIMED_OUT: evaluations will return the fallback config or a Config with variant "control".
21
+ pass
22
+
23
+ # Without target: returns the default variant of the config
24
+ default_config = client.get_config('CONFIG_NAME')
25
+ print(default_config.variant) # example: 'v1'
26
+ print(default_config.value) # example: {'prompt': 'Hello world', 'temperature': 0.5}
27
+
28
+ # With target: evaluates targeting rules for the given key
29
+ target = Target('user-123')
30
+ config = client.get_config('CONFIG_NAME', target)
31
+ print(config.variant, config.value)
32
+ ```
33
+
34
+ The SDK also support asyncio, see below example:
35
+ ```python
36
+ from splitio_configs import ConfigsClientAsync, TimeoutException, Target
37
+
38
+ async def main():
39
+ client = ConfigsClientAsync('YOUR_SDK_KEY')
40
+ try:
41
+ await client.block_until_ready()
42
+ except TimeoutException:
43
+ # SDK_READY_TIMED_OUT: evaluations will return the fallback config or a Config with variant "control".
44
+ pass
45
+
46
+ # Without target: returns the default variant of the config
47
+ default_config = await client.get_config('CONFIG_NAME')
48
+ print(default_config.variant) # example: 'v1'
49
+ print(default_config.value) # example: {'prompt': 'Hello world', 'temperature': 0.5}
50
+
51
+ # With target: evaluates targeting rules for the given key
52
+ target = Target('user-123')
53
+ config = await client.get_config('CONFIG_NAME', target)
54
+ print(config.variant, config.value)
55
+
56
+ asyncio.run(main())
57
+ ```
58
+
59
+ Please refer to [our official docs](TBD) to learn about all the functionality provided by our SDK and the configuration options available for tailoring it to your current application setup.
60
+
61
+ ## Submitting issues
62
+ The Split team monitors all issues submitted to this [issue tracker](https://github.com/splitio/python-configs-client/issues). We encourage you to use this issue tracker to submit any bug reports, feedback, and feature enhancements. We'll do our best to respond in a timely manner.
63
+
64
+ ## License
65
+ Licensed under the Apache License, Version 2.0. See: [Apache License](http://www.apache.org/licenses/).
@@ -0,0 +1,32 @@
1
+ [wheel]
2
+ universal = 1
3
+
4
+ [metadata]
5
+ name = splitio_configs
6
+ description = Harness FME Python Configs SDK is designed to serve standalone, versioned configuration objects in Python applications.
7
+ long_description = file: README.md
8
+ long_description_content_type = text/markdown
9
+
10
+ [flake8]
11
+ max-line-length = 100
12
+ exclude = tests/*
13
+
14
+ [aliases]
15
+ test = pytest
16
+
17
+ [tool:pytest]
18
+ addopts = --verbose --cov=splitio_configs --cov-report xml
19
+ python_classes = *Tests
20
+
21
+ [build_sphinx]
22
+ source-dir = doc/source
23
+ build-dir = doc/build
24
+ all_files = 1
25
+
26
+ [upload_sphinx]
27
+ upload-dir = doc/build/html
28
+
29
+ [egg_info]
30
+ tag_build =
31
+ tag_date = 0
32
+
@@ -0,0 +1,63 @@
1
+ """Setup module."""
2
+ # !/usr/bin/env python
3
+
4
+ from os import path
5
+ from setuptools import setup, find_packages
6
+
7
+ TESTS_REQUIRES = [
8
+ 'flake8',
9
+ 'pytest==7.0.1',
10
+ 'pytest-mock==3.11.1',
11
+ 'coverage==7.0.0',
12
+ 'pytest-cov==4.1.0',
13
+ 'importlib-metadata==6.7',
14
+ 'tomli==1.2.3',
15
+ 'iniconfig==1.1.1',
16
+ 'attrs==22.1.0',
17
+ 'pytest-asyncio==0.21.0',
18
+ 'aiohttp>=3.8.4',
19
+ 'aiofiles>=23.1.0',
20
+ 'requests-kerberos>=0.15.0',
21
+ 'urllib3==2.0.7'
22
+ ]
23
+
24
+ INSTALL_REQUIRES = [
25
+ 'splitio-commons',
26
+ 'requests',
27
+ 'pyyaml',
28
+ 'docopt>=0.6.2',
29
+ 'enum34;python_version<"3.4"',
30
+ 'bloom-filter2>=2.0.0'
31
+ ]
32
+
33
+ with open(path.join(path.abspath(path.dirname(__file__)), 'splitio_configs', 'version.py')) as f:
34
+ exec(f.read()) # pylint: disable=exec-used
35
+
36
+ setup(
37
+ name='splitio_configs',
38
+ version=__version__, # pylint: disable=undefined-variable
39
+ description='Harness.io Python Configs Client',
40
+ author='Bilal Al-Shahwany',
41
+ author_email='bilal.al-shahwany@harness.io',
42
+ url='https://github.com/splitio/python-configs-client',
43
+ download_url=('https://github.com/splitio/python-copnfigs-client/tarball/' + __version__), # pylint: disable=undefined-variable
44
+ license='Apache License 2.0',
45
+ install_requires=INSTALL_REQUIRES,
46
+ tests_require=TESTS_REQUIRES,
47
+ extras_require={
48
+ 'test': TESTS_REQUIRES,
49
+ 'uwsgi': ['uwsgi>=2.0.0'],
50
+ 'cpphash': ['mmh3cffi==0.2.1'],
51
+ 'asyncio': ['aiohttp>=3.8.4', 'aiofiles>=23.1.0']
52
+ },
53
+ setup_requires=['pytest-runner', 'pluggy==1.0.0;python_version<"3.8"'],
54
+ classifiers=[
55
+ 'Environment :: Console',
56
+ 'Intended Audience :: Developers',
57
+ 'Programming Language :: Python',
58
+ 'Programming Language :: Python :: 2',
59
+ 'Programming Language :: Python :: 3',
60
+ 'Topic :: Software Development :: Libraries'
61
+ ],
62
+ packages=find_packages(exclude=('tests', 'tests.*'))
63
+ )
@@ -0,0 +1,17 @@
1
+ """Harness Configs SDK."""
2
+ from splitio_configs.client import ConfigsClient, ConfigsClientAsync, ConfigsClientSettings, ServiceEndpoints, TimeoutException
3
+ from splitio_configs.models import Config, FallbackConfigs, Target, Key, EvaluationOptions, SdkEvent
4
+
5
+ __all__ = [
6
+ "ConfigsClient",
7
+ "ConfigsClientAsync",
8
+ "ConfigsClientSettings",
9
+ "ServiceEndpoints",
10
+ "TimeoutException",
11
+ "Config",
12
+ "FallbackConfigs",
13
+ "Target",
14
+ "Key",
15
+ "EvaluationOptions",
16
+ "SdkEvent"
17
+ ]
@@ -0,0 +1 @@
1
+ # Storage tests module
@@ -0,0 +1,125 @@
1
+ """Auth API module."""
2
+
3
+ import logging
4
+ import json
5
+
6
+ from splitio_commons.api import APIException, headers_from_metadata
7
+ from splitio_commons.api.commons import headers_from_metadata, record_telemetry
8
+ from splitio_commons.util.time import get_current_epoch_time_ms
9
+ from splitio_commons.api.client import HttpClientException
10
+ from splitio_commons.api.auth import AuthAPI as CommonsAuthAPI, AuthAPIAsync as CommonsAuthAPIAsync
11
+ from splitio_commons.models.token import from_raw
12
+ from splitio_commons.models.telemetry import HTTPExceptionsAndLatencies
13
+
14
+ _LOGGER = logging.getLogger(__name__)
15
+
16
+ class AuthAPIBase(CommonsAuthAPI):
17
+ def __init__(self, client, sdk_key, sdk_metadata, telemetry_runtime_producer, spec_version):
18
+ """
19
+ Class constructor.
20
+
21
+ :param client: HTTP Client responsble for issuing calls to the backend.
22
+ :type client: HttpClient
23
+ :param sdk_key: User sdk key.
24
+ :type sdk_key: string
25
+ :param sdk_metadata: SDK version & machine name & IP.
26
+ :type sdk_metadata: splitio_commons.client.util.SdkMetadata
27
+ """
28
+ CommonsAuthAPI.__init__(self, client, sdk_key, sdk_metadata, telemetry_runtime_producer, spec_version)
29
+
30
+ def _update_sdk_verison_header(self):
31
+ if self._metadata.get('SplitSDKVersion'):
32
+ self._metadata['X-Harness-FME-SDK-Version'] = self._metadata['SplitSDKVersion']
33
+ del self._metadata['SplitSDKVersion']
34
+
35
+ class AuthAPI(AuthAPIBase): # pylint: disable=too-few-public-methods
36
+ """Class that uses an httpClient to communicate with the SDK Auth Service API."""
37
+
38
+ def __init__(self, client, sdk_key, sdk_metadata, telemetry_runtime_producer, spec_version):
39
+ """
40
+ Class constructor.
41
+
42
+ :param client: HTTP Client responsble for issuing calls to the backend.
43
+ :type client: HttpClient
44
+ :param sdk_key: User sdk key.
45
+ :type sdk_key: string
46
+ :param sdk_metadata: SDK version & machine name & IP.
47
+ :type sdk_metadata: splitio_commons.client.util.SdkMetadata
48
+ """
49
+ AuthAPIBase.__init__(self, client, sdk_key, sdk_metadata, telemetry_runtime_producer, spec_version)
50
+
51
+ def authenticate(self):
52
+ """
53
+ Perform authentication.
54
+
55
+ :return: Json representation of an authentication.
56
+ :rtype: splitio_commons.models.token.Token
57
+ """
58
+ try:
59
+ self._update_sdk_verison_header()
60
+ response = self._client.get(
61
+ 'auth',
62
+ 'v3/auth?capabilities=config',
63
+ self._sdk_key,
64
+ extra_headers=self._metadata,
65
+ )
66
+ if 200 <= response.status_code < 300:
67
+ payload = json.loads(response.body)
68
+ return from_raw(payload)
69
+
70
+ if (response.status_code >= 400 and response.status_code < 500):
71
+ self._telemetry_runtime_producer.record_auth_rejections()
72
+
73
+ raise APIException(response.body, response.status_code)
74
+
75
+ except HttpClientException as exc:
76
+ _LOGGER.error('Exception raised while authenticating')
77
+ _LOGGER.debug('Exception information: ', exc_info=True)
78
+ raise APIException('Could not perform authentication.') from exc
79
+
80
+ class AuthAPIAsync(AuthAPIBase): # pylint: disable=too-few-public-methods
81
+ """Async Class that uses an httpClient to communicate with the SDK Auth Service API."""
82
+
83
+ def __init__(self, client, sdk_key, sdk_metadata, telemetry_runtime_producer, spec_version):
84
+ """
85
+ Class constructor.
86
+
87
+ :param client: HTTP Client responsble for issuing calls to the backend.
88
+ :type client: HttpClient
89
+ :param sdk_key: User sdk key.
90
+ :type sdk_key: string
91
+ :param sdk_metadata: SDK version & machine name & IP.
92
+ :type sdk_metadata: splitio_commons.client.util.SdkMetadata
93
+ """
94
+ AuthAPIBase.__init__(self, client, sdk_key, sdk_metadata, telemetry_runtime_producer, spec_version)
95
+
96
+ async def authenticate(self):
97
+ """
98
+ Perform authentication.
99
+
100
+ :return: Json representation of an authentication.
101
+ :rtype: splitio_commons.models.token.Token
102
+ """
103
+ try:
104
+ self._update_sdk_verison_header()
105
+ _LOGGER.debug("fetching auth")
106
+ response = await self._client.get(
107
+ 'auth',
108
+ 'v3/auth?capabilities=config',
109
+ self._sdk_key,
110
+ extra_headers=self._metadata,
111
+ )
112
+ if 200 <= response.status_code < 300:
113
+ payload = json.loads(response.body)
114
+ _LOGGER.debug(payload)
115
+ return from_raw(payload)
116
+
117
+ if (response.status_code >= 400 and response.status_code < 500):
118
+ await self._telemetry_runtime_producer.record_auth_rejections()
119
+
120
+ raise APIException(response.body, response.status_code)
121
+
122
+ except HttpClientException as exc:
123
+ _LOGGER.error('Exception raised while authenticating')
124
+ _LOGGER.debug('Exception information: ', exc_info=True)
125
+ raise APIException('Could not perform authentication.') from exc