diff --git a/eng/deployment/product-construction-service-deploy.ps1 b/eng/deployment/product-construction-service-deploy.ps1 index 1c4ac33fb..3cb4ba140 100644 --- a/eng/deployment/product-construction-service-deploy.ps1 +++ b/eng/deployment/product-construction-service-deploy.ps1 @@ -16,8 +16,8 @@ param( $containerapp = az containerapp show -g $resourceGroupName -n $containerappName | ConvertFrom-Json $pcsUrl = "https://$($containerapp.properties.configuration.ingress.fqdn)" $pcsStatusUrl = $pcsUrl + "/status" -$pcsStopUrl = $pcsStatusUrl + "/stop" -$pcsStartUrl = $pcsStatusUrl + "/start" +$pcsStopUrl = $pcsStatusUrl + "/stop?api-version=2020-02-20" +$pcsStartUrl = $pcsStatusUrl + "/start?api-version=2020-02-20" $authenticationHeader = @{ "Authorization" = "Bearer $token" } diff --git a/src/ProductConstructionService/ProductConstructionService.Api/Controllers/StatusController.cs b/src/ProductConstructionService/ProductConstructionService.Api/Controllers/StatusController.cs index 5b531a9ba..8b989c930 100644 --- a/src/ProductConstructionService/ProductConstructionService.Api/Controllers/StatusController.cs +++ b/src/ProductConstructionService/ProductConstructionService.Api/Controllers/StatusController.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.AspNetCore.ApiVersioning; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.OpenApi.Extensions; @@ -10,6 +11,7 @@ namespace ProductConstructionService.Api.Controllers; [Route("status")] +[ApiVersion("2020-02-20")] public class StatusController(WorkItemScopeManager workItemScopeManager) : ControllerBase { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/ProductConstructionServiceApi.cs b/src/ProductConstructionService/ProductConstructionService.Client/Generated/ProductConstructionServiceApi.cs index 73f5d9ded..f593a21f9 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/ProductConstructionServiceApi.cs +++ b/src/ProductConstructionService/ProductConstructionService.Client/Generated/ProductConstructionServiceApi.cs @@ -35,6 +35,7 @@ public partial interface IProductConstructionServiceApi IChannels Channels { get; } IPipelines Pipelines { get; } IRepository Repository { get; } + IStatus Status { get; } ISubscriptions Subscriptions { get; } } @@ -129,6 +130,8 @@ public HttpPipeline Pipeline public IRepository Repository { get; } + public IStatus Status { get; } + public ISubscriptions Subscriptions { get; } @@ -149,6 +152,7 @@ public ProductConstructionServiceApi(ProductConstructionServiceApiOptions option Channels = new Channels(this); Pipelines = new Pipelines(this); Repository = new Repository(this); + Status = new Status(this); Subscriptions = new Subscriptions(this); SerializerSettings = new JsonSerializerSettings { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Status.cs b/src/ProductConstructionService/ProductConstructionService.Client/Generated/Status.cs new file mode 100644 index 000000000..42d7a5fcf --- /dev/null +++ b/src/ProductConstructionService/ProductConstructionService.Client/Generated/Status.cs @@ -0,0 +1,222 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; + + + +namespace ProductConstructionService.Client +{ + public partial interface IStatus + { + Task StopPcsWorkItemProcessorAsync( + CancellationToken cancellationToken = default + ); + + Task StartPcsWorkItemProcessorAsync( + CancellationToken cancellationToken = default + ); + + Task GetPcsWorkItemProcessorStatusAsync( + CancellationToken cancellationToken = default + ); + + } + + internal partial class Status : IServiceOperations, IStatus + { + public Status(ProductConstructionServiceApi client) + { + Client = client ?? throw new ArgumentNullException(nameof(client)); + } + + public ProductConstructionServiceApi Client { get; } + + partial void HandleFailedRequest(RestApiException ex); + + partial void HandleFailedStopPcsWorkItemProcessorRequest(RestApiException ex); + + public async Task StopPcsWorkItemProcessorAsync( + CancellationToken cancellationToken = default + ) + { + + const string apiVersion = "2020-02-20"; + + var _baseUri = Client.Options.BaseUri; + var _url = new RequestUriBuilder(); + _url.Reset(_baseUri); + _url.AppendPath( + "/api/status/stop", + false); + + _url.AppendQuery("api-version", Client.Serialize(apiVersion)); + + + using (var _req = Client.Pipeline.CreateRequest()) + { + _req.Uri = _url; + _req.Method = RequestMethod.Put; + + using (var _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false)) + { + if (_res.Status < 200 || _res.Status >= 300) + { + await OnStopPcsWorkItemProcessorFailed(_req, _res).ConfigureAwait(false); + } + + + return; + } + } + } + + internal async Task OnStopPcsWorkItemProcessorFailed(Request req, Response res) + { + string content = null; + if (res.ContentStream != null) + { + using (var reader = new StreamReader(res.ContentStream)) + { + content = await reader.ReadToEndAsync().ConfigureAwait(false); + } + } + + var ex = new RestApiException( + req, + res, + content, + Client.Deserialize(content) + ); + HandleFailedStopPcsWorkItemProcessorRequest(ex); + HandleFailedRequest(ex); + Client.OnFailedRequest(ex); + throw ex; + } + + partial void HandleFailedStartPcsWorkItemProcessorRequest(RestApiException ex); + + public async Task StartPcsWorkItemProcessorAsync( + CancellationToken cancellationToken = default + ) + { + + const string apiVersion = "2020-02-20"; + + var _baseUri = Client.Options.BaseUri; + var _url = new RequestUriBuilder(); + _url.Reset(_baseUri); + _url.AppendPath( + "/api/status/start", + false); + + _url.AppendQuery("api-version", Client.Serialize(apiVersion)); + + + using (var _req = Client.Pipeline.CreateRequest()) + { + _req.Uri = _url; + _req.Method = RequestMethod.Put; + + using (var _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false)) + { + if (_res.Status < 200 || _res.Status >= 300) + { + await OnStartPcsWorkItemProcessorFailed(_req, _res).ConfigureAwait(false); + } + + + return; + } + } + } + + internal async Task OnStartPcsWorkItemProcessorFailed(Request req, Response res) + { + string content = null; + if (res.ContentStream != null) + { + using (var reader = new StreamReader(res.ContentStream)) + { + content = await reader.ReadToEndAsync().ConfigureAwait(false); + } + } + + var ex = new RestApiException( + req, + res, + content, + Client.Deserialize(content) + ); + HandleFailedStartPcsWorkItemProcessorRequest(ex); + HandleFailedRequest(ex); + Client.OnFailedRequest(ex); + throw ex; + } + + partial void HandleFailedGetPcsWorkItemProcessorStatusRequest(RestApiException ex); + + public async Task GetPcsWorkItemProcessorStatusAsync( + CancellationToken cancellationToken = default + ) + { + + const string apiVersion = "2020-02-20"; + + var _baseUri = Client.Options.BaseUri; + var _url = new RequestUriBuilder(); + _url.Reset(_baseUri); + _url.AppendPath( + "/api/status", + false); + + _url.AppendQuery("api-version", Client.Serialize(apiVersion)); + + + using (var _req = Client.Pipeline.CreateRequest()) + { + _req.Uri = _url; + _req.Method = RequestMethod.Get; + + using (var _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false)) + { + if (_res.Status < 200 || _res.Status >= 300) + { + await OnGetPcsWorkItemProcessorStatusFailed(_req, _res).ConfigureAwait(false); + } + + + return; + } + } + } + + internal async Task OnGetPcsWorkItemProcessorStatusFailed(Request req, Response res) + { + string content = null; + if (res.ContentStream != null) + { + using (var reader = new StreamReader(res.ContentStream)) + { + content = await reader.ReadToEndAsync().ConfigureAwait(false); + } + } + + var ex = new RestApiException( + req, + res, + content, + Client.Deserialize(content) + ); + HandleFailedGetPcsWorkItemProcessorStatusRequest(ex); + HandleFailedRequest(ex); + Client.OnFailedRequest(ex); + throw ex; + } + } +}