diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/CHANGELOG.md b/sdk/eventgrid/Azure.Messaging.EventGrid/CHANGELOG.md index f68b2fd1783cc..17ae662b76020 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/CHANGELOG.md +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 4.20.0-beta.1 (Unreleased) - -### Features Added - -### Breaking Changes +## 4.20.0 (2023-10-18) ### Bugs Fixed -### Other Changes +- Added several communication models into the correct namespace and hid the old ones. ## 4.19.0 (2023-10-11) diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs index b8e7086977402..15fb1ce13c874 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs @@ -88,7 +88,9 @@ public static partial class EventGridModelFactory public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobEventData AcsRouterJobEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, System.Collections.Generic.IReadOnlyDictionary labels = null, System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobExceptionTriggeredEventData AcsRouterJobExceptionTriggeredEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, System.Collections.Generic.IReadOnlyDictionary labels = null, System.Collections.Generic.IReadOnlyDictionary tags = null, string ruleKey = null, string exceptionRuleId = null) { throw null; } public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobQueuedEventData AcsRouterJobQueuedEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, System.Collections.Generic.IReadOnlyDictionary labels = null, System.Collections.Generic.IReadOnlyDictionary tags = null, int? priority = default(int?), System.Collections.Generic.IEnumerable attachedWorkerSelectors = null, System.Collections.Generic.IEnumerable requestedWorkerSelectors = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobReceivedEventData AcsRouterJobReceivedEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, System.Collections.Generic.IReadOnlyDictionary labels = null, System.Collections.Generic.IReadOnlyDictionary tags = null, Azure.Messaging.EventGrid.Models.AcsRouterJobStatus? jobStatus = default(Azure.Messaging.EventGrid.Models.AcsRouterJobStatus?), string classificationPolicyId = null, int? priority = default(int?), System.Collections.Generic.IEnumerable requestedWorkerSelectors = null, System.DateTimeOffset? scheduledOn = default(System.DateTimeOffset?), bool unavailableForMatching = false) { throw null; } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobReceivedEventData AcsRouterJobReceivedEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, System.Collections.Generic.IReadOnlyDictionary labels = null, System.Collections.Generic.IReadOnlyDictionary tags = null, Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus? status = default(Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus?), string classificationPolicyId = null, int? priority = default(int?), System.Collections.Generic.IEnumerable requestedWorkerSelectors = null, System.DateTimeOffset? scheduledOn = default(System.DateTimeOffset?), bool unavailableForMatching = false) { throw null; } public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobSchedulingFailedEventData AcsRouterJobSchedulingFailedEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, System.Collections.Generic.IReadOnlyDictionary labels = null, System.Collections.Generic.IReadOnlyDictionary tags = null, int? priority = default(int?), System.Collections.Generic.IEnumerable expiredAttachedWorkerSelectors = null, System.Collections.Generic.IEnumerable expiredRequestedWorkerSelectors = null, System.DateTimeOffset? scheduledOn = default(System.DateTimeOffset?), string failureReason = null) { throw null; } public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobUnassignedEventData AcsRouterJobUnassignedEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, System.Collections.Generic.IReadOnlyDictionary labels = null, System.Collections.Generic.IReadOnlyDictionary tags = null, string assignmentId = null, string workerId = null) { throw null; } public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobWaitingForActivationEventData AcsRouterJobWaitingForActivationEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, System.Collections.Generic.IReadOnlyDictionary labels = null, System.Collections.Generic.IReadOnlyDictionary tags = null, int? priority = default(int?), System.Collections.Generic.IEnumerable expiredAttachedWorkerSelectors = null, System.Collections.Generic.IEnumerable expiredRequestedWorkerSelectors = null, System.DateTimeOffset? scheduledOn = default(System.DateTimeOffset?), bool unavailableForMatching = false) { throw null; } @@ -623,6 +625,7 @@ namespace Azure.Messaging.EventGrid.Models public static bool operator !=(Azure.Messaging.EventGrid.Models.AcsRouterLabelOperator left, Azure.Messaging.EventGrid.Models.AcsRouterLabelOperator right) { throw null; } public override string ToString() { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct AcsRouterWorkerSelectorState : System.IEquatable { @@ -1090,6 +1093,7 @@ internal AcsRouterJobReceivedEventData() { } public int? Priority { get { throw null; } } public System.Collections.Generic.IReadOnlyList RequestedWorkerSelectors { get { throw null; } } public System.DateTimeOffset? ScheduledOn { get { throw null; } } + public Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus? Status { get { throw null; } } public bool UnavailableForMatching { get { throw null; } } } public partial class AcsRouterJobSchedulingFailedEventData : Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobEventData @@ -1101,6 +1105,34 @@ internal AcsRouterJobSchedulingFailedEventData() { } public int? Priority { get { throw null; } } public System.DateTimeOffset? ScheduledOn { get { throw null; } } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AcsRouterJobStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AcsRouterJobStatus(string value) { throw null; } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus Assigned { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus Cancelled { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus ClassificationFailed { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus Closed { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus Completed { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus Created { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus PendingClassification { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus PendingSchedule { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus Queued { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus Scheduled { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus ScheduleFailed { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus WaitingForActivation { get { throw null; } } + public bool Equals(Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus left, Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus right) { throw null; } + public static implicit operator Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus (string value) { throw null; } + public static bool operator !=(Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus left, Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus right) { throw null; } + public override string ToString() { throw null; } + } public partial class AcsRouterJobUnassignedEventData : Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobEventData { internal AcsRouterJobUnassignedEventData() { } @@ -1122,6 +1154,28 @@ internal AcsRouterJobWorkerSelectorsExpiredEventData() { } public System.Collections.Generic.IReadOnlyList ExpiredAttachedWorkerSelectors { get { throw null; } } public System.Collections.Generic.IReadOnlyList ExpiredRequestedWorkerSelectors { get { throw null; } } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AcsRouterLabelOperator : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AcsRouterLabelOperator(string value) { throw null; } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator Equal { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator Greater { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator GreaterThanOrEqual { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator Less { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator LessThanOrEqual { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator NotEqual { get { throw null; } } + public bool Equals(Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator left, Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator right) { throw null; } + public static implicit operator Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator (string value) { throw null; } + public static bool operator !=(Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator left, Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator right) { throw null; } + public override string ToString() { throw null; } + } public partial class AcsRouterQueueDetails { internal AcsRouterQueueDetails() { } @@ -1201,11 +1255,33 @@ public partial class AcsRouterWorkerSelector internal AcsRouterWorkerSelector() { } public System.DateTimeOffset? ExpirationTime { get { throw null; } } public string Key { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Messaging.EventGrid.Models.AcsRouterLabelOperator? LabelOperator { get { throw null; } } public object LabelValue { get { throw null; } } + public Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator? Operator { get { throw null; } } + public Azure.Messaging.EventGrid.SystemEvents.AcsRouterWorkerSelectorState? SelectorState { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Messaging.EventGrid.Models.AcsRouterWorkerSelectorState? State { get { throw null; } } public System.TimeSpan? TimeToLive { get { throw null; } } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AcsRouterWorkerSelectorState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AcsRouterWorkerSelectorState(string value) { throw null; } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterWorkerSelectorState Active { get { throw null; } } + public static Azure.Messaging.EventGrid.SystemEvents.AcsRouterWorkerSelectorState Expired { get { throw null; } } + public bool Equals(Azure.Messaging.EventGrid.SystemEvents.AcsRouterWorkerSelectorState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Messaging.EventGrid.SystemEvents.AcsRouterWorkerSelectorState left, Azure.Messaging.EventGrid.SystemEvents.AcsRouterWorkerSelectorState right) { throw null; } + public static implicit operator Azure.Messaging.EventGrid.SystemEvents.AcsRouterWorkerSelectorState (string value) { throw null; } + public static bool operator !=(Azure.Messaging.EventGrid.SystemEvents.AcsRouterWorkerSelectorState left, Azure.Messaging.EventGrid.SystemEvents.AcsRouterWorkerSelectorState right) { throw null; } + public override string ToString() { throw null; } + } public partial class AcsSmsDeliveryAttemptProperties { internal AcsSmsDeliveryAttemptProperties() { } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj index a1a3beaee20d0..ef8b568d99e36 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj @@ -2,7 +2,7 @@ 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. Microsoft Azure.Messaging.EventGrid client library - 4.20.0-beta.1 + 4.20.0 4.19.0 Microsoft Azure EventGrid;Event Grid;Event Grid Publishing; diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterJobReceivedEventData.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterJobReceivedEventData.cs new file mode 100644 index 0000000000000..5ee25311db035 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterJobReceivedEventData.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Messaging.EventGrid.SystemEvents +{ + public partial class AcsRouterJobReceivedEventData + { + /// Router Job Received Job Status. + [CodeGenMember("JobStatus")] + public AcsRouterJobStatus? Status { get; } + + /// Router Job Received Job Status. + public Azure.Messaging.EventGrid.Models.AcsRouterJobStatus? JobStatus + { + get + { + if (Status.HasValue) + { + return new Azure.Messaging.EventGrid.Models.AcsRouterJobStatus(Status.Value.ToString()); + } + + return null; + } + } + } +} \ No newline at end of file diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterJobStatus.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterJobStatus.cs new file mode 100644 index 0000000000000..11f8aec194342 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterJobStatus.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Messaging.EventGrid.Models +{ + /// Router Job Received Job Status. + public readonly partial struct AcsRouterJobStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AcsRouterJobStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PendingClassificationValue = "PendingClassification"; + private const string QueuedValue = "Queued"; + private const string AssignedValue = "Assigned"; + private const string CompletedValue = "Completed"; + private const string ClosedValue = "Closed"; + private const string CancelledValue = "Cancelled"; + private const string ClassificationFailedValue = "ClassificationFailed"; + private const string CreatedValue = "Created"; + private const string PendingScheduleValue = "PendingSchedule"; + private const string ScheduledValue = "Scheduled"; + private const string ScheduleFailedValue = "ScheduleFailed"; + private const string WaitingForActivationValue = "WaitingForActivation"; + + /// PendingClassification. + public static AcsRouterJobStatus PendingClassification { get; } = new AcsRouterJobStatus(PendingClassificationValue); + /// Queued. + public static AcsRouterJobStatus Queued { get; } = new AcsRouterJobStatus(QueuedValue); + /// Assigned. + public static AcsRouterJobStatus Assigned { get; } = new AcsRouterJobStatus(AssignedValue); + /// Completed. + public static AcsRouterJobStatus Completed { get; } = new AcsRouterJobStatus(CompletedValue); + /// Closed. + public static AcsRouterJobStatus Closed { get; } = new AcsRouterJobStatus(ClosedValue); + /// Cancelled. + public static AcsRouterJobStatus Cancelled { get; } = new AcsRouterJobStatus(CancelledValue); + /// ClassificationFailed. + public static AcsRouterJobStatus ClassificationFailed { get; } = new AcsRouterJobStatus(ClassificationFailedValue); + /// Created. + public static AcsRouterJobStatus Created { get; } = new AcsRouterJobStatus(CreatedValue); + /// PendingSchedule. + public static AcsRouterJobStatus PendingSchedule { get; } = new AcsRouterJobStatus(PendingScheduleValue); + /// Scheduled. + public static AcsRouterJobStatus Scheduled { get; } = new AcsRouterJobStatus(ScheduledValue); + /// ScheduleFailed. + public static AcsRouterJobStatus ScheduleFailed { get; } = new AcsRouterJobStatus(ScheduleFailedValue); + /// WaitingForActivation. + public static AcsRouterJobStatus WaitingForActivation { get; } = new AcsRouterJobStatus(WaitingForActivationValue); + /// Determines if two values are the same. + public static bool operator ==(AcsRouterJobStatus left, AcsRouterJobStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AcsRouterJobStatus left, AcsRouterJobStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AcsRouterJobStatus(string value) => new AcsRouterJobStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AcsRouterJobStatus other && Equals(other); + /// + public bool Equals(AcsRouterJobStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterLabelOperator.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterLabelOperator.cs new file mode 100644 index 0000000000000..d96162d8dd625 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterLabelOperator.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Messaging.EventGrid.Models +{ + /// Router Job Worker Selector Label Operator. + public readonly partial struct AcsRouterLabelOperator : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AcsRouterLabelOperator(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EqualValue = "Equal"; + private const string NotEqualValue = "NotEqual"; + private const string GreaterValue = "Greater"; + private const string LessValue = "Less"; + private const string GreaterThanOrEqualValue = "GreaterThanOrEqual"; + private const string LessThanOrEqualValue = "LessThanOrEqual"; + + /// =. + public static AcsRouterLabelOperator Equal { get; } = new AcsRouterLabelOperator(EqualValue); + /// !=. + public static AcsRouterLabelOperator NotEqual { get; } = new AcsRouterLabelOperator(NotEqualValue); + /// >. + public static AcsRouterLabelOperator Greater { get; } = new AcsRouterLabelOperator(GreaterValue); + /// <. + public static AcsRouterLabelOperator Less { get; } = new AcsRouterLabelOperator(LessValue); + /// >=. + public static AcsRouterLabelOperator GreaterThanOrEqual { get; } = new AcsRouterLabelOperator(GreaterThanOrEqualValue); + /// <=. + public static AcsRouterLabelOperator LessThanOrEqual { get; } = new AcsRouterLabelOperator(LessThanOrEqualValue); + /// Determines if two values are the same. + public static bool operator ==(AcsRouterLabelOperator left, AcsRouterLabelOperator right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AcsRouterLabelOperator left, AcsRouterLabelOperator right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AcsRouterLabelOperator(string value) => new AcsRouterLabelOperator(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AcsRouterLabelOperator other && Equals(other); + /// + public bool Equals(AcsRouterLabelOperator other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterWorkerSelector.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterWorkerSelector.cs index d092f9754a315..9386715075009 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterWorkerSelector.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterWorkerSelector.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; +using System.ComponentModel; using Azure.Core; namespace Azure.Messaging.EventGrid.SystemEvents @@ -13,5 +14,43 @@ public partial class AcsRouterWorkerSelector /// Router Job Worker Selector TTL. public TimeSpan? TimeToLive => TtlSeconds.HasValue ? TimeSpan.FromSeconds(TtlSeconds.Value) : null; + + /// Router Job Worker Selector Label Operator. + [CodeGenMember("LabelOperator")] + public AcsRouterLabelOperator? Operator { get; } + + /// Router Job Worker Selector Label Operator. + [EditorBrowsable(EditorBrowsableState.Never)] + public Azure.Messaging.EventGrid.Models.AcsRouterLabelOperator? LabelOperator + { + get + { + if (Operator.HasValue) + { + return new Azure.Messaging.EventGrid.Models.AcsRouterLabelOperator(Operator.Value.ToString()); + } + + return null; + } + } + + /// Router Job Worker Selector State. + [CodeGenMember("State")] + public AcsRouterWorkerSelectorState? SelectorState { get; } + + /// Router Job Worker Selector State. + [EditorBrowsable(EditorBrowsableState.Never)] + public Azure.Messaging.EventGrid.Models.AcsRouterWorkerSelectorState? State + { + get + { + if (SelectorState.HasValue) + { + return new Azure.Messaging.EventGrid.Models.AcsRouterWorkerSelectorState(SelectorState.Value.ToString()); + } + + return null; + } + } } } \ No newline at end of file diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterWorkerSelectorState.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterWorkerSelectorState.cs new file mode 100644 index 0000000000000..76be5fb497c37 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/AcsRouterWorkerSelectorState.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Messaging.EventGrid.Models +{ + /// Router Job Worker Selector State. + [EditorBrowsable(EditorBrowsableState.Never)] + public readonly partial struct AcsRouterWorkerSelectorState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AcsRouterWorkerSelectorState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ActiveValue = "active"; + private const string ExpiredValue = "expired"; + + /// Router Job Worker Selector is Active. + public static AcsRouterWorkerSelectorState Active { get; } = new AcsRouterWorkerSelectorState(ActiveValue); + /// Router Job Worker Selector has Expire. + public static AcsRouterWorkerSelectorState Expired { get; } = new AcsRouterWorkerSelectorState(ExpiredValue); + /// Determines if two values are the same. + public static bool operator ==(AcsRouterWorkerSelectorState left, AcsRouterWorkerSelectorState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AcsRouterWorkerSelectorState left, AcsRouterWorkerSelectorState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AcsRouterWorkerSelectorState(string value) => new AcsRouterWorkerSelectorState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AcsRouterWorkerSelectorState other && Equals(other); + /// + public bool Equals(AcsRouterWorkerSelectorState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridModelFactory.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridModelFactory.cs index 828100f2ec551..da01266c17914 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridModelFactory.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridModelFactory.cs @@ -5,10 +5,12 @@ using System.Collections.Generic; using System.ComponentModel; using System.Globalization; +using System.Linq; using System.Text.Json; using Azure.Core; using Azure.Messaging.EventGrid.Models; using Azure.Messaging.EventGrid.SystemEvents; +using AcsRouterJobStatus = Azure.Messaging.EventGrid.Models.AcsRouterJobStatus; namespace Azure.Messaging.EventGrid { @@ -584,6 +586,31 @@ public static AcsEmailEngagementTrackingReportReceivedEventData AcsEmailEngageme { return new AcsEmailEngagementTrackingReportReceivedEventData(sender, null, messageId, userActionTimestamp, engagementContext, userAgent, engagement); } + + /// Initializes a new instance of AcsRouterJobReceivedEventData. + /// Router Event Job ID. + /// Router Event Channel Reference. + /// Router Event Channel ID. + /// Router Job events Queue Id. + /// Router Job events Labels. + /// Router Jobs events Tags. + /// Router Job Received Job Status. + /// Router Job Classification Policy Id. + /// Router Job Priority. + /// Router Job Received Requested Worker Selectors. + /// Router Job Received Scheduled Time in UTC. + /// Unavailable For Matching for Router Job Received. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static AcsRouterJobReceivedEventData AcsRouterJobReceivedEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, IReadOnlyDictionary labels = null, IReadOnlyDictionary tags = null, Azure.Messaging.EventGrid.Models.AcsRouterJobStatus? jobStatus = null, string classificationPolicyId = null, int? priority = null, IEnumerable requestedWorkerSelectors = null, DateTimeOffset? scheduledOn = null, bool unavailableForMatching = default) + { + labels ??= new Dictionary(); + tags ??= new Dictionary(); + requestedWorkerSelectors ??= new List(); + Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus? status = jobStatus.HasValue ? new Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus(jobStatus.ToString()) : null; + + return new AcsRouterJobReceivedEventData(jobId, channelReference, channelId, queueId, labels, tags, status, classificationPolicyId, priority, requestedWorkerSelectors?.ToList(), scheduledOn, unavailableForMatching); + } } #pragma warning restore CA1054 // URI-like parameters should not be strings } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs index 241b4ce80ab04..b0ca3b4a63ce6 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Azure.Messaging.EventGrid.Models; using Azure.Messaging.EventGrid.SystemEvents; namespace Azure.Messaging.EventGrid @@ -1918,20 +1917,20 @@ public static AcsRouterJobQueuedEventData AcsRouterJobQueuedEventData(string job /// Router Job events Queue Id. /// Router Job events Labels. /// Router Jobs events Tags. - /// Router Job Received Job Status. + /// Router Job Received Job Status. /// Router Job Classification Policy Id. /// Router Job Priority. /// Router Job Received Requested Worker Selectors. /// Router Job Received Scheduled Time in UTC. /// Unavailable For Matching for Router Job Received. /// A new instance for mocking. - public static AcsRouterJobReceivedEventData AcsRouterJobReceivedEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, IReadOnlyDictionary labels = null, IReadOnlyDictionary tags = null, AcsRouterJobStatus? jobStatus = null, string classificationPolicyId = null, int? priority = null, IEnumerable requestedWorkerSelectors = null, DateTimeOffset? scheduledOn = null, bool unavailableForMatching = default) + public static AcsRouterJobReceivedEventData AcsRouterJobReceivedEventData(string jobId = null, string channelReference = null, string channelId = null, string queueId = null, IReadOnlyDictionary labels = null, IReadOnlyDictionary tags = null, AcsRouterJobStatus? status = null, string classificationPolicyId = null, int? priority = null, IEnumerable requestedWorkerSelectors = null, DateTimeOffset? scheduledOn = null, bool unavailableForMatching = default) { labels ??= new Dictionary(); tags ??= new Dictionary(); requestedWorkerSelectors ??= new List(); - return new AcsRouterJobReceivedEventData(jobId, channelReference, channelId, queueId, labels, tags, jobStatus, classificationPolicyId, priority, requestedWorkerSelectors?.ToList(), scheduledOn, unavailableForMatching); + return new AcsRouterJobReceivedEventData(jobId, channelReference, channelId, queueId, labels, tags, status, classificationPolicyId, priority, requestedWorkerSelectors?.ToList(), scheduledOn, unavailableForMatching); } /// Initializes a new instance of AcsRouterJobSchedulingFailedEventData. diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobReceivedEventData.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobReceivedEventData.Serialization.cs index 6d232c0c323e8..394708f038197 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobReceivedEventData.Serialization.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobReceivedEventData.Serialization.cs @@ -10,7 +10,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; -using Azure.Messaging.EventGrid.Models; namespace Azure.Messaging.EventGrid.SystemEvents { diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobReceivedEventData.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobReceivedEventData.cs index 3e0e38789325b..90857c9563ca0 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobReceivedEventData.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobReceivedEventData.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; using Azure.Core; -using Azure.Messaging.EventGrid.Models; namespace Azure.Messaging.EventGrid.SystemEvents { @@ -30,24 +29,21 @@ internal AcsRouterJobReceivedEventData(bool unavailableForMatching) /// Router Job events Queue Id. /// Router Job events Labels. /// Router Jobs events Tags. - /// Router Job Received Job Status. + /// Router Job Received Job Status. /// Router Job Classification Policy Id. /// Router Job Priority. /// Router Job Received Requested Worker Selectors. /// Router Job Received Scheduled Time in UTC. /// Unavailable For Matching for Router Job Received. - internal AcsRouterJobReceivedEventData(string jobId, string channelReference, string channelId, string queueId, IReadOnlyDictionary labels, IReadOnlyDictionary tags, AcsRouterJobStatus? jobStatus, string classificationPolicyId, int? priority, IReadOnlyList requestedWorkerSelectors, DateTimeOffset? scheduledOn, bool unavailableForMatching) : base(jobId, channelReference, channelId, queueId, labels, tags) + internal AcsRouterJobReceivedEventData(string jobId, string channelReference, string channelId, string queueId, IReadOnlyDictionary labels, IReadOnlyDictionary tags, AcsRouterJobStatus? status, string classificationPolicyId, int? priority, IReadOnlyList requestedWorkerSelectors, DateTimeOffset? scheduledOn, bool unavailableForMatching) : base(jobId, channelReference, channelId, queueId, labels, tags) { - JobStatus = jobStatus; + Status = status; ClassificationPolicyId = classificationPolicyId; Priority = priority; RequestedWorkerSelectors = requestedWorkerSelectors; ScheduledOn = scheduledOn; UnavailableForMatching = unavailableForMatching; } - - /// Router Job Received Job Status. - public AcsRouterJobStatus? JobStatus { get; } /// Router Job Classification Policy Id. public string ClassificationPolicyId { get; } /// Router Job Priority. diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobStatus.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobStatus.cs index 4e4178b97f90c..7d03cfcdbc2bd 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobStatus.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterJobStatus.cs @@ -8,7 +8,7 @@ using System; using System.ComponentModel; -namespace Azure.Messaging.EventGrid.Models +namespace Azure.Messaging.EventGrid.SystemEvents { /// Router Job Received Job Status. public readonly partial struct AcsRouterJobStatus : IEquatable diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterLabelOperator.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterLabelOperator.cs index d96162d8dd625..a147cd7616ff7 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterLabelOperator.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterLabelOperator.cs @@ -8,7 +8,7 @@ using System; using System.ComponentModel; -namespace Azure.Messaging.EventGrid.Models +namespace Azure.Messaging.EventGrid.SystemEvents { /// Router Job Worker Selector Label Operator. public readonly partial struct AcsRouterLabelOperator : IEquatable diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelector.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelector.Serialization.cs index e34099632404b..8ff766a40d0e7 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelector.Serialization.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelector.Serialization.cs @@ -8,7 +8,6 @@ using System; using System.Text.Json; using Azure.Core; -using Azure.Messaging.EventGrid.Models; namespace Azure.Messaging.EventGrid.SystemEvents { diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelector.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelector.cs index 463205d1f9c3a..4ab047de7d932 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelector.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelector.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using Azure.Messaging.EventGrid.Models; namespace Azure.Messaging.EventGrid.SystemEvents { @@ -20,29 +19,25 @@ internal AcsRouterWorkerSelector() /// Initializes a new instance of AcsRouterWorkerSelector. /// Router Job Worker Selector Key. - /// Router Job Worker Selector Label Operator. + /// Router Job Worker Selector Label Operator. /// Router Job Worker Selector Value. /// Router Job Worker Selector Time to Live in Seconds. - /// Router Job Worker Selector State. + /// Router Job Worker Selector State. /// Router Job Worker Selector Expiration Time. - internal AcsRouterWorkerSelector(string key, AcsRouterLabelOperator? labelOperator, object labelValue, float? ttlSeconds, AcsRouterWorkerSelectorState? state, DateTimeOffset? expirationTime) + internal AcsRouterWorkerSelector(string key, AcsRouterLabelOperator? @operator, object labelValue, float? ttlSeconds, AcsRouterWorkerSelectorState? selectorState, DateTimeOffset? expirationTime) { Key = key; - LabelOperator = labelOperator; + Operator = @operator; LabelValue = labelValue; TtlSeconds = ttlSeconds; - State = state; + SelectorState = selectorState; ExpirationTime = expirationTime; } /// Router Job Worker Selector Key. public string Key { get; } - /// Router Job Worker Selector Label Operator. - public AcsRouterLabelOperator? LabelOperator { get; } /// Router Job Worker Selector Value. public object LabelValue { get; } - /// Router Job Worker Selector State. - public AcsRouterWorkerSelectorState? State { get; } /// Router Job Worker Selector Expiration Time. public DateTimeOffset? ExpirationTime { get; } } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelectorState.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelectorState.cs index 31d73348c3390..b859d35382d26 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelectorState.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/AcsRouterWorkerSelectorState.cs @@ -8,7 +8,7 @@ using System; using System.ComponentModel; -namespace Azure.Messaging.EventGrid.Models +namespace Azure.Messaging.EventGrid.SystemEvents { /// Router Job Worker Selector State. public readonly partial struct AcsRouterWorkerSelectorState : IEquatable diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md b/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md index 2677c9d90707d..7287d5e78dc17 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md @@ -155,6 +155,15 @@ directive: { $[path]["properties"]["disconnectionReason"]["x-namespace"] = namespace; } + if (path.includes("AcsRouterJobReceivedEventData")) + { + $[path]["properties"]["jobStatus"]["x-namespace"] = namespace; + } + if (path.includes("AcsRouterWorkerSelector")) + { + $[path]["properties"]["labelOperator"]["x-namespace"] = namespace; + $[path]["properties"]["state"]["x-namespace"] = namespace; + } } ``` diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs index 55499ea160186..a5d94ccbe2768 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using Azure.Messaging.EventGrid.Models; +using AcsRouterJobStatus = Azure.Messaging.EventGrid.Models.AcsRouterJobStatus; namespace Azure.Messaging.EventGrid.Tests { @@ -3856,7 +3857,8 @@ public void ConsumeCloudEventAcsRouterJobQueuedEvent() ""key"": ""string"", ""labelOperator"": ""equal"", ""value"": 5, - ""ttlSeconds"": 1000 + ""ttlSeconds"": 1000, + ""state"": ""active"" } ] }, @@ -3874,7 +3876,62 @@ public void ConsumeCloudEventAcsRouterJobQueuedEvent() var selectors = routerJobQueuedEventData.AttachedWorkerSelectors; Assert.AreEqual(1, selectors.Count); Assert.AreEqual(TimeSpan.FromSeconds(1000), selectors[0].TimeToLive); - Assert.AreEqual(AcsRouterLabelOperator.Equal, selectors[0].LabelOperator); + Assert.AreEqual(Azure.Messaging.EventGrid.Models.AcsRouterLabelOperator.Equal, selectors[0].LabelOperator); + Assert.AreEqual(Azure.Messaging.EventGrid.SystemEvents.AcsRouterLabelOperator.Equal, selectors[0].Operator); + + Assert.AreEqual(Azure.Messaging.EventGrid.Models.AcsRouterWorkerSelectorState.Active, selectors[0].State); + Assert.AreEqual(Azure.Messaging.EventGrid.SystemEvents.AcsRouterWorkerSelectorState.Active, selectors[0].SelectorState); + } + + [Test] + public void ConsumeCloudEventAcsRouterJobReceivedEvent() + { + string requestContent = @"{ + ""id"": ""acdf8fa5-8ab4-4a65-874a-c1d2a4a97f2e"", + ""source"": ""/subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}"", + ""subject"": ""job/{job-id}/channel/{channel-id}"", + ""data"": { + ""jobId"": ""7f1df17b-570b-4ae5-9cf5-fe6ff64cc712"", + ""channelReference"": ""test-abc"", + ""jobStatus"": ""PendingClassification"", + ""channelId"": ""FooVoiceChannelId"", + ""classificationPolicyId"": ""test-policy"", + ""queueId"": ""queue-id"", + ""priority"": 0, + ""labels"": { + ""Locale"": ""en-us"", + ""Segment"": ""Enterprise"", + ""Token"": ""FooToken"" + }, + ""tags"": { + ""Locale"": ""en-us"", + ""Segment"": ""Enterprise"", + ""Token"": ""FooToken"" + }, + ""requestedWorkerSelectors"": [ + { + ""key"": ""string"", + ""labelOperator"": ""equal"", + ""value"": 5, + ""ttlSeconds"": 36 + } + ], + ""scheduledOn"": ""3/28/2007 7:13:50 PM +00:00"", + ""unavailableForMatching"": false + }, + ""type"": ""Microsoft.Communication.RouterJobReceived"", + ""specversion"": ""1.0"", + ""time"": ""2022-02-17T00:55:25.1736293Z"" + }"; + + CloudEvent[] events = CloudEvent.ParseMany(new BinaryData(requestContent)); + + Assert.NotNull(events); + events[0].TryGetSystemEventData(out object eventData); + var routerJobReceivedEventData = eventData as AcsRouterJobReceivedEventData; + Assert.IsNotNull(routerJobReceivedEventData); + Assert.AreEqual(Azure.Messaging.EventGrid.Models.AcsRouterJobStatus.PendingClassification, routerJobReceivedEventData.JobStatus); + Assert.AreEqual(Azure.Messaging.EventGrid.SystemEvents.AcsRouterJobStatus.PendingClassification, routerJobReceivedEventData.Status); } #endregion