From df97af710e4b6cf5c72b21d68d78ff84b0d9bbe6 Mon Sep 17 00:00:00 2001 From: williamzhao87 Date: Tue, 14 Nov 2023 18:16:09 -0500 Subject: [PATCH 1/2] [JobRouter] Re-add protocol methods --- ....Communication.JobRouter.netstandard2.0.cs | 15 ++ .../Models/JobRouterAdministrationClient.cs | 246 +++++++++++++++++- .../src/Models/JobRouterClient.cs | 143 +++++++++- 3 files changed, 387 insertions(+), 17 deletions(-) diff --git a/sdk/communication/Azure.Communication.JobRouter/api/Azure.Communication.JobRouter.netstandard2.0.cs b/sdk/communication/Azure.Communication.JobRouter/api/Azure.Communication.JobRouter.netstandard2.0.cs index e027a41c1d3a2..bfc5b30f5f5a0 100644 --- a/sdk/communication/Azure.Communication.JobRouter/api/Azure.Communication.JobRouter.netstandard2.0.cs +++ b/sdk/communication/Azure.Communication.JobRouter/api/Azure.Communication.JobRouter.netstandard2.0.cs @@ -319,19 +319,25 @@ public JobRouterAdministrationClient(System.Uri endpoint, Azure.Core.TokenCreden public virtual System.Threading.Tasks.Task DeleteExceptionPolicyAsync(string exceptionPolicyId, Azure.RequestContext context = null) { throw null; } public virtual Azure.Response DeleteQueue(string queueId, Azure.RequestContext context = null) { throw null; } public virtual System.Threading.Tasks.Task DeleteQueueAsync(string queueId, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Pageable GetClassificationPolicies(Azure.RequestContext context) { throw null; } public virtual Azure.Pageable GetClassificationPolicies(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetClassificationPoliciesAsync(Azure.RequestContext context) { throw null; } public virtual Azure.AsyncPageable GetClassificationPoliciesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response GetClassificationPolicy(string classificationPolicyId, Azure.RequestContext context) { throw null; } public virtual Azure.Response GetClassificationPolicy(string classificationPolicyId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task GetClassificationPolicyAsync(string classificationPolicyId, Azure.RequestContext context) { throw null; } public virtual System.Threading.Tasks.Task> GetClassificationPolicyAsync(string classificationPolicyId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetDistributionPolicies(Azure.RequestContext context) { throw null; } public virtual Azure.Pageable GetDistributionPolicies(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetDistributionPoliciesAsync(Azure.RequestContext context) { throw null; } public virtual Azure.AsyncPageable GetDistributionPoliciesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response GetDistributionPolicy(string distributionPolicyId, Azure.RequestContext context) { throw null; } public virtual Azure.Response GetDistributionPolicy(string distributionPolicyId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task GetDistributionPolicyAsync(string distributionPolicyId, Azure.RequestContext context) { throw null; } public virtual System.Threading.Tasks.Task> GetDistributionPolicyAsync(string distributionPolicyId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetExceptionPolicies(Azure.RequestContext context) { throw null; } public virtual Azure.Pageable GetExceptionPolicies(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetExceptionPoliciesAsync(Azure.RequestContext context) { throw null; } public virtual Azure.AsyncPageable GetExceptionPoliciesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response GetExceptionPolicy(string exceptionPolicyId, Azure.RequestContext context) { throw null; } public virtual Azure.Response GetExceptionPolicy(string exceptionPolicyId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -341,7 +347,9 @@ public JobRouterAdministrationClient(System.Uri endpoint, Azure.Core.TokenCreden public virtual Azure.Response GetQueue(string queueId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task GetQueueAsync(string queueId, Azure.RequestContext context) { throw null; } public virtual System.Threading.Tasks.Task> GetQueueAsync(string queueId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetQueues(Azure.RequestContext context) { throw null; } public virtual Azure.Pageable GetQueues(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetQueuesAsync(Azure.RequestContext context) { throw null; } public virtual Azure.AsyncPageable GetQueuesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response UpdateClassificationPolicy(Azure.Communication.JobRouter.ClassificationPolicy classificationPolicy, Azure.RequestConditions requestConditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response UpdateClassificationPolicy(string classificationPolicyId, Azure.Core.RequestContent content, Azure.RequestConditions requestConditions = null, Azure.RequestContext context = null) { throw null; } @@ -352,8 +360,11 @@ public JobRouterAdministrationClient(System.Uri endpoint, Azure.Core.TokenCreden public virtual System.Threading.Tasks.Task> UpdateDistributionPolicyAsync(Azure.Communication.JobRouter.DistributionPolicy distributionPolicy, Azure.RequestConditions requestConditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task UpdateDistributionPolicyAsync(string distributionPolicyId, Azure.Core.RequestContent content, Azure.RequestConditions requestConditions = null, Azure.RequestContext context = null) { throw null; } public virtual Azure.Response UpdateExceptionPolicy(Azure.Communication.JobRouter.ExceptionPolicy exceptionPolicy, Azure.RequestConditions requestConditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response UpdateExceptionPolicy(string exceptionPolicyId, Azure.Core.RequestContent content, Azure.RequestConditions requestConditions = null, Azure.RequestContext context = null) { throw null; } public virtual System.Threading.Tasks.Task> UpdateExceptionPolicyAsync(Azure.Communication.JobRouter.ExceptionPolicy exceptionPolicy, Azure.RequestConditions requestConditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task UpdateExceptionPolicyAsync(string exceptionPolicyId, Azure.Core.RequestContent content, Azure.RequestConditions requestConditions = null, Azure.RequestContext context = null) { throw null; } public virtual Azure.Response UpdateQueue(Azure.Communication.JobRouter.RouterQueue queue, Azure.RequestConditions requestConditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response UpdateQueue(string queueId, Azure.Core.RequestContent content, Azure.RequestConditions requestConditions = null, Azure.RequestContext context = null) { throw null; } public virtual System.Threading.Tasks.Task> UpdateQueueAsync(Azure.Communication.JobRouter.RouterQueue queue, Azure.RequestConditions requestConditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task UpdateQueueAsync(string queueId, Azure.Core.RequestContent content, Azure.RequestConditions requestConditions = null, Azure.RequestContext context = null) { throw null; } } @@ -399,7 +410,9 @@ public JobRouterClient(System.Uri endpoint, Azure.Core.TokenCredential credentia public virtual System.Threading.Tasks.Task GetJobAsync(string jobId, Azure.RequestContext context) { throw null; } public virtual System.Threading.Tasks.Task> GetJobAsync(string jobId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetJobs(Azure.Communication.JobRouter.RouterJobStatusSelector? status = default(Azure.Communication.JobRouter.RouterJobStatusSelector?), string queueId = null, string channelId = null, string classificationPolicyId = null, System.DateTimeOffset? scheduledBefore = default(System.DateTimeOffset?), System.DateTimeOffset? scheduledAfter = default(System.DateTimeOffset?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetJobs(string status, string queueId, string channelId, string classificationPolicyId, System.DateTimeOffset? scheduledBefore, System.DateTimeOffset? scheduledAfter, Azure.RequestContext context) { throw null; } public virtual Azure.AsyncPageable GetJobsAsync(Azure.Communication.JobRouter.RouterJobStatusSelector? status = default(Azure.Communication.JobRouter.RouterJobStatusSelector?), string queueId = null, string channelId = null, string classificationPolicyId = null, System.DateTimeOffset? scheduledBefore = default(System.DateTimeOffset?), System.DateTimeOffset? scheduledAfter = default(System.DateTimeOffset?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetJobsAsync(string status, string queueId, string channelId, string classificationPolicyId, System.DateTimeOffset? scheduledBefore, System.DateTimeOffset? scheduledAfter, Azure.RequestContext context) { throw null; } public virtual Azure.Response GetQueuePosition(string jobId, Azure.RequestContext context) { throw null; } public virtual Azure.Response GetQueuePosition(string jobId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task GetQueuePositionAsync(string jobId, Azure.RequestContext context) { throw null; } @@ -413,7 +426,9 @@ public JobRouterClient(System.Uri endpoint, Azure.Core.TokenCredential credentia public virtual System.Threading.Tasks.Task GetWorkerAsync(string workerId, Azure.RequestContext context) { throw null; } public virtual System.Threading.Tasks.Task> GetWorkerAsync(string workerId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetWorkers(Azure.Communication.JobRouter.RouterWorkerStateSelector? state = default(Azure.Communication.JobRouter.RouterWorkerStateSelector?), string channelId = null, string queueId = null, bool? hasCapacity = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetWorkers(string state, string channelId, string queueId, bool? hasCapacity, Azure.RequestContext context) { throw null; } public virtual Azure.AsyncPageable GetWorkersAsync(Azure.Communication.JobRouter.RouterWorkerStateSelector? state = default(Azure.Communication.JobRouter.RouterWorkerStateSelector?), string channelId = null, string queueId = null, bool? hasCapacity = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetWorkersAsync(string state, string channelId, string queueId, bool? hasCapacity, Azure.RequestContext context) { throw null; } public virtual Azure.Response ReclassifyJob(string jobId, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } public virtual Azure.Response ReclassifyJob(string jobId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task ReclassifyJobAsync(string jobId, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } diff --git a/sdk/communication/Azure.Communication.JobRouter/src/Models/JobRouterAdministrationClient.cs b/sdk/communication/Azure.Communication.JobRouter/src/Models/JobRouterAdministrationClient.cs index 7c28e3245ab2c..383ad614baf8c 100644 --- a/sdk/communication/Azure.Communication.JobRouter/src/Models/JobRouterAdministrationClient.cs +++ b/sdk/communication/Azure.Communication.JobRouter/src/Models/JobRouterAdministrationClient.cs @@ -326,14 +326,70 @@ public virtual Response UpdateClassificationPolicy(string classificationPolicyId /// The cancellation token to use. public virtual AsyncPageable GetClassificationPoliciesAsync(CancellationToken cancellationToken = default) { - return GetClassificationPoliciesAsync(null, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetClassificationPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetClassificationPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, ClassificationPolicy.DeserializeClassificationPolicy, ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetClassificationPolicies", "value", "nextLink", context); } /// Retrieves existing classification policies. /// The cancellation token to use. public virtual Pageable GetClassificationPolicies(CancellationToken cancellationToken = default) { - return GetClassificationPolicies(null, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetClassificationPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetClassificationPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, ClassificationPolicy.DeserializeClassificationPolicy, ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetClassificationPolicies", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves existing classification policies. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual AsyncPageable GetClassificationPoliciesAsync(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetClassificationPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetClassificationPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetClassificationPolicies", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves existing classification policies. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual Pageable GetClassificationPolicies(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetClassificationPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetClassificationPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetClassificationPolicies", "value", "nextLink", context); } #endregion ClassificationPolicy @@ -546,14 +602,70 @@ public virtual Response UpdateDistributionPolicy(string distributionPolicyId, Re /// The cancellation token to use. public virtual AsyncPageable GetDistributionPoliciesAsync(CancellationToken cancellationToken = default) { - return GetDistributionPoliciesAsync(null, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDistributionPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDistributionPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, DistributionPolicy.DeserializeDistributionPolicy, ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetDistributionPolicies", "value", "nextLink", context); } /// Retrieves existing distribution policies. /// The cancellation token to use. public virtual Pageable GetDistributionPolicies(CancellationToken cancellationToken = default) { - return GetDistributionPolicies(null, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDistributionPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDistributionPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, DistributionPolicy.DeserializeDistributionPolicy, ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetDistributionPolicies", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves existing distribution policies. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual AsyncPageable GetDistributionPoliciesAsync(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDistributionPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDistributionPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetDistributionPolicies", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves existing distribution policies. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual Pageable GetDistributionPolicies(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDistributionPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDistributionPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetDistributionPolicies", "value", "nextLink", context); } #endregion DistributionPolicy @@ -704,7 +816,7 @@ public virtual Response UpdateExceptionPolicy( /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task UpdateExceptionPolicyAsync(string exceptionPolicyId, RequestContent content, RequestConditions requestConditions = null, RequestContext context = null) + public virtual async Task UpdateExceptionPolicyAsync(string exceptionPolicyId, RequestContent content, RequestConditions requestConditions = null, RequestContext context = null) { Argument.AssertNotNullOrEmpty(exceptionPolicyId, nameof(exceptionPolicyId)); Argument.AssertNotNull(content, nameof(content)); @@ -744,7 +856,7 @@ internal virtual async Task UpdateExceptionPolicyAsync(string exceptio /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response UpdateExceptionPolicy(string exceptionPolicyId, RequestContent content, RequestConditions requestConditions = null, RequestContext context = null) + public virtual Response UpdateExceptionPolicy(string exceptionPolicyId, RequestContent content, RequestConditions requestConditions = null, RequestContext context = null) { Argument.AssertNotNullOrEmpty(exceptionPolicyId, nameof(exceptionPolicyId)); Argument.AssertNotNull(content, nameof(content)); @@ -770,14 +882,70 @@ internal virtual Response UpdateExceptionPolicy(string exceptionPolicyId, Reques /// The cancellation token to use. public virtual AsyncPageable GetExceptionPoliciesAsync(CancellationToken cancellationToken = default) { - return GetExceptionPoliciesAsync(null, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetExceptionPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetExceptionPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, ExceptionPolicy.DeserializeExceptionPolicy, ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetExceptionPolicies", "value", "nextLink", context); } /// Retrieves existing exception policies. /// The cancellation token to use. public virtual Pageable GetExceptionPolicies(CancellationToken cancellationToken = default) { - return GetExceptionPolicies(null, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetExceptionPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetExceptionPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, ExceptionPolicy.DeserializeExceptionPolicy, ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetExceptionPolicies", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves existing exception policies. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual AsyncPageable GetExceptionPoliciesAsync(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetExceptionPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetExceptionPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetExceptionPolicies", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves existing exception policies. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual Pageable GetExceptionPolicies(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetExceptionPoliciesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetExceptionPoliciesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetExceptionPolicies", "value", "nextLink", context); } #endregion ExceptionPolicy @@ -979,7 +1147,7 @@ public virtual async Task UpdateQueueAsync(string queueId, RequestCont /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response UpdateQueue(string queueId, RequestContent content, RequestConditions requestConditions = null, RequestContext context = null) + public virtual Response UpdateQueue(string queueId, RequestContent content, RequestConditions requestConditions = null, RequestContext context = null) { Argument.AssertNotNullOrEmpty(queueId, nameof(queueId)); Argument.AssertNotNull(content, nameof(content)); @@ -1005,14 +1173,70 @@ internal virtual Response UpdateQueue(string queueId, RequestContent content, Re /// The cancellation token to use. public virtual AsyncPageable GetQueuesAsync(CancellationToken cancellationToken = default) { - return GetQueuesAsync(null, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetQueuesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetQueuesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, RouterQueue.DeserializeRouterQueue, ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetQueues", "value", "nextLink", context); } /// Retrieves existing exception policies. /// The cancellation token to use. public virtual Pageable GetQueues(CancellationToken cancellationToken = default) { - return GetQueues(null, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetQueuesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetQueuesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, RouterQueue.DeserializeRouterQueue, ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetQueues", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves existing queues. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual AsyncPageable GetQueuesAsync(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetQueuesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetQueuesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetQueues", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves existing queues. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual Pageable GetQueues(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetQueuesRequest(pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetQueuesNextPageRequest(nextLink, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterAdministrationClient.GetQueues", "value", "nextLink", context); } #endregion Queue diff --git a/sdk/communication/Azure.Communication.JobRouter/src/Models/JobRouterClient.cs b/sdk/communication/Azure.Communication.JobRouter/src/Models/JobRouterClient.cs index 8e25cf2a30145..4bdaade3a28d7 100644 --- a/sdk/communication/Azure.Communication.JobRouter/src/Models/JobRouterClient.cs +++ b/sdk/communication/Azure.Communication.JobRouter/src/Models/JobRouterClient.cs @@ -7,6 +7,7 @@ using Azure.Communication.Pipeline; using Azure.Core; using Azure.Core.Pipeline; +using Autorest.CSharp.Core; namespace Azure.Communication.JobRouter { @@ -1183,8 +1184,10 @@ public virtual AsyncPageable GetJobsAsync(RouterJobStatusSelector? st DateTimeOffset? scheduledBefore = null, DateTimeOffset? scheduledAfter = null, CancellationToken cancellationToken = default) { - return GetJobsAsync(null, status, queueId, channelId, classificationPolicyId, scheduledBefore, - scheduledAfter, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetJobsRequest(pageSizeHint, status?.ToString(), queueId, channelId, classificationPolicyId, scheduledBefore, scheduledAfter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetJobsNextPageRequest(nextLink, pageSizeHint, status?.ToString(), queueId, channelId, classificationPolicyId, scheduledBefore, scheduledAfter, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, RouterJob.DeserializeRouterJob, ClientDiagnostics, _pipeline, "JobRouterClient.GetJobs", "value", "nextLink", context); } /// Retrieves list of jobs based on filter parameters. @@ -1199,8 +1202,72 @@ public virtual Pageable GetJobs(RouterJobStatusSelector? status = nul string channelId = null, string classificationPolicyId = null, DateTimeOffset? scheduledBefore = null, DateTimeOffset? scheduledAfter = null, CancellationToken cancellationToken = default) { - return GetJobs(null, status, queueId, channelId, classificationPolicyId, scheduledBefore, scheduledAfter, - cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetJobsRequest(pageSizeHint, status?.ToString(), queueId, channelId, classificationPolicyId, scheduledBefore, scheduledAfter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetJobsNextPageRequest(nextLink, pageSizeHint, status?.ToString(), queueId, channelId, classificationPolicyId, scheduledBefore, scheduledAfter, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, RouterJob.DeserializeRouterJob, ClientDiagnostics, _pipeline, "JobRouterClient.GetJobs", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves list of jobs based on filter parameters. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// If specified, filter jobs by status. Allowed values: "all" | "pendingClassification" | "queued" | "assigned" | "completed" | "closed" | "cancelled" | "classificationFailed" | "created" | "pendingSchedule" | "scheduled" | "scheduleFailed" | "waitingForActivation" | "active". + /// If specified, filter jobs by queue. + /// If specified, filter jobs by channel. + /// If specified, filter jobs by classificationPolicy. + /// If specified, filter on jobs that was scheduled before or at given timestamp. Range: (-Inf, scheduledBefore]. + /// If specified, filter on jobs that was scheduled at or after given value. Range: [scheduledAfter, +Inf). + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual AsyncPageable GetJobsAsync(string status, string queueId, string channelId, string classificationPolicyId, DateTimeOffset? scheduledBefore, DateTimeOffset? scheduledAfter, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetJobsRequest(pageSizeHint, status, queueId, channelId, classificationPolicyId, scheduledBefore, scheduledAfter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetJobsNextPageRequest(nextLink, pageSizeHint, status, queueId, channelId, classificationPolicyId, scheduledBefore, scheduledAfter, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterClient.GetJobs", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves list of jobs based on filter parameters. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// If specified, filter jobs by status. Allowed values: "all" | "pendingClassification" | "queued" | "assigned" | "completed" | "closed" | "cancelled" | "classificationFailed" | "created" | "pendingSchedule" | "scheduled" | "scheduleFailed" | "waitingForActivation" | "active". + /// If specified, filter jobs by queue. + /// If specified, filter jobs by channel. + /// If specified, filter jobs by classificationPolicy. + /// If specified, filter on jobs that was scheduled before or at given timestamp. Range: (-Inf, scheduledBefore]. + /// If specified, filter on jobs that was scheduled at or after given value. Range: [scheduledAfter, +Inf). + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual Pageable GetJobs(string status, string queueId, string channelId, string classificationPolicyId, DateTimeOffset? scheduledBefore, DateTimeOffset? scheduledAfter, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetJobsRequest(pageSizeHint, status, queueId, channelId, classificationPolicyId, scheduledBefore, scheduledAfter, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetJobsNextPageRequest(nextLink, pageSizeHint, status, queueId, channelId, classificationPolicyId, scheduledBefore, scheduledAfter, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterClient.GetJobs", "value", "nextLink", context); } #endregion Job @@ -1445,7 +1512,10 @@ public virtual Response UpdateWorker(string workerId, RequestContent content, Re /// The cancellation token to use. public virtual AsyncPageable GetWorkersAsync(RouterWorkerStateSelector? state = null, string channelId = null, string queueId = null, bool? hasCapacity = null, CancellationToken cancellationToken = default) { - return GetWorkersAsync(null, state, channelId, queueId, hasCapacity, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetWorkersRequest(pageSizeHint, state?.ToString(), channelId, queueId, hasCapacity, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetWorkersNextPageRequest(nextLink, pageSizeHint, state?.ToString(), channelId, queueId, hasCapacity, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, RouterWorker.DeserializeRouterWorker, ClientDiagnostics, _pipeline, "JobRouterClient.GetWorkers", "value", "nextLink", context); } /// Retrieves existing workers. @@ -1456,7 +1526,68 @@ public virtual AsyncPageable GetWorkersAsync(RouterWorkerStateSele /// The cancellation token to use. public virtual Pageable GetWorkers(RouterWorkerStateSelector? state = null, string channelId = null, string queueId = null, bool? hasCapacity = null, CancellationToken cancellationToken = default) { - return GetWorkers(null, state, channelId, queueId, hasCapacity, cancellationToken); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetWorkersRequest(pageSizeHint, state?.ToString(), channelId, queueId, hasCapacity, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetWorkersNextPageRequest(nextLink, pageSizeHint, state?.ToString(), channelId, queueId, hasCapacity, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, RouterWorker.DeserializeRouterWorker, ClientDiagnostics, _pipeline, "JobRouterClient.GetWorkers", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves existing workers. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// If specified, select workers by worker state. Allowed values: "active" | "draining" | "inactive" | "all". + /// If specified, select workers who have a channel configuration with this channel. + /// If specified, select workers who are assigned to this queue. + /// If set to true, select only workers who have capacity for the channel specified by `channelId` or for any channel if `channelId` not specified. If set to false, then will return all workers including workers without any capacity for jobs. Defaults to false. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual AsyncPageable GetWorkersAsync(string state, string channelId, string queueId, bool? hasCapacity, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetWorkersRequest(pageSizeHint, state, channelId, queueId, hasCapacity, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetWorkersNextPageRequest(nextLink, pageSizeHint, state, channelId, queueId, hasCapacity, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterClient.GetWorkers", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Retrieves existing workers. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// If specified, select workers by worker state. Allowed values: "active" | "draining" | "inactive" | "all". + /// If specified, select workers who have a channel configuration with this channel. + /// If specified, select workers who are assigned to this queue. + /// If set to true, select only workers who have capacity for the channel specified by `channelId` or for any channel if `channelId` not specified. If set to false, then will return all workers including workers without any capacity for jobs. Defaults to false. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual Pageable GetWorkers(string state, string channelId, string queueId, bool? hasCapacity, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetWorkersRequest(pageSizeHint, state, channelId, queueId, hasCapacity, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetWorkersNextPageRequest(nextLink, pageSizeHint, state, channelId, queueId, hasCapacity, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "JobRouterClient.GetWorkers", "value", "nextLink", context); } #endregion Worker From be5d9c1d10175b3c2cf600333860aa6e615b18e0 Mon Sep 17 00:00:00 2001 From: williamzhao87 Date: Tue, 14 Nov 2023 18:40:49 -0500 Subject: [PATCH 2/2] Update records --- sdk/communication/Azure.Communication.JobRouter/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/communication/Azure.Communication.JobRouter/assets.json b/sdk/communication/Azure.Communication.JobRouter/assets.json index 28577495791b4..f7cbb1775b52e 100644 --- a/sdk/communication/Azure.Communication.JobRouter/assets.json +++ b/sdk/communication/Azure.Communication.JobRouter/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/communication/Azure.Communication.JobRouter", - "Tag": "net/communication/Azure.Communication.JobRouter_cf5426ddc5" + "Tag": "net/communication/Azure.Communication.JobRouter_0250925020" }