Skip to content

Commit

Permalink
[EG] Docstring/update changelog (#35108)
Browse files Browse the repository at this point in the history
* nits

* Revert "shorten operation names"

This reverts commit cd37161.

* remove broken link

* edit
  • Loading branch information
l0lawrence committed May 22, 2024
1 parent 9123ac0 commit c1e2e67
Show file tree
Hide file tree
Showing 27 changed files with 84 additions and 86 deletions.
7 changes: 3 additions & 4 deletions sdk/eventgrid/azure-eventgrid/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
- EventGridClient `send` can be used for both Event Grid Namespace Resources and Event Grid Basic Resources.
- Added a kwarg `level` in the EventGridClient constructor. The default value is `Standard` which creates a client for an Event Grid Namespace Resource.

### Breaking Changes

- Removed the `AcknowledgeOptions`,`ReleaseOptions`, `RejectOptions`, and `RenewLockOptions` models. `lock_tokens` can now be specified as a `kwarg` on the operation.
- Renamed `publish_cloud_events` to `send`
### Breaking Changes
- Removed the `AcknowledgeOptions`,`ReleaseOptions`, `RejectOptions`, and `RenewLockOptions` models. `lock_tokens` can now be specified as a `kwarg` on the operation.
- Renamed `publish_cloud_events` to `send`.

## 4.19.0 (2024-04-10)

Expand Down
18 changes: 7 additions & 11 deletions sdk/eventgrid/azure-eventgrid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Azure Event Grid is a fully-managed intelligent event routing service that allow

## _Disclaimer_

This is a beta release of Azure EventGrid's `EventGridClient`. `EventGridClient` supports `send`, `receive`, `acknowledge` , `release`, `reject`, and `renew_locks` operations. Please refer to the [samples](https://github.com/Azure/azure-sdk-for-python/tree/feature/eventgrid/sdk/eventgrid/azure-eventgrid/samples/sync_samples/eventgrid_client_samples) for further information.
This is a beta release of Azure EventGrid's `EventGridClient`. `EventGridClient` supports `send`, `receive_cloud_events`, `acknowledge_cloud_events` , `release_cloud_events`, `reject_cloud_events`, and `renew_cloud_event_locks` operations. Please refer to the [samples](https://github.com/Azure/azure-sdk-for-python/tree/feature/eventgrid/sdk/eventgrid/azure-eventgrid/samples/sync_samples/eventgrid_client_samples) for further information.

## Getting started

Expand Down Expand Up @@ -316,32 +316,32 @@ sub_name = os.environ["EVENTGRID_EVENT_SUBSCRIPTION_NAME"]
credential = AzureKeyCredential(key)
client = EventGridClient(endpoint, credential, level=ClientLevel.STANDARD)

events = client.receive(topic_name, sub_name, max_events=4)
events = client.receive_cloud_events(topic_name, sub_name, max_events=4)

for e in events:
renew_tokens = e.broker_properties.lock_token
renew_result = client.renew_locks(
renew_result = client.renew_cloud_events_lock(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=renew_tokens,
)

release_tokens = events[0].broker_properties.lock_token
release_result = client.release(
release_result = client.release_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=release_tokens,
)

ack_tokens = events[1].broker_properties.lock_token
ack_result = client.acknowledge(
ack_result = client.acknowledge_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=ack_tokens,
)

reject_tokens = events[2].broker_properties.lock_token
reject_result = client.reject(
reject_result = client.reject_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=reject_tokens,
Expand Down Expand Up @@ -459,7 +459,7 @@ These code samples show common champion scenario operations with the Azure Event

#### Namespaces EventGrid Scenarios

* Authenticate the client: [sample_eg_client_authentication.py][python-eg-client-auth-samples]
* Authenticate the client: [sample_authentication.py][python-eg-auth]
* Sample of all operations: [sample_all_operations.py][python-eg-client-all-ops-sample]
* Publish cloud event in binary mode: [sample_binary_mode_operation.py][python-eg-client-binary-mode-sample]

Expand Down Expand Up @@ -541,10 +541,6 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
[python-eg-sample-consume-custom-payload]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_consume_custom_payload.py


[python-eg-client-aad-auth-samples]:https://github.com/Azure/azure-sdk-for-python/blob/feature/eventgrid/sdk/eventgrid/azure-eventgrid/samples/sync_samples/eventgrid_client_samples/sample_aad_auth_operation.py

[python-eg-client-auth-samples]:https://github.com/Azure/azure-sdk-for-python/blob/feature/eventgrid/sdk/eventgrid/azure-eventgrid/samples/sync_samples/eventgrid_client_samples/sample_eg_client_authentication.py

[python-eg-client-all-ops-sample]:https://github.com/Azure/azure-sdk-for-python/blob/feature/eventgrid/sdk/eventgrid/azure-eventgrid/samples/sync_samples/eventgrid_client_samples/sample_all_operations.py

[python-eg-client-binary-mode-sample]:https://github.com/Azure/azure-sdk-for-python/blob/feature/eventgrid/sdk/eventgrid/azure-eventgrid/samples/sync_samples/eventgrid_client_samples/sample_binary_mode.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ def _publish(
http_request.url, **path_format_arguments
)

# pipeline_response: PipelineResponse = self.send_request(http_request, **kwargs)
pipeline_response: PipelineResponse = (
self._client._pipeline.run( # pylint: disable=protected-access
http_request, stream=_stream, **kwargs
Expand Down Expand Up @@ -417,7 +416,7 @@ def _publish(

@use_standard_only
@distributed_trace
def receive(
def receive_cloud_events(
self,
topic_name: str,
subscription_name: str,
Expand Down Expand Up @@ -468,7 +467,7 @@ def receive(

@use_standard_only
@distributed_trace
def acknowledge(
def acknowledge_cloud_events(
self,
topic_name: str,
subscription_name: str,
Expand Down Expand Up @@ -504,7 +503,7 @@ def acknowledge(
@api_version_validation(
params_added_on={"2023-10-01-preview": ["release_delay_in_seconds"]},
)
def release(
def release_cloud_events(
self,
topic_name: str,
subscription_name: str,
Expand Down Expand Up @@ -541,7 +540,7 @@ def release(

@use_standard_only
@distributed_trace
def reject(
def reject_cloud_events(
self,
topic_name: str,
subscription_name: str,
Expand Down Expand Up @@ -576,7 +575,7 @@ def reject(
@api_version_validation(
method_added_on="2023-10-01-preview",
)
def renew_locks(
def renew_cloud_event_locks(
self,
topic_name: str,
subscription_name: str,
Expand Down
5 changes: 4 additions & 1 deletion sdk/eventgrid/azure-eventgrid/azure/eventgrid/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ def __init__(
)

self._send = self._publish_cloud_events

else:
raise ValueError(
"Unknown client level. Known values are `Standard` and `Basic`."
)
self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ async def send(self, *args, **kwargs) -> None:
except Exception as exception: # pylint: disable=broad-except
self._http_response_error_handler(exception, "Standard")
raise exception
# # If that fails, try to send via basic
# self._last_exception = exception
else:
try:
await self._send(events, channel_name=channel_name, **kwargs)
Expand Down Expand Up @@ -248,7 +246,7 @@ def _http_response_error_handler(self, exception, level):

@use_standard_only
@distributed_trace_async
async def receive(
async def receive_cloud_events(
self,
topic_name: str,
subscription_name: str,
Expand Down Expand Up @@ -299,7 +297,7 @@ async def receive(

@use_standard_only
@distributed_trace_async
async def acknowledge(
async def acknowledge_cloud_events(
self,
topic_name: str,
subscription_name: str,
Expand Down Expand Up @@ -332,7 +330,7 @@ async def acknowledge(
@api_version_validation(
params_added_on={"2023-10-01-preview": ["release_delay_in_seconds"]},
)
async def release(
async def release_cloud_events(
self,
topic_name: str,
subscription_name: str,
Expand Down Expand Up @@ -369,7 +367,7 @@ async def release(

@use_standard_only
@distributed_trace_async
async def reject(
async def reject_cloud_events(
self,
topic_name: str,
subscription_name: str,
Expand Down Expand Up @@ -401,7 +399,7 @@ async def reject(
@api_version_validation(
method_added_on="2023-10-01-preview",
)
async def renew_locks(
async def renew_cloud_event_locks(
self,
topic_name: str,
subscription_name: str,
Expand Down
5 changes: 4 additions & 1 deletion sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def __init__(
**kwargs
)
self._send = self._publish_cloud_events

else:
raise ValueError(
"Unknown client level. Known values are `Standard` and `Basic`."
)
self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def run():
try:
async with client:
lock_tokens = ["token"]
ack_events = await client.acknowledge(
ack_events = await client.acknowledge_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=lock_tokens,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def run():

# Receive Published Cloud Events
try:
receive_results = await client.receive(
receive_results = await client.receive_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
max_events=10,
Expand Down Expand Up @@ -95,7 +95,7 @@ async def run():

if len(release_events) > 0:
try:
release_result = await client.release(
release_result = await client.release_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=release_events,
Expand All @@ -108,7 +108,7 @@ async def run():

if len(acknowledge_events) > 0:
try:
ack_result = await client.acknowledge(
ack_result = await client.acknowledge_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=acknowledge_events,
Expand All @@ -121,7 +121,7 @@ async def run():

if len(reject_events) > 0:
try:
reject_result = await client.reject(
reject_result = await client.reject_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=reject_events,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def run():
cloud_event = CloudEvent(data=json.dumps({"hello":"data"}).encode("utf-8"), source="https://example.com", type="example", datacontenttype="application/json")
await client.send(topic_name=TOPIC_NAME, events=cloud_event, binary_mode=True)

receive_result = await client.receive(
receive_result = await client.receive_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
max_events=10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ async def run():
await client.send(topic_name=TOPIC_NAME, events=cloud_event)

# Receive CloudEvents and parse out lock tokens
receive_result = await client.receive(topic_name=TOPIC_NAME, subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=10, max_wait_time=10)
receive_result = await client.receive_cloud_events(topic_name=TOPIC_NAME, 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 lock tokens
renew_events = await client.renew_locks(
renew_events = await client.renew_cloud_event_locks(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=lock_tokens_to_release,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ async def run():
await client.send(topic_name=TOPIC_NAME, events=cloud_event)

# Receive CloudEvents and parse out lock tokens
receive_result = await client.receive(topic_name=TOPIC_NAME, subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=1, max_wait_time=15)
receive_result = await client.receive_cloud_events(topic_name=TOPIC_NAME, 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_events = await client.release(
release_events = await client.release_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
release_delay_in_seconds=60,
Expand All @@ -59,11 +59,11 @@ async def run():
print("Released Event:", release_events)

# Receive CloudEvents again
receive_result = await client.receive(topic_name=TOPIC_NAME, subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=1, max_wait_time=15)
receive_result = await client.receive_cloud_events(topic_name=TOPIC_NAME, subscription_name=EVENT_SUBSCRIPTION_NAME, max_events=1, max_wait_time=15)
print("Received events after release:", receive_result.value)

# Acknowledge a LockToken that was released
acknowledge_events = await client.acknowledge(
acknowledge_events = await client.acknowledge_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=lock_tokens_to_release,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def run():
# Receive CloudEvents
try:
async with client:
receive_result = await client.receive(
receive_result = await client.receive_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
max_events=10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def run():
try:
async with client:
tokens = ["token"]
reject_events = await client.reject(
reject_events = await client.reject_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=tokens,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def run():
try:
async with client:
tokens = ["token"]
release_events = await client.release(
release_events = await client.release_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
release_delay_in_seconds=10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def run():
# Renew a lockToken
try:
lock_tokens = ["token"]
release_events = await client.renew_locks(
release_events = await client.renew_cloud_event_locks(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=lock_tokens,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# Acknowledge a CloudEvent
try:
lock_tokens = ["token"]
ack_events = client.acknowledge(
ack_events = client.acknowledge_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=lock_tokens,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

# Receive Published Cloud Events
try:
receive_results = client.receive(
receive_results = client.receive_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
max_events=10,
Expand Down Expand Up @@ -88,7 +88,7 @@

if len(release_events) > 0:
try:
release_result = client.release(
release_result = client.release_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=release_events,
Expand All @@ -101,7 +101,7 @@

if len(acknowledge_events) > 0:
try:
ack_result = client.acknowledge(
ack_result = client.acknowledge_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=acknowledge_events,
Expand All @@ -114,7 +114,7 @@

if len(reject_events) > 0:
try:
reject_result = client.reject(
reject_result = client.reject_cloud_events(
topic_name=TOPIC_NAME,
subscription_name=EVENT_SUBSCRIPTION_NAME,
lock_tokens=reject_events,
Expand Down
Loading

0 comments on commit c1e2e67

Please sign in to comment.