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

[JobRouter] Fix job/queue/worker updates #37835

Merged
merged 1 commit into from
Jul 25, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -652,36 +652,36 @@ public UpdateExceptionPolicyOptions(string exceptionPolicyId) { }
public partial class UpdateJobOptions
{
public UpdateJobOptions(string jobId) { }
public string ChannelId { get { throw null; } set { } }
public string ChannelReference { get { throw null; } set { } }
public string ClassificationPolicyId { get { throw null; } set { } }
public string DispositionCode { get { throw null; } set { } }
public string? ChannelId { get { throw null; } set { } }
public string? ChannelReference { get { throw null; } set { } }
public string? ClassificationPolicyId { get { throw null; } set { } }
public string? DispositionCode { get { throw null; } set { } }
public string JobId { get { throw null; } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.LabelValue> Labels { get { throw null; } }
public Azure.Communication.JobRouter.JobMatchingMode MatchingMode { get { throw null; } set { } }
public System.Collections.Generic.List<Azure.Communication.JobRouter.RouterJobNote> Notes { get { throw null; } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.LabelValue?> Labels { get { throw null; } }
public Azure.Communication.JobRouter.JobMatchingMode? MatchingMode { get { throw null; } set { } }
public System.Collections.Generic.List<Azure.Communication.JobRouter.RouterJobNote?> Notes { get { throw null; } }
public int? Priority { get { throw null; } set { } }
public string QueueId { get { throw null; } set { } }
public string? QueueId { get { throw null; } set { } }
public System.Collections.Generic.List<Azure.Communication.JobRouter.RouterWorkerSelector> RequestedWorkerSelectors { get { throw null; } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.LabelValue> Tags { get { throw null; } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.LabelValue?> Tags { get { throw null; } }
}
public partial class UpdateQueueOptions
{
public UpdateQueueOptions(string queueId) { }
public string DistributionPolicyId { get { throw null; } set { } }
public string ExceptionPolicyId { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.LabelValue> Labels { get { throw null; } }
public string Name { get { throw null; } set { } }
public string? DistributionPolicyId { get { throw null; } set { } }
public string? ExceptionPolicyId { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.LabelValue?> Labels { get { throw null; } }
public string? Name { get { throw null; } set { } }
public string QueueId { get { throw null; } }
}
public partial class UpdateWorkerOptions
{
public UpdateWorkerOptions(string workerId) { }
public bool? AvailableForOffers { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.ChannelConfiguration?> ChannelConfigurations { get { throw null; } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.LabelValue> Labels { get { throw null; } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.LabelValue?> Labels { get { throw null; } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.RouterQueueAssignment?> QueueAssignments { get { throw null; } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.LabelValue> Tags { get { throw null; } }
public System.Collections.Generic.IDictionary<string, Azure.Communication.JobRouter.LabelValue?> Tags { get { throw null; } }
public int? TotalCapacity { get { throw null; } set { } }
public string WorkerId { get { throw null; } }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable enable
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
Expand All @@ -9,10 +10,12 @@ namespace Azure.Communication.JobRouter
{
internal static class Extensions
{
public static IDictionary<TK, TV> Append<TK, TV>(this IDictionary<TK, TV> first, IDictionary<TK, TV> second)
public static IDictionary<TK, TV?> Append<TK, TV>(this IDictionary<TK, TV?> first, IDictionary<TK, TV?> second)
{
second.ToList().ForEach(pair => first[pair.Key] = pair.Value);
return second;
}
}
}

#nullable restore
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ public virtual async Task<Response<RouterWorker>> CreateWorkerAsync(

foreach (var queueAssignment in options.QueueAssignments)
{
request.QueueAssignments[queueAssignment.Key] = new RouterQueueAssignment();
request.QueueAssignments[queueAssignment.Key] = queueAssignment.Value;
}

foreach (var label in options.Labels)
Expand All @@ -1182,10 +1182,7 @@ public virtual async Task<Response<RouterWorker>> CreateWorkerAsync(

foreach (var channel in options.ChannelConfigurations)
{
request.ChannelConfigurations[channel.Key] = new ChannelConfiguration(channel.Value.CapacityCostPerJob)
{
MaxNumberOfJobs = channel.Value.MaxNumberOfJobs
};
request.ChannelConfigurations[channel.Key] = channel.Value;
}

var response = await RestClient.UpsertWorkerAsync(
Expand Down Expand Up @@ -1222,7 +1219,7 @@ public virtual Response<RouterWorker> CreateWorker(

foreach (var queueAssignment in options.QueueAssignments)
{
request.QueueAssignments[queueAssignment.Key] = new RouterQueueAssignment();
request.QueueAssignments[queueAssignment.Key] = queueAssignment.Value;
}

foreach (var label in options.Labels)
Expand All @@ -1237,10 +1234,7 @@ public virtual Response<RouterWorker> CreateWorker(

foreach (var channel in options.ChannelConfigurations)
{
request.ChannelConfigurations[channel.Key] = new ChannelConfiguration(channel.Value.CapacityCostPerJob)
{
MaxNumberOfJobs = channel.Value.MaxNumberOfJobs
};
request.ChannelConfigurations[channel.Key] = channel.Value;
}

var response = RestClient.UpsertWorker(
Expand Down Expand Up @@ -1270,13 +1264,13 @@ public virtual async Task<Response<RouterWorker>> UpdateWorkerAsync(
{
var request = new RouterWorker()
{
TotalCapacity = options.TotalCapacity,
TotalCapacity = options?.TotalCapacity,
AvailableForOffers = options?.AvailableForOffers
};

foreach (var queueAssignment in options.QueueAssignments)
{
request.QueueAssignments[queueAssignment.Key] = new RouterQueueAssignment();
request.QueueAssignments[queueAssignment.Key] = queueAssignment.Value;
}

foreach (var label in options.Labels)
Expand All @@ -1291,10 +1285,7 @@ public virtual async Task<Response<RouterWorker>> UpdateWorkerAsync(

foreach (var channel in options.ChannelConfigurations)
{
request.ChannelConfigurations[channel.Key] = new ChannelConfiguration(channel.Value.CapacityCostPerJob)
{
MaxNumberOfJobs = channel.Value.MaxNumberOfJobs
};
request.ChannelConfigurations[channel.Key] = channel.Value;
}

var response = await RestClient.UpsertWorkerAsync(
Expand Down Expand Up @@ -1331,7 +1322,7 @@ public virtual Response<RouterWorker> UpdateWorker(

foreach (var queueAssignment in options.QueueAssignments)
{
request.QueueAssignments[queueAssignment.Key] = new RouterQueueAssignment();
request.QueueAssignments[queueAssignment.Key] = queueAssignment.Value;
}

foreach (var label in options.Labels)
Expand All @@ -1346,10 +1337,7 @@ public virtual Response<RouterWorker> UpdateWorker(

foreach (var channel in options.ChannelConfigurations)
{
request.ChannelConfigurations[channel.Key] = new ChannelConfiguration(channel.Value.CapacityCostPerJob)
{
MaxNumberOfJobs = channel.Value.MaxNumberOfJobs
};
request.ChannelConfigurations[channel.Key] = channel.Value;
}

var response = RestClient.UpsertWorker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal IDictionary<string, object> _labelsToUpsert
get
{
return LabelsToUpsert != null && LabelsToUpsert.Count != 0
? LabelsToUpsert?.ToDictionary(x => x.Key, x => x.Value.Value)
? LabelsToUpsert?.ToDictionary(x => x.Key, x => x.Value?.Value)
: new ChangeTrackingDictionary<string, object>();
}
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal IDictionary<string, object> _labels
get
{
return Labels != null && Labels.Count != 0
? Labels?.ToDictionary(x => x.Key, x => x.Value.Value)
? Labels?.ToDictionary(x => x.Key, x => x.Value?.Value)
: new ChangeTrackingDictionary<string, object>();
}
set
Expand All @@ -87,7 +87,7 @@ internal IDictionary<string, object> _tags
get
{
return Tags != null && Tags.Count != 0
? Tags?.ToDictionary(x => x.Key, x => x.Value.Value)
? Tags?.ToDictionary(x => x.Key, x => x.Value?.Value)
: new ChangeTrackingDictionary<string, object>();
}
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal IDictionary<string, object> _labels
get
{
return Labels != null && Labels.Count != 0
? Labels?.ToDictionary(x => x.Key, x => x.Value.Value)
? Labels?.ToDictionary(x => x.Key, x => x.Value?.Value)
: new ChangeTrackingDictionary<string, object>();
}
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal IDictionary<string, object> _labels
get
{
return Labels != null && Labels.Count != 0
? Labels?.ToDictionary(x => x.Key, x => x.Value.Value)
? Labels?.ToDictionary(x => x.Key, x => x.Value?.Value)
: new ChangeTrackingDictionary<string, object>();
}
set
Expand All @@ -60,7 +60,7 @@ internal IDictionary<string, object> _tags
get
{
return Tags != null && Tags.Count != 0
? Tags?.ToDictionary(x => x.Key, x => x.Value.Value)
? Tags?.ToDictionary(x => x.Key, x => x.Value?.Value)
: new ChangeTrackingDictionary<string, object>();
}
set
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable enable
using System;
using System.Collections.Generic;
using System.Text;
Expand Down Expand Up @@ -34,38 +35,38 @@ public UpdateJobOptions(string jobId)
/// <summary>
/// A set of key/value pairs that are identifying attributes used by the rules engines to make decisions.
/// </summary>
public IDictionary<string, LabelValue> Labels { get; } = new Dictionary<string, LabelValue>();
public IDictionary<string, LabelValue?> Labels { get; } = new Dictionary<string, LabelValue?>();

/// <summary> Reference to an external parent context, eg. call ID. </summary>
public string ChannelReference { get; set; }
public string? ChannelReference { get; set; }

/// <summary> The Id of the Queue that this job is queued to. </summary>
public string QueueId { get; set; }
public string? QueueId { get; set; }

/// <summary> The Id of the Classification policy used for classifying a job. </summary>
public string ClassificationPolicyId { get; set; }
public string? ClassificationPolicyId { get; set; }

/// <summary> The channel identifier. eg. voice, chat, etc. </summary>
public string ChannelId { get; set; }
public string? ChannelId { get; set; }

/// <summary> The priority of this job (range from -100 to 100). </summary>
public int? Priority { get; set; }

/// <summary> Reason code for cancelled or closed jobs. </summary>
public string DispositionCode { get; set; }
public string? DispositionCode { get; set; }

/// <summary> A collection of manually specified label selectors, which a worker must satisfy in order to process this job. </summary>
public List<RouterWorkerSelector> RequestedWorkerSelectors { get; } = new List<RouterWorkerSelector>();

/// <summary> Notes attached to a job, sorted by timestamp. </summary>
public List<RouterJobNote> Notes { get; } = new List<RouterJobNote>();
public List<RouterJobNote?> Notes { get; } = new List<RouterJobNote?>();

/// <summary> A set of non-identifying attributes attached to this job. </summary>
public IDictionary<string, LabelValue> Tags { get; } = new Dictionary<string, LabelValue>();
public IDictionary<string, LabelValue?> Tags { get; } = new Dictionary<string, LabelValue?>();

/// <summary>
/// If provided, will determine how job matching will be carried out.
/// </summary>
public JobMatchingMode MatchingMode { get; set; }
public JobMatchingMode? MatchingMode { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable enable
using System;
using System.Collections.Generic;
using System.Text;
using Azure.Core;

namespace Azure.Communication.JobRouter
Expand Down Expand Up @@ -31,17 +31,17 @@ public UpdateQueueOptions(string queueId)
public string QueueId { get; }

/// <summary> The ID of the distribution policy that will determine how a job is distributed to workers. </summary>
public string DistributionPolicyId { get; set; }
public string? DistributionPolicyId { get; set; }

/// <summary> The name of this queue. </summary>
public string Name { get; set; }
public string? Name { get; set; }

/// <summary> (Optional) The ID of the exception policy that determines various job escalation rules. </summary>
public string ExceptionPolicyId { get; set; }
public string? ExceptionPolicyId { get; set; }

/// <summary>
/// A set of key/value pairs that are identifying attributes used by the rules engines to make decisions.
/// </summary>
public IDictionary<string, LabelValue> Labels { get; } = new Dictionary<string, LabelValue>();
public IDictionary<string, LabelValue?> Labels { get; } = new Dictionary<string, LabelValue?>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public UpdateWorkerOptions(string workerId)
/// <summary>
/// A set of key/value pairs that are identifying attributes used by the rules engines to make decisions.
/// </summary>
public IDictionary<string, LabelValue> Labels { get; } = new Dictionary<string, LabelValue>();
public IDictionary<string, LabelValue?> Labels { get; } = new Dictionary<string, LabelValue?>();

/// <summary>
/// A set of non-identifying attributes attached to this worker.
/// </summary>
public IDictionary<string, LabelValue> Tags { get; } = new Dictionary<string, LabelValue>();
public IDictionary<string, LabelValue?> Tags { get; } = new Dictionary<string, LabelValue?>();

/// <summary> The channel(s) this worker can handle and their impact on the workers capacity. </summary>
public IDictionary<string, ChannelConfiguration?> ChannelConfigurations { get; } = new Dictionary<string, ChannelConfiguration?>();
Expand Down
Loading