Skip to content

Commit 5b2e0f4

Browse files
committed
fix(env/integration): Add entity_selector field used by dynatrace (#124)
1 parent 5512573 commit 5b2e0f4

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

flag_engine/environments/integrations/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
class IntegrationModel:
66
api_key: str = None
77
base_url: str = None
8+
entity_selector: str = None

flag_engine/environments/integrations/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
class IntegrationSchema(LoadToModelSchema):
88
api_key = fields.Str(required=False, allow_none=True)
99
base_url = fields.Str(required=False, allow_none=True)
10+
entity_selector = fields.Str(required=False, allow_none=True)
1011

1112
class Meta:
1213
model_class = IntegrationModel

flag_engine/environments/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ class EnvironmentModel:
4444
segment_config: IntegrationModel = None
4545
mixpanel_config: IntegrationModel = None
4646
heap_config: IntegrationModel = None
47+
dynatrace_config: IntegrationModel = None
4748
webhooks: typing.List[WebhookModel] = field(default_factory=list)
4849

4950
_INTEGRATION_ATTS = [
5051
"amplitude_config",
5152
"segment_config",
5253
"mixpanel_config",
5354
"heap_config",
55+
"dynatrace_config",
5456
"webhooks",
5557
]
5658

@@ -76,5 +78,6 @@ def integrations_data(self) -> dict:
7678
integrations_data[integration_attr] = {
7779
"base_url": integration_config.base_url,
7880
"api_key": integration_config.api_key,
81+
"entity_selector": integration_config.entity_selector,
7982
}
8083
return integrations_data

flag_engine/environments/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class BaseEnvironmentSchema(Schema):
4545
heap_config = fields.Nested(IntegrationSchema, required=False, allow_none=True)
4646
mixpanel_config = fields.Nested(IntegrationSchema, required=False, allow_none=True)
4747
amplitude_config = fields.Nested(IntegrationSchema, required=False, allow_none=True)
48+
dynatrace_config = fields.Nested(IntegrationSchema, required=False, allow_none=True)
4849

4950

5051
class EnvironmentSchema(LoadToModelMixin, BaseEnvironmentSchema):

tests/unit/environments/test_environments_models.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,36 @@ def test_environment_integrations_data_returns_correct_data_when_multiple_integr
7070
):
7171
# Given
7272
example_key = "some-key"
73-
segment_url = "https://api.segment.com"
74-
73+
base_url = "https://some-integration-url"
74+
entity_selector = "some-entity-selector"
75+
environment.dynatrace_config = IntegrationModel(
76+
api_key=example_key,
77+
base_url=base_url,
78+
entity_selector=entity_selector,
79+
)
7580
environment.mixpanel_config = IntegrationModel(api_key=example_key)
7681
environment.segment_config = IntegrationModel(
77-
api_key=example_key, base_url=segment_url
82+
api_key=example_key, base_url=base_url
7883
)
7984

8085
# When
8186
integrations_data = environment.integrations_data
8287

8388
# Then
8489
assert integrations_data == {
85-
"mixpanel_config": {"api_key": example_key, "base_url": None},
86-
"segment_config": {"api_key": example_key, "base_url": segment_url},
90+
"mixpanel_config": {
91+
"api_key": example_key,
92+
"base_url": None,
93+
"entity_selector": None,
94+
},
95+
"segment_config": {
96+
"api_key": example_key,
97+
"base_url": base_url,
98+
"entity_selector": None,
99+
},
100+
"dynatrace_config": {
101+
"api_key": example_key,
102+
"base_url": base_url,
103+
"entity_selector": entity_selector,
104+
},
87105
}

0 commit comments

Comments
 (0)