Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for EG release #20956

Merged
merged 1 commit into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion sdk/eventgrid/Azure.Messaging.EventGrid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Release History

## 4.2.0-beta.1 (Unreleased)
## 4.2.0 (2021-05-10)

### New Features
* Added the following new system events:
- PolicyInsightsPolicyStateChangedEventData
- PolicyInsightsPolicyStateCreatedEventData
- PolicyInsightsPolicyStateDeletedEventData
- StorageAsyncOperationInitiatedEventData
- StorageBlobTierChangedEventData

## 4.1.0 (2021-03-23)

Expand Down
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.2.0-beta.1</Version>
<Version>4.2.0</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>4.1.0</ApiCompatVersion>
<PackageTags>Microsoft Azure EventGrid;Event Grid;Event Grid Publishing;</PackageTags>
Expand Down
120 changes: 120 additions & 0 deletions sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,28 @@ public void ConsumeStorageDirectoryRenamedEvent()
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testDir", (eventData as StorageDirectoryRenamedEventData).DestinationUrl);
}

[Test]
public void ConsumeStorageAsyncOperationInitiatedEvent()
{
string requestContent = "[{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"eventType\": \"Microsoft.Storage.AsyncOperationInitiated\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"RenameDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"1.0\"}]";
EventGridEvent[] events = EventGridEvent.ParseMany(new BinaryData(requestContent));

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testDir", (eventData as StorageAsyncOperationInitiatedEventData).Url);
}

[Test]
public void ConsumeStorageBlobTierChangedEvent()
{
string requestContent = "[{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"eventType\": \"Microsoft.Storage.BlobTierChanged\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"RenameDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"1.0\"}]";
EventGridEvent[] events = EventGridEvent.ParseMany(new BinaryData(requestContent));

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testDir", (eventData as StorageBlobTierChangedEventData).Url);
}
#endregion

#region App Service events
Expand Down Expand Up @@ -1327,6 +1349,44 @@ public void ConsumeWebAppServicePlanUpdatedEvent()
Assert.AreEqual(planName, (eventData as WebAppServicePlanUpdatedEventData).Name);
}
#endregion

#region Policy Insights
[Test]
public void ConsumePolicyInsightsPolicyStateChangedEvent()
{
string requestContent = "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"eventType\":\"Microsoft.PolicyInsights.PolicyStateChanged\", \"eventTime\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":\"{request-operation}\", \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"dataVersion\": \"1.0\" }]";

EventGridEvent[] events = EventGridEvent.ParseMany(new BinaryData(requestContent));

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("4c2359fe-001e-00ba-0e04-585868000000", (eventData as PolicyInsightsPolicyStateChangedEventData).PolicyDefinitionId);
}

[Test]
public void ConsumePolicyInsightsPolicyStateCreatedEvent()
{
string requestContent = "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"eventType\":\"Microsoft.PolicyInsights.PolicyStateCreated\", \"eventTime\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":\"{request-operation}\", \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"dataVersion\": \"1.0\" }]";

EventGridEvent[] events = EventGridEvent.ParseMany(new BinaryData(requestContent));

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("4c2359fe-001e-00ba-0e04-585868000000", (eventData as PolicyInsightsPolicyStateCreatedEventData).PolicyDefinitionId);
}

[Test]
public void ConsumePolicyInsightsPolicyStateDeletedEvent()
{
string requestContent = "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"eventType\":\"Microsoft.PolicyInsights.PolicyStateDeleted\", \"eventTime\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":\"{request-operation}\", \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"dataVersion\": \"1.0\" }]";

EventGridEvent[] events = EventGridEvent.ParseMany(new BinaryData(requestContent));

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("4c2359fe-001e-00ba-0e04-585868000000", (eventData as PolicyInsightsPolicyStateDeletedEventData).PolicyDefinitionId);
}
#endregion
#endregion

#region CloudEvent tests
Expand Down Expand Up @@ -2497,6 +2557,28 @@ public void ConsumeCloudEventStorageDirectoryRenamedEvent()
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testDir", (eventData as StorageDirectoryRenamedEventData).DestinationUrl);
}

[Test]
public void ConsumeCloudEventStorageAsyncOperationInitiatedEvent()
{
string requestContent = "[{ \"source\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"type\": \"Microsoft.Storage.AsyncOperationInitiated\", \"time\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"RenameDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"specversion\": \"1.0\"}]";
CloudEvent[] events = CloudEvent.ParseMany(new BinaryData(requestContent));

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testDir", (eventData as StorageAsyncOperationInitiatedEventData).Url);
}

[Test]
public void ConsumeCloudEventStorageBlobTierChangedEvent()
{
string requestContent = "[{ \"source\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"type\": \"Microsoft.Storage.BlobTierChanged\", \"time\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"RenameDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"specversion\": \"1.0\"}]";
CloudEvent[] events = CloudEvent.ParseMany(new BinaryData(requestContent));

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testDir", (eventData as StorageBlobTierChangedEventData).Url);
}
#endregion

#region App Service events
Expand Down Expand Up @@ -2668,6 +2750,44 @@ public void ConsumeCloudEventWebAppServicePlanUpdatedEvent()
Assert.AreEqual(planName, (eventData as WebAppServicePlanUpdatedEventData).Name);
}
#endregion

#region Policy Insights
[Test]
public void ConsumeCloudEventPolicyInsightsPolicyStateChangedEvent()
{
string requestContent = "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.PolicyInsights.PolicyStateChanged\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":\"{request-operation}\", \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"specversion\": \"1.0\" }]";

CloudEvent[] events = CloudEvent.ParseMany(new BinaryData(requestContent));

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("4c2359fe-001e-00ba-0e04-585868000000", (eventData as PolicyInsightsPolicyStateChangedEventData).PolicyDefinitionId);
}

[Test]
public void ConsumeCloudEventPolicyInsightsPolicyStateCreatedEvent()
{
string requestContent = "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.PolicyInsights.PolicyStateCreated\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":\"{request-operation}\", \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"specversion\": \"1.0\" }]";

CloudEvent[] events = CloudEvent.ParseMany(new BinaryData(requestContent));

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("4c2359fe-001e-00ba-0e04-585868000000", (eventData as PolicyInsightsPolicyStateCreatedEventData).PolicyDefinitionId);
}

[Test]
public void ConsumeCloudEventPolicyInsightsPolicyStateDeletedEvent()
{
string requestContent = "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.PolicyInsights.PolicyStateDeleted\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":\"{request-operation}\", \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"specversion\": \"1.0\" }]";

CloudEvent[] events = CloudEvent.ParseMany(new BinaryData(requestContent));

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual("4c2359fe-001e-00ba-0e04-585868000000", (eventData as PolicyInsightsPolicyStateDeletedEventData).PolicyDefinitionId);
}
#endregion
#endregion
}
}