Skip to content

Commit

Permalink
feat(python): updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
v.kozyar committed Feb 22, 2024
1 parent 5116e7f commit aa33c65
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 8 deletions.
51 changes: 51 additions & 0 deletions flipt-python/example/async_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import asyncio

from flipt import AsyncFliptClient
from flipt.evaluation import BatchEvaluationRequest, EvaluationRequest


async def main():
flipt_client = AsyncFliptClient()

variant_flag = await flipt_client.evaluation.variant(
EvaluationRequest(
namespace_key="default",
flag_key="flag1",
entity_id="entity",
context={"fizz": "buzz"},
)
)
boolean_flag = await flipt_client.evaluation.boolean(
EvaluationRequest(
namespace_key="default",
flag_key="flag_boolean",
entity_id="entity",
context={"fizz": "buzz"},
)
)
batch = await flipt_client.evaluation.batch(
BatchEvaluationRequest(
requests=[
EvaluationRequest(
namespace_key="default",
flag_key="flag1",
entity_id="entity",
context={"fizz": "buzz"},
),
EvaluationRequest(
namespace_key="default",
flag_key="flag_boolean",
entity_id="entity",
context={"fizz": "buzz"},
),
]
)
)

print(variant_flag)
print(boolean_flag)
print(batch)


loop = asyncio.new_event_loop()
loop.run_until_complete(main())
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
from flipt import FliptClient
from flipt.evaluation import BatchEvaluationRequest, EvaluationRequest

fliptClient = FliptClient()
flipt_client = FliptClient()

v = fliptClient.evaluation.variant(
variant_flag = flipt_client.evaluation.variant(
EvaluationRequest(
namespace_key="default",
flag_key="flagll",
flag_key="flag1",
entity_id="entity",
context={"fizz": "buzz"},
)
)
b = fliptClient.evaluation.boolean(
boolean_flag = flipt_client.evaluation.boolean(
EvaluationRequest(
namespace_key="default",
flag_key="flag_boolean",
entity_id="entity",
context={"fizz": "buzz"},
)
)
ba = fliptClient.evaluation.batch(
batch = flipt_client.evaluation.batch(
BatchEvaluationRequest(
requests=[
EvaluationRequest(
Expand All @@ -38,6 +38,6 @@
)
)

print(v)
print(b)
print(ba)
print(variant_flag)
print(boolean_flag)
print(batch)

0 comments on commit aa33c65

Please sign in to comment.