Skip to content

Commit

Permalink
move samples (#35966)
Browse files Browse the repository at this point in the history
* sample

* readme updates

* links

* delete duplicates

* doc updates

* plural
  • Loading branch information
l0lawrence authored Jun 11, 2024
1 parent 10c3c79 commit 433b99a
Show file tree
Hide file tree
Showing 56 changed files with 615 additions and 171 deletions.
68 changes: 43 additions & 25 deletions sdk/eventgrid/azure-eventgrid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This is a GA release of Azure Event Grid's `EventGridPublisherClient` and `Event
### Event Grid Resources

Azure Event Grid Namespaces supports both pull and push delivery. Azure Event Grid Basic supports only push delivery.
More information on the two resource types can be found [here](https://learn.microsoft.com/azure/event-grid/choose-right-tier).
More information on the two resource tiers can be found [here](https://learn.microsoft.com/azure/event-grid/choose-right-tier).

**Note:** Azure Event Grid Namespaces only supports the Cloud Event v1.0 Schema.

Expand Down Expand Up @@ -401,7 +401,14 @@ The following section provides several code snippets illustrating common pattern

These code samples show common champion scenario operations with the Azure Event Grid client library.

#### Basic Event Grid Scenarios
#### Additional Namespace Event Grid Scenarios

* Authenticate the client: [sample_namespace_authentication_async.py][python-eg-namespace-authenticate-async]
* Publish to the namespace topic: [sample_publish_cloud_event_async.py][python-eg-namespace-publish-cloud-async]
* Consume and Process from an event subscription: [sample_consume_process_events.py][python-eg-namespace-consume-async]


#### Additional Basic Event Grid Scenarios

* Generate Shared Access Signature: [sample_generate_sas.py][python-eg-generate-sas]

Expand Down Expand Up @@ -455,29 +462,40 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
[azure_core_ref_docs]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/core/azure-core#configurations
[azure_subscription]: https://azure.microsoft.com/free/

[python-eg-auth]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_authentication.py
[python-eg-generate-sas]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_generate_sas.py
[python-eg-sample-send-using-sas]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_publish_events_to_a_topic_using_sas_credential.py
[python-eg-sample-eg-event]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_publish_eg_events_to_a_topic.py
[python-eg-sample-eg-event-to-domain]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_publish_eg_events_to_a_domain.py
[python-eg-sample-send-cloudevent]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_publish_events_using_cloud_events_1.0_schema.py
[python-eg-publish-custom-schema]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_publish_custom_schema_to_a_topic.py
[python-eg-sample-send-eg-as-dict]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_publish_eg_event_using_dict.py
[python-eg-sample-send-cloudevent-as-dict]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_publish_cloud_event_using_dict.py

[python-eg-auth-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/async_samples/sample_authentication_async.py
[python-eg-sample-send-using-sas-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/async_samples/sample_publish_events_to_a_topic_using_sas_credential_async.py
[python-eg-sample-eg-event-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/async_samples/sample_publish_eg_events_to_a_topic_async.py
[python-eg-sample-eg-event-to-domain-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/async_samples/sample_publish_eg_events_to_a_domain_async.py
[python-eg-sample-send-cloudevent-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/async_samples/sample_publish_events_using_cloud_events_1.0_schema_async.py
[python-eg-publish-custom-schema-async]:https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/async_samples/sample_publish_custom_schema_to_a_topic_async.py
[python-eg-sample-send-eg-as-dict-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/async_samples/sample_publish_eg_event_using_dict_async.py
[python-eg-sample-send-cloudevent-as-dict-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/async_samples/sample_publish_cloud_event_using_dict_async.py

[python-eg-publish-samples]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/publish_samples
[python-eg-consume-samples]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/consume_samples
[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-auth]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/sync_samples/sample_authentication.py
[python-eg-generate-sas]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/sync_samples/sample_generate_sas.py
[python-eg-sample-send-using-sas]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/sync_samples/sample_publish_events_to_a_topic_using_sas_credential.py
[python-eg-sample-eg-event]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/sync_samples/sample_publish_eg_events_to_a_topic.py
[python-eg-sample-eg-event-to-domain]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/sync_samples/sample_publish_eg_events_to_a_domain.py
[python-eg-sample-send-cloudevent]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/sync_samples/sample_publish_events_using_cloud_events_1.0_schema.py
[python-eg-publish-custom-schema]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/sync_samples/sample_publish_custom_schema_to_a_topic.py
[python-eg-sample-send-eg-as-dict]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/sync_samples/sample_publish_eg_event_using_dict.py
[python-eg-sample-send-cloudevent-as-dict]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/sync_samples/sample_publish_cloud_event_using_dict.py

[python-eg-auth-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/async_samples/sample_authentication_async.py
[python-eg-sample-send-using-sas-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/async_samples/sample_publish_events_to_a_topic_using_sas_credential_async.py
[python-eg-sample-eg-event-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/async_samples/sample_publish_eg_events_to_a_topic_async.py
[python-eg-sample-eg-event-to-domain-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/async_samples/sample_publish_eg_events_to_a_domain_async.py
[python-eg-sample-send-cloudevent-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/async_samples/sample_publish_events_using_cloud_events_1.0_schema_async.py
[python-eg-publish-custom-schema-async]:https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/async_samples/sample_publish_custom_schema_to_a_topic_async.py
[python-eg-sample-send-eg-as-dict-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/async_samples/sample_publish_eg_event_using_dict_async.py
[python-eg-sample-send-cloudevent-as-dict-async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/async_samples/sample_publish_cloud_event_using_dict_async.py

[python-eg-publish-samples]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/publish_samples
[python-eg-consume-samples]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/consume_samples
[python-eg-sample-consume-custom-payload]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/basic/sync_samples/sample_consume_custom_payload.py


[python-eg-namespace-authenticate]:https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/namespace/sync_samples/sample_namespace_authentication.py
[python-eg-namespace-publish-cncf]:https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/namespace/sync_samples/sample_publish_cncf_events.py
[python-eg-namespace-publish-cloud]:https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/namespace/sync_samples/sample_publish_cloud_event.py
[python-eg-namespace-consume]:https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/namespace/samples/sync_samples/sample_consume_process_events.py


[python-eg-namespace-authenticate-async]:https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/namespace/async_samples/sample_namespace_authentication_async.py
[python-eg-namespace-publish-cncf-async]:https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/namespace/async_samples/sample_publish_cncf_events_async.py
[python-eg-namespace-publish-cloud-async]:https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/namespace/async_samples/sample_publish_cloud_event_async.py
[python-eg-namespace-consume-async]:https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventgrid/azure-eventgrid/samples/namespace/async_samples/sample_consume_process_events_async.py

[cla]: https://cla.microsoft.com
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def send(
) -> None: # pylint: disable=docstring-should-be-keyword, docstring-missing-param
"""Send events to the Event Grid Service.
:param events: The event(s) to send. If sending to an Event Grid Namespace, the dict or list of dicts
should be in the format of a CloudEvent.
:param events: The event(s) to send. If sending to an Event Grid Namespace, the dict, list of dicts,
or event(s) should be in the format of a CloudEvent.
:type events: CloudEvent or List[CloudEvent] or Dict[str, Any] or List[Dict[str, Any]]
or CNCFCloudEvent or List[CNCFCloudEvent] or EventGridEvent or List[EventGridEvent]
:keyword channel_name: The name of the channel to send the event to. Event Grid Basic Resource only.
Expand Down Expand Up @@ -154,15 +154,15 @@ def receive(
"""Receive Batch of Cloud Events from the Event Subscription.
:keyword max_events: Max Events count to be received. Minimum value is 1, while maximum value
is 100 events. If not specified, the default value is 1. Default value is None.
is 100 events. The default is None, meaning it will receive one event if available.
:paramtype max_events: int
:keyword max_wait_time: Max wait time value for receive operation in Seconds. It is the time in
seconds that the server approximately waits for the availability of an event and responds to
the request. If an event is available, the broker responds immediately to the client. Minimum
value is 10 seconds, while maximum value is 120 seconds. If not specified, the default value is
60 seconds. Default value is None.
value is 10 seconds, while maximum value is 120 seconds. The default value is None, meaning it
will wait for 60 seconds.
:paramtype max_wait_time: int
:return: Receive Details.
:return: ReceiveDetails list of received events and their broker properties.
:rtype: list[~azure.eventgrid.models.ReceiveDetails]
:raises ~azure.core.exceptions.HttpResponseError:
"""
Expand Down
13 changes: 7 additions & 6 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EventGridPublisherClient(InternalEventGridPublisherClient):
"""EventGridPublisherClient.
Sends events to a basic topic, basic domain, or a namespace topic
specified during the client initialization.
specified during the client initialization.
A single instance or a list of dictionaries, CloudEvents or EventGridEvents are accepted.
If a list is provided, the list must contain only one type of event.
Expand All @@ -44,10 +44,11 @@ class EventGridPublisherClient(InternalEventGridPublisherClient):
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword namespace_topic: The name of the topic to publish events to. Required for EventGrid Namespaces.
Default value is None, which is used for EventGrid Basic.
:keyword namespace_topic: The name of the topic to publish events to. Required for Event Grid Namespaces.
Default value is None, which is used for Event Grid Basic.
:paramtype namespace_topic: str or None
:keyword api_version: The API version to use for this operation. Default value is "2024-06-01".
:keyword api_version: The API version to use for this operation. Default value for Event Grid Namespace
is "2024-06-01", default value for Event Grid Basic is "2018-01-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""
Expand Down Expand Up @@ -96,7 +97,7 @@ class EventGridConsumerClient(InternalEventGridConsumerClient):
"""EventGridConsumerClient.
Consumes and manages events from a namespace topic
and event subscription specified during the client initialization.
and event subscription specified during the client initialization.
:param endpoint: The host name of the namespace, e.g.
namespaceName1.westus-1.eventgrid.azure.net. Required.
Expand All @@ -107,7 +108,7 @@ class EventGridConsumerClient(InternalEventGridConsumerClient):
~azure.core.credentials.TokenCredential
:keyword namespace_topic: The name of the topic to consume events from. Required.
:paramtype namespace_topic: str
:subscription: The name of the subscription to consume events from. Required.
:keyword subscription: The name of the subscription to consume events from. Required.
:paramtype subscription: str
:keyword api_version: The API version to use for this operation. Default value is "2024-06-01".
Note that overriding this default value may result in unsupported behavior.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ async def send(
) -> None: # pylint: disable=docstring-should-be-keyword, docstring-missing-param
"""Send events to the Event Grid Service.
:param events: The event(s) to send. If sending to an Event Grid Namespace, the dict or list of dicts
should be in the format of a CloudEvent.
:param events: The event(s) to send. If sending to an Event Grid Namespace, the dict, list of dicts,
or event(s) should be in the format of a CloudEvent.
:type events: CloudEvent or List[CloudEvent] or Dict[str, Any] or List[Dict[str, Any]]
or CNCFCloudEvent or List[CNCFCloudEvent] or EventGridEvent or List[EventGridEvent]
:keyword channel_name: The name of the channel to send the event to. Event Grid Basic Resource only.
Expand Down Expand Up @@ -138,15 +138,15 @@ async def receive(
"""Receive Batch of Cloud Events from the Event Subscription.
:keyword max_events: Max Events count to be received. Minimum value is 1, while maximum value
is 100 events. If not specified, the default value is 1. Default value is None.
is 100 events. The default is None, meaning it will receive one event if available.
:paramtype max_events: int
:keyword max_wait_time: Max wait time value for receive operation in Seconds. It is the time in
seconds that the server approximately waits for the availability of an event and responds to
the request. If an event is available, the broker responds immediately to the client. Minimum
value is 10 seconds, while maximum value is 120 seconds. If not specified, the default value is
60 seconds. Default value is None.
value is 10 seconds, while maximum value is 120 seconds. The default value is None, meaning it
will wait for 60 seconds.
:paramtype max_wait_time: int
:return: ReceiveDetails
:return: ReceiveDetails list of received events and their broker properties.
:rtype: list[~azure.eventgrid.models.ReceiveDetails]
:raises ~azure.core.exceptions.HttpResponseError:
"""
Expand Down
13 changes: 7 additions & 6 deletions sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EventGridPublisherClient(InternalEventGridPublisherClient):
"""EventGridPublisherClient.
Sends events to a basic topic, basic domain, or a namespace topic
specified during the client initialization.
specified during the client initialization.
A single instance or a list of dictionaries, CloudEvents or EventGridEvents are accepted.
If a list is provided, the list must contain only one type of event.
Expand All @@ -44,10 +44,11 @@ class EventGridPublisherClient(InternalEventGridPublisherClient):
AzureKeyCredential type or a AsyncTokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials_async.AsyncTokenCredential
:keyword namespace_topic: The name of the topic to publish events to. Required for EventGrid Namespaces.
Default value is None, which is used for EventGrid Basic.
:keyword namespace_topic: The name of the topic to publish events to. Required for Event Grid Namespaces.
Default value is None, which is used for Event Grid Basic.
:paramtype namespace_topic: str or None
:keyword api_version: The API version to use for this operation. Default value is "2024-06-01".
:keyword api_version: The API version to use for this operation. Default value for Event Grid Namespace
is "2024-06-01", default value for Event Grid Basic is "2018-01-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""
Expand Down Expand Up @@ -94,7 +95,7 @@ class EventGridConsumerClient(InternalEventGridConsumerClient):
"""EventGridConsumerClient.
Consumes and manages events from a namespace topic
and event subscription specified during the client initialization.
and event subscription specified during the client initialization.
:param endpoint: The host name of the namespace, e.g.
namespaceName1.westus-1.eventgrid.azure.net. Required.
Expand All @@ -105,7 +106,7 @@ class EventGridConsumerClient(InternalEventGridConsumerClient):
~azure.core.credentials_async.AsyncTokenCredential
:keyword namespace_topic: The name of the topic to consume events from. Required.
:paramtype namespace_topic: str
:subscription: The name of the subscription to consume events from. Required.
:keyword subscription: The name of the subscription to consume events from. Required.
:paramtype subscription: str
:keyword api_version: The API version to use for this operation. Default value is "2024-06-01".
Note that overriding this default value may result in unsupported behavior.
Expand Down
Loading

0 comments on commit 433b99a

Please sign in to comment.