Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a366776
Beta LiveTests (#30728)
l0lawrence Aug 25, 2023
835aa5f
[EGv2] Binary mode (#32922)
l0lawrence Nov 3, 2023
f7c1d1f
[EGv2] Build Release (#30325)
l0lawrence May 19, 2023
4f00208
Beta LiveTests (#30728)
l0lawrence Aug 25, 2023
cfcf881
regen
l0lawrence Oct 31, 2023
3bb49cf
new api version
l0lawrence Oct 31, 2023
921ad51
samples for new features
l0lawrence Oct 31, 2023
af75e64
update test-resources.json
l0lawrence Oct 31, 2023
f491579
update operation samples
l0lawrence Oct 31, 2023
851d112
add samples
l0lawrence Nov 1, 2023
052f431
more sample
l0lawrence Nov 1, 2023
7e52f8c
update tests
l0lawrence Nov 2, 2023
9299c34
add mros
l0lawrence Nov 2, 2023
8b4261d
gen
l0lawrence Nov 2, 2023
657d2de
fix changelog
l0lawrence Nov 3, 2023
af257bf
update tests
l0lawrence Nov 3, 2023
2658379
update preparer
l0lawrence Nov 3, 2023
560e961
point at canary until release
l0lawrence Nov 3, 2023
bdcbb01
update test deployment area
l0lawrence Nov 3, 2023
003ee06
update
l0lawrence Nov 3, 2023
1004f8c
add
l0lawrence Nov 3, 2023
8f7cf6c
try this tests
l0lawrence Nov 5, 2023
a22d999
update samples
l0lawrence Nov 5, 2023
6ae5fd3
livetest mark
l0lawrence Nov 5, 2023
0a509c3
update tests
l0lawrence Nov 5, 2023
22677cd
eastus working?
l0lawrence Nov 5, 2023
64faa0d
regen - removed azure refs in gen code
l0lawrence Nov 6, 2023
a003a09
update comments
l0lawrence Nov 6, 2023
d012ab1
add other sample
l0lawrence Nov 6, 2023
d3291b2
update
l0lawrence Nov 6, 2023
aaa8629
remove stream - no response
l0lawrence Nov 7, 2023
c3dd323
update version and date for release
l0lawrence Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update samples
  • Loading branch information
l0lawrence committed Nov 8, 2023
commit a22d9990be9e8bb4cfe738b20b7b82e976768106
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import os
import asyncio
from azure.core.credentials import AzureKeyCredential
from azure.eventgrid.aio import EventGridClient
from azure.eventgrid.models import *
from azure.core.messaging import CloudEvent
from azure.core.exceptions import HttpResponseError


EVENTGRID_KEY: str = os.environ["EVENTGRID_KEY"]
EVENTGRID_ENDPOINT: str = os.environ["EVENTGRID_ENDPOINT"]
TOPIC_NAME: str = os.environ["EVENTGRID_TOPIC_NAME"]
EVENT_SUBSCRIPTION_NAME: str = os.environ["EVENTGRID_EVENT_SUBSCRIPTION_NAME"]


async def run():
# Create a client
client = EventGridClient(EVENTGRID_ENDPOINT, AzureKeyCredential(EVENTGRID_KEY))

async with client:
# Publish a CloudEvent
try:
cloud_event = CloudEvent(data="hello", source="https://example.com", type="example")
await client.publish_cloud_events(topic_name=TOPIC_NAME, body=cloud_event)

receive_result = await client.receive_cloud_events(topic_name=TOPIC_NAME, event_subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=10, max_wait_time=10)
lock_tokens_to_release = []
for item in receive_result.value:
lock_tokens_to_release.append(item.broker_properties.lock_token)


# Renew a lock token
lock_tokens = RenewLockOptions(lock_tokens=lock_tokens_to_release)
renew_events = await client.renew_cloud_event_locks(
topic_name=TOPIC_NAME,
event_subscription_name=EVENT_SUBSCRIPTION_NAME,
renew_lock_options=lock_tokens,
)
print("Renewed Event:", renew_events)
except HttpResponseError:
raise

if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(run())
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import os
import asyncio
from azure.core.credentials import AzureKeyCredential
from azure.eventgrid.aio import EventGridClient
from azure.eventgrid.models import *
from azure.core.messaging import CloudEvent
from azure.core.exceptions import HttpResponseError


EVENTGRID_KEY: str = os.environ["EVENTGRID_KEY"]
EVENTGRID_ENDPOINT: str = os.environ["EVENTGRID_ENDPOINT"]
TOPIC_NAME: str = os.environ["EVENTGRID_TOPIC_NAME"]
EVENT_SUBSCRIPTION_NAME: str = os.environ["EVENTGRID_EVENT_SUBSCRIPTION_NAME"]


async def run():
# Create a client
client = EventGridClient(EVENTGRID_ENDPOINT, AzureKeyCredential(EVENTGRID_KEY))

async with client:
# Publish a CloudEvent
try:
cloud_event = CloudEvent(data="hello", source="https://example.com", type="example")
await client.publish_cloud_events(topic_name=TOPIC_NAME, body=cloud_event)

receive_result = await client.receive_cloud_events(topic_name=TOPIC_NAME, event_subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=1, max_wait_time=15)
lock_tokens_to_release = []
for item in receive_result.value:
lock_tokens_to_release.append(item.broker_properties.lock_token)

print("Received events:", receive_result.value)

# Release a LockToken
release_token = ReleaseOptions(lock_tokens=lock_tokens_to_release)
release_events = await client.release_cloud_events(
topic_name=TOPIC_NAME,
event_subscription_name=EVENT_SUBSCRIPTION_NAME,
release_delay_in_seconds=60,
release_options=release_token,
)
print("Released Event:", release_events)


receive_result = await client.receive_cloud_events(topic_name=TOPIC_NAME, event_subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=1, max_wait_time=15)
print("Received events after release:", receive_result.value)

# Acknowledge a LockToken
acknowledge_token = AcknowledgeOptions(lock_tokens=lock_tokens_to_release)
acknowledge_events = await client.acknowledge_cloud_events(
topic_name=TOPIC_NAME,
event_subscription_name=EVENT_SUBSCRIPTION_NAME,
acknowledge_options=acknowledge_token,
)
print("Acknowledged events after release:", acknowledge_events)
except HttpResponseError:
raise

if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(run())
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
cloud_event = CloudEvent(data="hello", source="https://example.com", type="example")
client.publish_cloud_events(topic_name=TOPIC_NAME, body=cloud_event)

receive_result = client.receive_cloud_events(topic_name=TOPIC_NAME, event_subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=1, max_wait_time=5)
receive_result = client.receive_cloud_events(topic_name=TOPIC_NAME, event_subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=1, max_wait_time=15)
lock_tokens_to_release = []
for item in receive_result.value:
lock_tokens_to_release.append(item.broker_properties.lock_token)
Expand All @@ -43,7 +43,7 @@
print("Released Event:", release_events)


receive_result = client.receive_cloud_events(topic_name=TOPIC_NAME, event_subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=1, max_wait_time=5)
receive_result = client.receive_cloud_events(topic_name=TOPIC_NAME, event_subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=1, max_wait_time=15)
print("Received events after release:", receive_result.value)

# Acknowledge a LockToken
Expand Down