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

Function generate_environment_sample_webhook_data

api/webhooks/webhooks.py:339–393  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

337
338
339def generate_environment_sample_webhook_data() -> dict[str, Any]:
340 project = Project(id=1, name="Test Project", organisation_id=1)
341
342 environment = Environment(id=1, name="Development", project=project)
343
344 feature = Feature(
345 id=1,
346 name="test_feature",
347 project=project,
348 description="This is a description",
349 default_enabled=False,
350 type="CONFIG",
351 initial_value=None,
352 created_date=datetime.fromisoformat(
353 "2021-02-10T20:03:43.348556Z".replace("Z", "+00:00")
354 ),
355 )
356
357 mv_option = MultivariateFeatureOption(
358 id=1,
359 feature=feature,
360 default_percentage_allocation=50,
361 type="unicode",
362 string_value="variant_a",
363 )
364 mv_state_value = MultivariateFeatureStateValue(
365 id=1,
366 multivariate_feature_option=mv_option,
367 percentage_allocation=50,
368 )
369
370 data = {
371 "changed_by": "user@domain.com",
372 "timestamp": "2021-06-18T07:50:26.595298Z",
373 "new_state": Webhook.generate_webhook_feature_state_data(
374 feature=feature,
375 environment=environment,
376 enabled=True,
377 value="feature_state_value",
378 identity_id=1,
379 identity_identifier="test_identity",
380 multivariate_feature_state_values=[mv_state_value],
381 ),
382 "previous_state": Webhook.generate_webhook_feature_state_data(
383 feature=feature,
384 environment=environment,
385 enabled=False,
386 value="old_feature_state_value",
387 identity_id=1,
388 identity_identifier="test_identity",
389 multivariate_feature_state_values=[mv_state_value],
390 ),
391 }
392
393 return {"data": data, "event_type": WebhookEventType.FLAG_UPDATED.value}
394
395
396def generate_organisation_sample_webhook_data() -> dict[str, Any]:

Calls 6

ProjectClass · 0.90
EnvironmentClass · 0.90
FeatureClass · 0.90

Used in the wild real call sites across dependent graphs

searching dependent graphs…