gofeatureflag-python-provider 0.4.0__tar.gz → 0.4.2__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.
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/PKG-INFO +2 -2
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/gofeatureflag_python_provider/provider.py +41 -20
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/gofeatureflag_python_provider/request_flag_evaluation.py +3 -4
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/pyproject.toml +3 -3
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/README.md +0 -0
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/gofeatureflag_python_provider/__init__.py +0 -0
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/gofeatureflag_python_provider/data_collector_hook.py +0 -0
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/gofeatureflag_python_provider/metadata.py +0 -0
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/gofeatureflag_python_provider/options.py +0 -0
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/gofeatureflag_python_provider/request_data_collector.py +0 -0
- {gofeatureflag_python_provider-0.4.0 → gofeatureflag_python_provider-0.4.2}/gofeatureflag_python_provider/response_flag_evaluation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: gofeatureflag-python-provider
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: GO Feature Flag provider for OpenFeature
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Keywords: feature flags,feature toggles,go-feature-flag,gofeatureflag,openfeature,open-feature
|
|
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
16
16
|
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
17
17
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
18
|
Requires-Dist: asyncio (>=3.4.3,<4.0.0)
|
|
19
|
-
Requires-Dist: openfeature-sdk (>=0.5.0,<0.
|
|
19
|
+
Requires-Dist: openfeature-sdk (>=0.5.0,<0.9.0)
|
|
20
20
|
Requires-Dist: pydantic (>=2.5.2,<3.0.0)
|
|
21
21
|
Requires-Dist: pylru (>=1.2.1,<2.0.0)
|
|
22
22
|
Requires-Dist: rel (>=0.4.9,<0.5.0)
|
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from http import HTTPStatus
|
|
3
|
-
from threading import Thread
|
|
4
|
-
from typing import List, Optional, Type, Union
|
|
5
|
-
from urllib.parse import urljoin
|
|
6
|
-
|
|
7
2
|
import pylru
|
|
8
3
|
import urllib3
|
|
9
4
|
import websocket
|
|
5
|
+
from gofeatureflag_python_provider.data_collector_hook import DataCollectorHook
|
|
6
|
+
from gofeatureflag_python_provider.metadata import GoFeatureFlagMetadata
|
|
7
|
+
from gofeatureflag_python_provider.options import BaseModel, GoFeatureFlagOptions
|
|
8
|
+
from gofeatureflag_python_provider.request_flag_evaluation import (
|
|
9
|
+
RequestFlagEvaluation,
|
|
10
|
+
convert_evaluation_context,
|
|
11
|
+
)
|
|
12
|
+
from gofeatureflag_python_provider.response_flag_evaluation import (
|
|
13
|
+
JsonType,
|
|
14
|
+
ResponseFlagEvaluation,
|
|
15
|
+
)
|
|
16
|
+
from http import HTTPStatus
|
|
10
17
|
from openfeature.evaluation_context import EvaluationContext
|
|
11
18
|
from openfeature.exception import (
|
|
12
19
|
ErrorCode,
|
|
13
20
|
FlagNotFoundError,
|
|
14
21
|
GeneralError,
|
|
22
|
+
InvalidContextError,
|
|
15
23
|
OpenFeatureError,
|
|
16
24
|
TypeMismatchError,
|
|
17
25
|
)
|
|
18
26
|
from openfeature.flag_evaluation import FlagResolutionDetails, Reason
|
|
19
27
|
from openfeature.hook import Hook
|
|
20
|
-
from openfeature.provider.metadata import Metadata
|
|
21
28
|
from openfeature.provider import AbstractProvider
|
|
29
|
+
from openfeature.provider.metadata import Metadata
|
|
22
30
|
from pydantic import PrivateAttr, ValidationError
|
|
23
|
-
|
|
24
|
-
from
|
|
25
|
-
from gofeatureflag_python_provider.metadata import GoFeatureFlagMetadata
|
|
26
|
-
from gofeatureflag_python_provider.options import BaseModel, GoFeatureFlagOptions
|
|
27
|
-
from gofeatureflag_python_provider.request_flag_evaluation import (
|
|
28
|
-
RequestFlagEvaluation,
|
|
29
|
-
convert_evaluation_context,
|
|
30
|
-
)
|
|
31
|
-
from gofeatureflag_python_provider.response_flag_evaluation import (
|
|
32
|
-
JsonType,
|
|
33
|
-
ResponseFlagEvaluation,
|
|
34
|
-
)
|
|
31
|
+
from threading import Thread
|
|
32
|
+
from typing import List, Optional, Type, Union
|
|
35
33
|
|
|
36
34
|
AbstractProviderMetaclass = type(AbstractProvider)
|
|
37
35
|
BaseModelMetaclass = type(BaseModel)
|
|
@@ -196,6 +194,16 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
196
194
|
"/v1/feature/{}/eval".format(flag_key),
|
|
197
195
|
)
|
|
198
196
|
|
|
197
|
+
# add exporter metadata to the context if it exists
|
|
198
|
+
if self.options.exporter_metadata:
|
|
199
|
+
goff_request.gofeatureflag["exporterMetadata"] = (
|
|
200
|
+
self.options.exporter_metadata
|
|
201
|
+
)
|
|
202
|
+
goff_request.gofeatureflag["exporterMetadata"]["openfeature"] = True
|
|
203
|
+
goff_request.gofeatureflag["exporterMetadata"][
|
|
204
|
+
"provider"
|
|
205
|
+
] = "python"
|
|
206
|
+
|
|
199
207
|
response = self._http_client.request(
|
|
200
208
|
method="POST",
|
|
201
209
|
url=url,
|
|
@@ -203,16 +211,29 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
203
211
|
body=goff_request.model_dump_json(),
|
|
204
212
|
)
|
|
205
213
|
|
|
214
|
+
response_body = response.data
|
|
215
|
+
|
|
216
|
+
# Handle 404 error code
|
|
206
217
|
if response.status == HTTPStatus.NOT_FOUND.value:
|
|
207
218
|
raise FlagNotFoundError(
|
|
208
219
|
"flag {} was not found in your configuration".format(flag_key)
|
|
209
220
|
)
|
|
210
221
|
|
|
211
|
-
|
|
222
|
+
# Handle 400 error code
|
|
223
|
+
if int(response.status) == HTTPStatus.BAD_REQUEST.value:
|
|
224
|
+
response_dict = json.loads(response_body)
|
|
225
|
+
error_message = response_dict.get("message")
|
|
226
|
+
|
|
227
|
+
if error_message is None:
|
|
228
|
+
error_message = "no error message given."
|
|
229
|
+
|
|
230
|
+
raise InvalidContextError("Invalid context: " + error_message)
|
|
231
|
+
|
|
232
|
+
# Handle every error response above 400
|
|
233
|
+
if int(response.status) > HTTPStatus.BAD_REQUEST.value:
|
|
212
234
|
raise GeneralError(
|
|
213
235
|
"impossible to contact GO Feature Flag relay proxy instance"
|
|
214
236
|
)
|
|
215
|
-
response_body = response.data
|
|
216
237
|
|
|
217
238
|
response_flag_evaluation = ResponseFlagEvaluation.model_validate_json(
|
|
218
239
|
response_body
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import hashlib
|
|
2
2
|
import json
|
|
3
|
-
from
|
|
4
|
-
|
|
3
|
+
from gofeatureflag_python_provider.options import BaseModel
|
|
5
4
|
from openfeature.evaluation_context import EvaluationContext
|
|
6
5
|
from openfeature.exception import (
|
|
7
6
|
TargetingKeyMissingError,
|
|
8
7
|
InvalidContextError,
|
|
9
8
|
)
|
|
10
9
|
from pydantic import SkipValidation
|
|
11
|
-
|
|
12
|
-
from gofeatureflag_python_provider.options import BaseModel
|
|
10
|
+
from typing import Optional, Any, Dict
|
|
13
11
|
|
|
14
12
|
|
|
15
13
|
class GoFeatureFlagEvaluationContext(BaseModel):
|
|
@@ -56,3 +54,4 @@ def convert_evaluation_context(
|
|
|
56
54
|
class RequestFlagEvaluation(BaseModel):
|
|
57
55
|
user: GoFeatureFlagEvaluationContext
|
|
58
56
|
defaultValue: SkipValidation[Any] = None
|
|
57
|
+
gofeatureflag: Optional[Dict] = {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "gofeatureflag-python-provider"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
description = "GO Feature Flag provider for OpenFeature"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
authors = [ "Thomas Poignant" ]
|
|
@@ -28,7 +28,7 @@ classifiers = [
|
|
|
28
28
|
|
|
29
29
|
[tool.poetry.dependencies]
|
|
30
30
|
python = "^3.9"
|
|
31
|
-
openfeature-sdk = ">=0.5.0,<0.
|
|
31
|
+
openfeature-sdk = ">=0.5.0,<0.9.0"
|
|
32
32
|
pydantic = "^2.5.2"
|
|
33
33
|
urllib3 = "^2.1.0"
|
|
34
34
|
pylru = "^1.2.1"
|
|
@@ -38,7 +38,7 @@ classifiers = [
|
|
|
38
38
|
|
|
39
39
|
[tool.poetry.group.dev.dependencies]
|
|
40
40
|
pytest = ">=7.4,<9.0"
|
|
41
|
-
black = ">=23.10.1,<
|
|
41
|
+
black = ">=23.10.1,<26.0.0"
|
|
42
42
|
requests = "^2.31.0"
|
|
43
43
|
pyyaml = "^6.0.1"
|
|
44
44
|
pytest-docker = ">=2.0.1,<4.0.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|