MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / generate_data

Function generate_data

api/integrations/github/github.py:190–241  ·  view source on GitHub ↗
(
    github_configuration: GithubConfiguration,
    feature: Feature,
    type: str,
    feature_states: (
        typing.Union[list[FeatureState], list[FeatureStateValue]] | None
    ) = None,
    url: str | None = None,
    segment_name: str | None = None,
)

Source from the content-addressed store, hash-verified

188
189
190def generate_data(
191 github_configuration: GithubConfiguration,
192 feature: Feature,
193 type: str,
194 feature_states: (
195 typing.Union[list[FeatureState], list[FeatureStateValue]] | None
196 ) = None,
197 url: str | None = None,
198 segment_name: str | None = None,
199) -> GithubData:
200 feature_states_list = []
201
202 if feature_states:
203 for feature_state in feature_states:
204 feature_state_value = feature_state.get_feature_state_value()
205 feature_env_data = {}
206
207 if check_not_none(feature_state_value):
208 feature_env_data["feature_state_value"] = feature_state_value
209
210 if type is not GitHubEventType.FEATURE_EXTERNAL_RESOURCE_REMOVED.value:
211 feature_env_data["environment_name"] = feature_state.environment.name # type: ignore[union-attr]
212 feature_env_data["enabled"] = feature_state.enabled
213 feature_env_data["last_updated"] = feature_state.updated_at.strftime(
214 get_format("DATETIME_INPUT_FORMATS")[0]
215 )
216 feature_env_data["environment_api_key"] = (
217 feature_state.environment.api_key # type: ignore[union-attr]
218 )
219 if (
220 hasattr(feature_state, "feature_segment")
221 and feature_state.feature_segment is not None
222 ):
223 feature_env_data["segment_name"] = (
224 feature_state.feature_segment.segment.name
225 )
226 feature_states_list.append(feature_env_data)
227
228 return GithubData(
229 feature_id=feature.id,
230 feature_name=feature.name,
231 installation_id=github_configuration.installation_id,
232 type=type,
233 url=(
234 url
235 if type == GitHubEventType.FEATURE_EXTERNAL_RESOURCE_REMOVED.value
236 else None
237 ),
238 feature_states=feature_states_list,
239 project_id=feature.project_id,
240 segment_name=segment_name,
241 )
242
243
244def call_github_task(

Callers 1

call_github_taskFunction · 0.85

Calls 4

GithubDataClass · 0.90
check_not_noneFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…