Skip to content

Commit

Permalink
Enable AAD auth for EventGridPublisherClient (#22587)
Browse files Browse the repository at this point in the history
* Enable AAD auth for EventGridPublisherClient

* Export API

* Fix API link

* remove locale

* Regenerate system events.

* Fix version
  • Loading branch information
JoshLove-msft authored Jul 16, 2021
1 parent 51212bb commit 3b0d98e
Show file tree
Hide file tree
Showing 25 changed files with 674 additions and 129 deletions.
12 changes: 4 additions & 8 deletions sdk/eventgrid/Azure.Messaging.EventGrid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# Release History

## 4.5.0-beta.1 (Unreleased)
## 4.5.0 (2021-07-19)

### Features Added

### Breaking Changes

### Key Bugs Fixed

### Fixed

- Added constructor for `EventGridPublisherClient` that takes a `TokenCredential` to enable Azure Active Directory authentication.
- Added `Metadata` property to `AcsChatMessageEditedEventData`, `AcsChatMessageEditedInThreadEventData`, `AcsChatMessageReceivedEventData`, and `AcsChatMessageReceivedInThreadEventData`.
- Added custom converter for `EventGridEvent` that allows this type to be serialized and deserialized using `System.Text.Json` APIs.

## 4.4.0 (2021-06-21)

Expand Down
2 changes: 1 addition & 1 deletion sdk/eventgrid/Azure.Messaging.EventGrid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Use the client library for Azure Event Grid to:
- Consume events that have been delivered to event handlers
- Generate SAS tokens to authenticate the client publishing events to Azure Event Grid topics

[Source code](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/eventgrid/Azure.Messaging.EventGrid/src) | [Package (NuGet)](https://www.nuget.org/packages/Azure.Messaging.EventGrid/) | [API reference documentation](https://azure.github.io/azure-sdk-for-net/eventgrid.html) | [Product documentation](https://docs.microsoft.com/azure/event-grid/) | [Samples](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventgrid/Azure.Messaging.EventGrid/samples) | [Migration guide](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventgrid/Azure.Messaging.EventGrid/MigrationGuide.md)
[Source code](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/eventgrid/Azure.Messaging.EventGrid/src) | [Package (NuGet)](https://www.nuget.org/packages/Azure.Messaging.EventGrid/) | [API reference documentation](https://docs.microsoft.com/dotnet/api/azure.messaging.eventgrid) | [Product documentation](https://docs.microsoft.com/azure/event-grid/) | [Samples](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventgrid/Azure.Messaging.EventGrid/samples) | [Migration guide](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventgrid/Azure.Messaging.EventGrid/MigrationGuide.md)

## Getting started

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>This library can be used to publish events to Azure Event Grid and to consume events delivered by EventGrid. It also defines the event schemas for the events published to EventGrid by various Azure services.</Description>
<AssemblyTitle>Microsoft Azure.Messaging.EventGrid client library</AssemblyTitle>
<Version>4.5.0-beta.1</Version>
<Version>4.5.0</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>4.4.0</ApiCompatVersion>
<PackageTags>Microsoft Azure EventGrid;Event Grid;Event Grid Publishing;</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public static AcsChatThreadCreatedEventData AcsChatThreadCreatedEventData(string
/// <param name="receivedTimestamp"> The time at which the SMS delivery report was received. </param>
/// <param name="tag"> Customer Content. </param>
/// <returns> A new <see cref="SystemEvents.AcsSmsDeliveryReportReceivedEventData"/> instance for mocking. </returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static AcsSmsDeliveryReportReceivedEventData AcsSmsDeliveryReportReceivedEventData(string messageId = default, string @from = default, string to = default, string deliveryStatus = default, string deliveryStatusDetails = default, IReadOnlyList<AcsSmsDeliveryAttemptProperties> deliveryAttempts = default, DateTimeOffset? receivedTimestamp = default, string tag = default)
{
deliveryAttempts ??= new List<AcsSmsDeliveryAttemptProperties>();
Expand All @@ -139,6 +140,7 @@ public static AcsSmsDeliveryReportReceivedEventData AcsSmsDeliveryReportReceived
/// <summary> Initializes new instance of AcsRecordingStorageInfoProperties class. </summary>
/// <param name="recordingChunks"> List of details of recording chunks information. </param>
/// <returns> A new <see cref="SystemEvents.AcsRecordingStorageInfoProperties"/> instance for mocking. </returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static AcsRecordingStorageInfoProperties AcsRecordingStorageInfoProperties(IReadOnlyList<AcsRecordingChunkInfoProperties> recordingChunks = default)
{
recordingChunks ??= new List<AcsRecordingChunkInfoProperties>();
Expand Down Expand Up @@ -315,6 +317,78 @@ public static SubscriptionValidationResponse SubscriptionValidationResponse(stri
{
return new(validationResponse);
}

/// <summary> Initializes a new instance of AcsChatMessageReceivedEventData. </summary>
/// <param name="recipientCommunicationIdentifier"> The communication identifier of the target user. </param>
/// <param name="transactionId"> The transaction id will be used as co-relation vector. </param>
/// <param name="threadId"> The chat thread id. </param>
/// <param name="messageId"> The chat message id. </param>
/// <param name="senderCommunicationIdentifier"> The communication identifier of the sender. </param>
/// <param name="senderDisplayName"> The display name of the sender. </param>
/// <param name="composeTime"> The original compose time of the message. </param>
/// <param name="type"> The type of the message. </param>
/// <param name="version"> The version of the message. </param>
/// <param name="messageBody"> The body of the chat message. </param>
/// <returns> A new <see cref="SystemEvents.AcsChatMessageReceivedEventData"/> instance for mocking. </returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static AcsChatMessageReceivedEventData AcsChatMessageReceivedEventData(CommunicationIdentifierModel recipientCommunicationIdentifier = null, string transactionId = null, string threadId = null, string messageId = null, CommunicationIdentifierModel senderCommunicationIdentifier = null, string senderDisplayName = null, DateTimeOffset? composeTime = null, string type = null, long? version = null, string messageBody = null)
{
return new AcsChatMessageReceivedEventData(recipientCommunicationIdentifier, transactionId, threadId, messageId, senderCommunicationIdentifier, senderDisplayName, composeTime, type, version, messageBody, new ChangeTrackingDictionary<string, string>());
}

/// <summary> Initializes a new instance of AcsChatMessageReceivedInThreadEventData. </summary>
/// <param name="transactionId"> The transaction id will be used as co-relation vector. </param>
/// <param name="threadId"> The chat thread id. </param>
/// <param name="messageId"> The chat message id. </param>
/// <param name="senderCommunicationIdentifier"> The communication identifier of the sender. </param>
/// <param name="senderDisplayName"> The display name of the sender. </param>
/// <param name="composeTime"> The original compose time of the message. </param>
/// <param name="type"> The type of the message. </param>
/// <param name="version"> The version of the message. </param>
/// <param name="messageBody"> The body of the chat message. </param>
/// <returns> A new <see cref="SystemEvents.AcsChatMessageReceivedInThreadEventData"/> instance for mocking. </returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static AcsChatMessageReceivedInThreadEventData AcsChatMessageReceivedInThreadEventData(string transactionId = null, string threadId = null, string messageId = null, CommunicationIdentifierModel senderCommunicationIdentifier = null, string senderDisplayName = null, DateTimeOffset? composeTime = null, string type = null, long? version = null, string messageBody = null)
{
return new AcsChatMessageReceivedInThreadEventData(transactionId, threadId, messageId, senderCommunicationIdentifier, senderDisplayName, composeTime, type, version, messageBody, new ChangeTrackingDictionary<string, string>());
}

/// <summary> Initializes a new instance of AcsChatMessageEditedEventData. </summary>
/// <param name="recipientCommunicationIdentifier"> The communication identifier of the target user. </param>
/// <param name="transactionId"> The transaction id will be used as co-relation vector. </param>
/// <param name="threadId"> The chat thread id. </param>
/// <param name="messageId"> The chat message id. </param>
/// <param name="senderCommunicationIdentifier"> The communication identifier of the sender. </param>
/// <param name="senderDisplayName"> The display name of the sender. </param>
/// <param name="composeTime"> The original compose time of the message. </param>
/// <param name="type"> The type of the message. </param>
/// <param name="version"> The version of the message. </param>
/// <param name="messageBody"> The body of the chat message. </param>
/// <param name="editTime"> The time at which the message was edited. </param>
/// <returns> A new <see cref="SystemEvents.AcsChatMessageEditedEventData"/> instance for mocking. </returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static AcsChatMessageEditedEventData AcsChatMessageEditedEventData(CommunicationIdentifierModel recipientCommunicationIdentifier = null, string transactionId = null, string threadId = null, string messageId = null, CommunicationIdentifierModel senderCommunicationIdentifier = null, string senderDisplayName = null, DateTimeOffset? composeTime = null, string type = null, long? version = null, string messageBody = null, DateTimeOffset? editTime = null)
{
return new AcsChatMessageEditedEventData(recipientCommunicationIdentifier, transactionId, threadId, messageId, senderCommunicationIdentifier, senderDisplayName, composeTime, type, version, messageBody, new ChangeTrackingDictionary<string, string>(), editTime);
}

/// <summary> Initializes a new instance of AcsChatMessageEditedInThreadEventData. </summary>
/// <param name="transactionId"> The transaction id will be used as co-relation vector. </param>
/// <param name="threadId"> The chat thread id. </param>
/// <param name="messageId"> The chat message id. </param>
/// <param name="senderCommunicationIdentifier"> The communication identifier of the sender. </param>
/// <param name="senderDisplayName"> The display name of the sender. </param>
/// <param name="composeTime"> The original compose time of the message. </param>
/// <param name="type"> The type of the message. </param>
/// <param name="version"> The version of the message. </param>
/// <param name="messageBody"> The body of the chat message. </param>
/// <param name="editTime"> The time at which the message was edited. </param>
/// <returns> A new <see cref="SystemEvents.AcsChatMessageEditedInThreadEventData"/> instance for mocking. </returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static AcsChatMessageEditedInThreadEventData AcsChatMessageEditedInThreadEventData(string transactionId = null, string threadId = null, string messageId = null, CommunicationIdentifierModel senderCommunicationIdentifier = null, string senderDisplayName = null, DateTimeOffset? composeTime = null, string type = null, long? version = null, string messageBody = null, DateTimeOffset? editTime = null)
{
return new AcsChatMessageEditedInThreadEventData(transactionId, threadId, messageId, senderCommunicationIdentifier, senderDisplayName, composeTime, type, version, messageBody, new ChangeTrackingDictionary<string, string>(), editTime);
}
}
#pragma warning restore CA1054 // URI-like parameters should not be strings
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ public EventGridPublisherClient(Uri endpoint, AzureKeyCredential credential, Eve
_clientDiagnostics = new ClientDiagnostics(options);
}

/// <summary>Initalizes a new instance of the <see cref="EventGridPublisherClient"/> class.</summary>
/// <param name="endpoint">The topic endpoint. For example, "https://TOPIC-NAME.REGION-NAME-1.eventgrid.azure.net/api/events".</param>
/// <param name="credential">The token credential used to authenticate with the service.</param>
/// <param name="options">The set of options to use for configuring the client.</param>
public EventGridPublisherClient(Uri endpoint, TokenCredential credential, EventGridPublisherClientOptions options = default)
{
Argument.AssertNotNull(endpoint, nameof(endpoint));
Argument.AssertNotNull(credential, nameof(credential));
options ??= new EventGridPublisherClientOptions();
_uriBuilder = new RequestUriBuilder();
_uriBuilder.Reset(endpoint);
_uriBuilder.AppendQuery("api-version", options.Version.GetVersionString(), true);
_pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, "https://eventgrid.azure.net/.default"));
_clientDiagnostics = new ClientDiagnostics(options);
}

/// <summary>
/// Initializes a new instance of the <see cref="EventGridPublisherClient"/> class.
/// </summary>
Expand Down
Loading

0 comments on commit 3b0d98e

Please sign in to comment.