Skip to content

Commit

Permalink
Add new Media enum values (#27342)
Browse files Browse the repository at this point in the history
* Add new Media enum values

* Update version
  • Loading branch information
JoshLove-msft authored Mar 4, 2022
1 parent d56ebba commit c1f475f
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 44 deletions.
8 changes: 2 additions & 6 deletions sdk/eventgrid/Azure.Messaging.EventGrid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Release History

## 4.9.0-beta.1 (Unreleased)
## 4.9.0 (2022-03-08)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
- Added new enum values for `MediaJobErrorCategory` and `MediaJobErrorCode`.

## 4.8.2 (2022-02-08)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,7 @@ public enum MediaJobErrorCategory
Upload = 2,
Configuration = 3,
Content = 4,
Account = 5,
}
public enum MediaJobErrorCode
{
Expand All @@ -1292,6 +1293,7 @@ public enum MediaJobErrorCode
ConfigurationUnsupported = 6,
ContentMalformed = 7,
ContentUnsupported = 8,
IdentityUnsupported = 9,
}
public partial class MediaJobErrorDetail
{
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.9.0-beta.1</Version>
<Version>4.9.0</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>4.8.2</ApiCompatVersion>
<PackageTags>Microsoft Azure EventGrid;Event Grid;Event Grid Publishing;</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Text;
using Azure.Core;

namespace Azure.Messaging.EventGrid.SystemEvents
{
/// <summary> Helps with categorization of errors. </summary>
/// <summary>
/// Helps with categorization of errors. If you get an enum with a value of <see cref="int.MaxValue"/>, that means the service has returned a new category, and you
/// should upgrade to the latest SDK.
/// </summary>
[CodeGenModel("MediaJobErrorCategory")]
public enum MediaJobErrorCategory
{
Expand All @@ -21,6 +21,8 @@ public enum MediaJobErrorCategory
/// <summary> The error is configuration related. </summary>
Configuration,
/// <summary> The error is related to data in the input files. </summary>
Content
Content,
/// <summary> The error is related to account information. </summary>
Account
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;

namespace Azure.Messaging.EventGrid.SystemEvents
{
internal static partial class MediaJobErrorCategoryExtensions
{
public static MediaJobErrorCategory ToMediaJobErrorCategory(this string value)
{
if (string.Equals(value, "Service", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCategory.Service;
if (string.Equals(value, "Download", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCategory.Download;
if (string.Equals(value, "Upload", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCategory.Upload;
if (string.Equals(value, "Configuration", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCategory.Configuration;
if (string.Equals(value, "Content", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCategory.Content;
if (string.Equals(value, "Account", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCategory.Account;
// use Max Int for unknown values
return (MediaJobErrorCategory)int.MaxValue;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

namespace Azure.Messaging.EventGrid.SystemEvents
{
/// <summary> Error code describing the error. </summary>
/// <summary>
/// Error code describing the error. If you get an enum with a value of <see cref="int.MaxValue"/>, that means the service has returned a new category, and you
/// should upgrade to the latest SDK.
/// </summary>
[CodeGenModel("MediaJobErrorCode")]
public enum MediaJobErrorCode
{
Expand All @@ -29,6 +32,8 @@ public enum MediaJobErrorCode
/// <summary> There was a problem with the input content (for example: zero byte files, or corrupt/non-decodable files), check the input files. </summary>
ContentMalformed,
/// <summary> There was a problem with the format of the input (not valid media file, or an unsupported file/codec), check the validity of the input files. </summary>
ContentUnsupported
ContentUnsupported,
/// <summary> There is an error verifying to the account identity. Check and fix the identity configurations and retry. If unsuccessful, please contact support. </summary>
IdentityUnsupported
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;

namespace Azure.Messaging.EventGrid.SystemEvents
{
internal static partial class MediaJobErrorCodeExtensions
{
public static MediaJobErrorCode ToMediaJobErrorCode(this string value)
{
if (string.Equals(value, "ServiceError", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCode.ServiceError;
if (string.Equals(value, "ServiceTransientError", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCode.ServiceTransientError;
if (string.Equals(value, "DownloadNotAccessible", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCode.DownloadNotAccessible;
if (string.Equals(value, "DownloadTransientError", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCode.DownloadTransientError;
if (string.Equals(value, "UploadNotAccessible", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCode.UploadNotAccessible;
if (string.Equals(value, "UploadTransientError", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCode.UploadTransientError;
if (string.Equals(value, "ConfigurationUnsupported", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCode.ConfigurationUnsupported;
if (string.Equals(value, "ContentMalformed", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCode.ContentMalformed;
if (string.Equals(value, "ContentUnsupported", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCode.ContentUnsupported;
if (string.Equals(value, "IdentityUnsupported", StringComparison.InvariantCultureIgnoreCase)) return MediaJobErrorCode.IdentityUnsupported;
// use Max Int for unknown values
return (MediaJobErrorCode)int.MaxValue;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Run `dotnet build /t:GenerateCode` to generate code.

``` yaml
title: EventGridClient
require: https://github.com/Azure/azure-rest-api-specs/blob/03da592cccfa0e52ccd6ecc53d232afda8a38c95/specification/eventgrid/data-plane/readme.md
require: https://github.com/Azure/azure-rest-api-specs/blob/6b29b8552671eded065f51ee1b291582ab8cc149/specification/eventgrid/data-plane/readme.md
```
## Swagger workarounds
Expand Down
22 changes: 22 additions & 0 deletions sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,28 @@ public void ConsumeMediaJobOutputStateChangeEvent()
Assert.True((eventData as MediaJobOutputStateChangeEventData).Output is MediaJobOutputAsset);
MediaJobOutputAsset outputAsset = (MediaJobOutputAsset)(eventData as MediaJobOutputStateChangeEventData).Output;
Assert.AreEqual("output-2ac2fe75-6557-4de5-ab25-5713b74a6901", outputAsset.AssetName);

Assert.AreEqual(MediaJobErrorCategory.Service, outputAsset.Error.Category);
Assert.AreEqual(MediaJobErrorCode.ServiceError, outputAsset.Error.Code);
}

[Test]
public void ConsumeMediaJobOutputStateChangeEvent_UnknownError()
{
string requestContent = "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobOutputStateChange\", \"eventTime\": \"2018-10-12T15:14:17.8962704\", \"id\": \"8d0305c0-28c0-4cc9-b613-776e4dd31e9a\", \"data\": { \"previousState\": \"Scheduled\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": {\"code\":\"SomeNewCode\", \"message\":\"error message\", \"category\":\"SomeNewCategory\", \"retry\":\"DoNotRetry\", \"details\":[{\"code\":\"code\", \"message\":\"Service Error Message\"}]}, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 0, \"state\": \"Processing\" }, \"jobCorrelationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]";

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

Assert.NotNull(events);
Assert.True(events[0].TryGetSystemEventData(out object eventData));
Assert.AreEqual(MediaJobState.Scheduled, (eventData as MediaJobOutputStateChangeEventData).PreviousState);
Assert.AreEqual(MediaJobState.Processing, (eventData as MediaJobOutputStateChangeEventData).Output.State);
Assert.True((eventData as MediaJobOutputStateChangeEventData).Output is MediaJobOutputAsset);
MediaJobOutputAsset outputAsset = (MediaJobOutputAsset)(eventData as MediaJobOutputStateChangeEventData).Output;
Assert.AreEqual("output-2ac2fe75-6557-4de5-ab25-5713b74a6901", outputAsset.AssetName);

Assert.AreEqual((MediaJobErrorCategory)int.MaxValue, outputAsset.Error.Category);
Assert.AreEqual((MediaJobErrorCode)int.MaxValue, outputAsset.Error.Code);
}

[Test]
Expand Down

0 comments on commit c1f475f

Please sign in to comment.