File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
sdk/eventgrid/azure-eventgrid/samples/sync_samples/eventgrid_client_samples Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ # --------------------------------------------------------------------------
2+ # Copyright (c) Microsoft Corporation. All rights reserved.
3+ # Licensed under the MIT License. See License.txt in the project root for
4+ # license information.
5+ # --------------------------------------------------------------------------
6+ import os
7+ from azure .eventgrid import EventGridClient
8+ from azure .eventgrid .models import *
9+ from azure .identity import DefaultAzureCredential
10+
11+ EVENTGRID_ENDPOINT : str = os .environ ["EVENTGRID_ENDPOINT" ]
12+
13+ # Create a client using DefaultAzureCredential
14+ client = EventGridClient (EVENTGRID_ENDPOINT , DefaultAzureCredential ())
Original file line number Diff line number Diff line change 1+ # --------------------------------------------------------------------------
2+ # Copyright (c) Microsoft Corporation. All rights reserved.
3+ # Licensed under the MIT License. See License.txt in the project root for
4+ # license information.
5+ # --------------------------------------------------------------------------
6+ import os
7+ from azure .core .credentials import AzureKeyCredential
8+ from azure .eventgrid import EventGridClient
9+ from azure .eventgrid .models import *
10+ from azure .core .exceptions import HttpResponseError
11+
12+ EVENTGRID_KEY : str = os .environ ["EVENTGRID_KEY" ]
13+ EVENTGRID_ENDPOINT : str = os .environ ["EVENTGRID_ENDPOINT" ]
14+ TOPIC_NAME : str = os .environ ["EVENTGRID_TOPIC_NAME" ]
15+ EVENT_SUBSCRIPTION_NAME : str = os .environ ["EVENTGRID_EVENT_SUBSCRIPTION_NAME" ]
16+
17+ # Create a client
18+ client = EventGridClient (EVENTGRID_ENDPOINT , AzureKeyCredential (EVENTGRID_KEY ))
19+
20+ # Renew a lockToken
21+ try :
22+ lock_tokens = RenewLockOptions (lock_tokens = ["token" ])
23+ release_events = client .renew_cloud_event_locks (
24+ topic_name = TOPIC_NAME ,
25+ event_subscription_name = EVENT_SUBSCRIPTION_NAME ,
26+ renew_lock_options = lock_tokens ,
27+ )
28+ print (release_events )
29+ except HttpResponseError :
30+ raise
You can’t perform that action at this time.
0 commit comments