diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/Azure.ResourceManager.ContainerRegistryTasks.sln b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/Azure.ResourceManager.ContainerRegistryTasks.sln new file mode 100644 index 000000000000..ec4b80812b46 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/Azure.ResourceManager.ContainerRegistryTasks.sln @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.ContainerRegistryTasks", "src\Azure.ResourceManager.ContainerRegistryTasks.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.ContainerRegistryTasks.Tests", "tests\Azure.ResourceManager.ContainerRegistryTasks.Tests.csproj", "{E2E6A1D6-8F7B-4F92-B8A3-1C3D5E7F9A2B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {E2E6A1D6-8F7B-4F92-B8A3-1C3D5E7F9A2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2E6A1D6-8F7B-4F92-B8A3-1C3D5E7F9A2B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2E6A1D6-8F7B-4F92-B8A3-1C3D5E7F9A2B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2E6A1D6-8F7B-4F92-B8A3-1C3D5E7F9A2B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/CHANGELOG.md b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/CHANGELOG.md new file mode 100644 index 000000000000..e8b37573af11 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2026-03-13) + +### Features Added + +- Initial release of `Azure.ResourceManager.ContainerRegistryTasks` for managing Container Registry Tasks resources (Tasks, Runs, TaskRuns, and Agent Pools). +- This package provides dedicated management of the `Microsoft.ContainerRegistry/RegistryTasks` resource provider, separated from the `Azure.ResourceManager.ContainerRegistry` package where these resources were previously included. \ No newline at end of file diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/Directory.Build.props b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/README.md b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/README.md new file mode 100644 index 000000000000..99e997403989 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure containerregistrytasks management client library for .NET + +The Azure Container Registry Tasks .NET client library enables you to manage Azure Container Registry task resources, including task definitions, runs, triggers, and related configuration. + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure containerregistrytasks management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.containerregistrytasks --prerelease +``` + +### Prerequisites + +* You must have a [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://learn.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/assets.json b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/assets.json new file mode 100644 index 000000000000..fc70647de1a0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/assets.json @@ -0,0 +1,7 @@ + +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/containerregistrytasks/Azure.ResourceManager.containerregistrytasks", + "Tag": "" +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/metadata.json b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/metadata.json new file mode 100644 index 000000000000..608fe7ee617b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/metadata.json @@ -0,0 +1,5 @@ +{ + "apiVersions": { + "Microsoft.ContainerRegistry": "2025-03-01-preview" + } +} \ No newline at end of file diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Azure.ResourceManager.ContainerRegistryTasks.csproj b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Azure.ResourceManager.ContainerRegistryTasks.csproj new file mode 100644 index 000000000000..9ae1b7eb98d7 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Azure.ResourceManager.ContainerRegistryTasks.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.ContainerRegistryTasks client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.ContainerRegistryTasks + 1.0.0-beta.1 + Azure.ResourceManager.ContainerRegistryTasks + true + + diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolCollection.cs new file mode 100644 index 000000000000..06e6a18c24e3 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolCollection.cs @@ -0,0 +1,584 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetAgentPools method from an instance of . + /// + public partial class AgentPoolCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _agentPoolsClientDiagnostics; + private readonly AgentPools _agentPoolsRestClient; + /// The registryName. + private readonly string _registryName; + + /// Initializes a new instance of AgentPoolCollection for mocking. + protected AgentPoolCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + /// The registryName for the resource. + internal AgentPoolCollection(ArmClient client, ResourceIdentifier id, string registryName) : base(client, id) + { + TryGetApiVersion(AgentPoolResource.ResourceType, out string agentPoolApiVersion); + _registryName = registryName; + _agentPoolsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerRegistryTasks", AgentPoolResource.ResourceType.Namespace, Diagnostics); + _agentPoolsRestClient = new AgentPools(_agentPoolsClientDiagnostics, Pipeline, Endpoint, agentPoolApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } + } + + /// + /// Creates an agent pool for a container registry with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Create. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the agent pool. + /// The parameters of an agent pool that needs to scheduled. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string agentPoolName, AgentPoolData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentPoolName, nameof(agentPoolName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, agentPoolName, AgentPoolData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation( + new AgentPoolOperationSource(Client), + _agentPoolsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates an agent pool for a container registry with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Create. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the agent pool. + /// The parameters of an agent pool that needs to scheduled. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string agentPoolName, AgentPoolData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentPoolName, nameof(agentPoolName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, agentPoolName, AgentPoolData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation( + new AgentPoolOperationSource(Client), + _agentPoolsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the detailed information for a given agent pool. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the agent pool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string agentPoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentPoolName, nameof(agentPoolName)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, agentPoolName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AgentPoolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the detailed information for a given agent pool. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the agent pool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string agentPoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentPoolName, nameof(agentPoolName)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, agentPoolName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AgentPoolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all the agent pools for a specified container registry. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools. + /// + /// + /// Operation Id. + /// AgentPools_List. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new AgentPoolsGetAllAsyncCollectionResultOfT(_agentPoolsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, context), data => new AgentPoolResource(Client, data)); + } + + /// + /// Lists all the agent pools for a specified container registry. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools. + /// + /// + /// Operation Id. + /// AgentPools_List. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new AgentPoolsGetAllCollectionResultOfT(_agentPoolsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, context), data => new AgentPoolResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the agent pool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string agentPoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentPoolName, nameof(agentPoolName)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, agentPoolName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AgentPoolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AgentPoolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the agent pool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string agentPoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentPoolName, nameof(agentPoolName)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, agentPoolName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AgentPoolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AgentPoolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the agent pool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string agentPoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentPoolName, nameof(agentPoolName)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, agentPoolName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AgentPoolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AgentPoolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the agent pool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string agentPoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentPoolName, nameof(agentPoolName)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, agentPoolName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AgentPoolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AgentPoolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + /// The cancellation token to use. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolData.Serialization.cs new file mode 100644 index 000000000000..33580cd7de70 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolData.Serialization.cs @@ -0,0 +1,234 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// The agentpool that has the ARM resource and properties. + /// The agentpool will have all information to create an agent pool. + /// + public partial class AgentPoolData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentPoolData() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentPoolData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentPoolData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(AgentPoolData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AgentPoolData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AgentPoolData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(AgentPoolData agentPoolData) + { + if (agentPoolData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(agentPoolData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static AgentPoolData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgentPoolData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentPoolData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AgentPoolData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentPoolData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentPoolData DeserializeAgentPoolData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + AgentPoolProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerContainerRegistryTasksContext.Default); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = AgentPoolProperties.DeserializeAgentPoolProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentPoolData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolData.cs new file mode 100644 index 000000000000..7a82b8b45815 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolData.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// The agentpool that has the ARM resource and properties. + /// The agentpool will have all information to create an agent pool. + /// + public partial class AgentPoolData : TrackedResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The geo-location where the resource lives. + public AgentPoolData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The properties associated with the agent pool. + internal AgentPoolData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, AgentPoolProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The properties associated with the agent pool. + internal AgentPoolProperties Properties { get; set; } + + /// The count of agent machine. + public int? Count + { + get + { + return Properties is null ? default : Properties.Count; + } + set + { + if (Properties is null) + { + Properties = new AgentPoolProperties(); + } + Properties.Count = value.Value; + } + } + + /// The Tier of agent machine. + public string Tier + { + get + { + return Properties is null ? default : Properties.Tier; + } + set + { + if (Properties is null) + { + Properties = new AgentPoolProperties(); + } + Properties.Tier = value; + } + } + + /// The OS of agent machine. + public ContainerRegistryTaskOS? OS + { + get + { + return Properties is null ? default : Properties.OS; + } + set + { + if (Properties is null) + { + Properties = new AgentPoolProperties(); + } + Properties.OS = value.Value; + } + } + + /// The Virtual Network Subnet Resource Id of the agent machine. + public ResourceIdentifier VirtualNetworkSubnetResourceId + { + get + { + return Properties is null ? default : Properties.VirtualNetworkSubnetResourceId; + } + set + { + if (Properties is null) + { + Properties = new AgentPoolProperties(); + } + Properties.VirtualNetworkSubnetResourceId = value; + } + } + + /// The provisioning state of this agent pool. + public ContainerRegistryTaskProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolResource.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolResource.Serialization.cs new file mode 100644 index 000000000000..e13773cdafe1 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + public partial class AgentPoolResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new AgentPoolData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + AgentPoolData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerContainerRegistryTasksContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + AgentPoolData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerContainerRegistryTasksContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolResource.cs new file mode 100644 index 000000000000..3619bac42c35 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/AgentPoolResource.cs @@ -0,0 +1,779 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// A class representing a AgentPool along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetAgentPools method. + /// + public partial class AgentPoolResource : ArmResource + { + private readonly ClientDiagnostics _agentPoolsClientDiagnostics; + private readonly AgentPools _agentPoolsRestClient; + private readonly AgentPoolData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.ContainerRegistry/registries/agentPools"; + + /// Initializes a new instance of AgentPoolResource for mocking. + protected AgentPoolResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal AgentPoolResource(ArmClient client, AgentPoolData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal AgentPoolResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string agentPoolApiVersion); + _agentPoolsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerRegistryTasks", ResourceType.Namespace, Diagnostics); + _agentPoolsRestClient = new AgentPools(_agentPoolsClientDiagnostics, Pipeline, Endpoint, agentPoolApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual AgentPoolData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The registryName. + /// The agentPoolName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string registryName, string agentPoolName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Gets the detailed information for a given agent pool. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AgentPoolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the detailed information for a given agent pool. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AgentPoolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates an agent pool with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Update. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The parameters for updating an agent pool. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, AgentPoolPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, AgentPoolPatch.ToRequestContent(patch), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation( + new AgentPoolOperationSource(Client), + _agentPoolsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates an agent pool with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Update. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The parameters for updating an agent pool. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, AgentPoolPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, AgentPoolPatch.ToRequestContent(patch), context); + Response response = Pipeline.ProcessMessage(message, context); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation( + new AgentPoolOperationSource(Client), + _agentPoolsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a specified agent pool resource. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Delete. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation(_agentPoolsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a specified agent pool resource. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Delete. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation(_agentPoolsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the count of queued runs for a given agent pool. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}/listQueueStatus. + /// + /// + /// Operation Id. + /// AgentPools_GetQueueStatus. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetQueueStatusAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.GetQueueStatus"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetQueueStatusRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AgentPoolQueueStatus.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the count of queued runs for a given agent pool. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}/listQueueStatus. + /// + /// + /// Operation Id. + /// AgentPools_GetQueueStatus. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response GetQueueStatus(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.GetQueueStatus"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetQueueStatusRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AgentPoolQueueStatus.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AgentPoolData.FromResponse(result), result); + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AgentPoolData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AgentPoolPatch patch = new AgentPoolPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AgentPoolData.FromResponse(result), result); + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AgentPoolData current = Get(cancellationToken: cancellationToken).Value.Data; + AgentPoolPatch patch = new AgentPoolPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AgentPoolData.FromResponse(result), result); + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AgentPoolData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AgentPoolPatch patch = new AgentPoolPatch(); + patch.Tags.ReplaceWith(tags); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AgentPoolData.FromResponse(result), result); + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AgentPoolData current = Get(cancellationToken: cancellationToken).Value.Data; + AgentPoolPatch patch = new AgentPoolPatch(); + patch.Tags.ReplaceWith(tags); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AgentPoolData.FromResponse(result), result); + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AgentPoolData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AgentPoolPatch patch = new AgentPoolPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _agentPoolsClientDiagnostics.CreateScope("AgentPoolResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _agentPoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AgentPoolData.FromResponse(result), result); + return Response.FromValue(new AgentPoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AgentPoolData current = Get(cancellationToken: cancellationToken).Value.Data; + AgentPoolPatch patch = new AgentPoolPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/ArmContainerRegistryTasksModelFactory.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/ArmContainerRegistryTasksModelFactory.cs new file mode 100644 index 000000000000..2147cc5056cf --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/ArmContainerRegistryTasksModelFactory.cs @@ -0,0 +1,763 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// A factory class for creating instances of the models for mocking. + public static partial class ArmContainerRegistryTasksModelFactory + { + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. + /// The count of agent machine. + /// The Tier of agent machine. + /// The OS of agent machine. + /// The Virtual Network Subnet Resource Id of the agent machine. + /// The provisioning state of this agent pool. + /// A new instance for mocking. + public static AgentPoolData AgentPoolData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, int? count = default, string tier = default, ContainerRegistryTaskOS? os = default, ResourceIdentifier virtualNetworkSubnetResourceId = default, ContainerRegistryTaskProvisioningState? provisioningState = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new AgentPoolData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + count is null && tier is null && os is null && virtualNetworkSubnetResourceId is null && provisioningState is null ? default : new AgentPoolProperties( + count, + tier, + os, + virtualNetworkSubnetResourceId, + provisioningState, + null)); + } + + /// The count of agent machine. + /// The ARM resource tags. + /// A new instance for mocking. + public static AgentPoolPatch AgentPoolPatch(int? count = default, IDictionary tags = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new AgentPoolPatch(count is null ? default : new AgentPoolPropertiesUpdateParameters(count, null), tags, additionalBinaryDataProperties: null); + } + + /// The QueueStatus of Agent Pool. + /// The number of pending runs in the queue. + /// A new instance for mocking. + public static AgentPoolQueueStatus AgentPoolQueueStatus(int? count = default) + { + return new AgentPoolQueueStatus(count, additionalBinaryDataProperties: null); + } + + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// The unique identifier for the run. + /// The current status of the run. + /// The last updated time for the run. + /// The type of run. + /// The dedicated agent pool for the run. + /// The time the run was scheduled. + /// The time the run started. + /// The time the run finished. + /// The list of all images that were generated from the run. This is applicable if the run generates base image dependencies. + /// The task against which run was scheduled. + /// The image update trigger that caused the run. This is applicable if the task has base image trigger configured. + /// The source trigger that caused the run. + /// The timer trigger that caused the run. + /// The platform properties against which the run will happen. + /// The scope of the credentials that were used to login to the source registry during this run. + /// The list of custom registries that were logged in during this run. + /// The error message received from backend systems after the run is scheduled. + /// The update trigger token passed for the Run. + /// The image description for the log artifact. + /// The provisioning state of a run. + /// The value that indicates whether archiving is enabled or not. + /// The CPU configuration in terms of number of cores required for the run. + /// A new instance for mocking. + public static RunData RunData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, string runId = default, ContainerRegistryTaskRunStatus? status = default, DateTimeOffset? lastUpdatedOn = default, ContainerRegistryTaskRunType? runType = default, string agentPoolName = default, DateTimeOffset? createdOn = default, DateTimeOffset? startOn = default, DateTimeOffset? finishOn = default, IEnumerable outputImages = default, string task = default, ImageUpdateTrigger imageUpdateTrigger = default, SourceTriggerDescriptor sourceTrigger = default, TimerTriggerDescriptor timerTrigger = default, PlatformProperties platform = default, string sourceRegistryAuth = default, IEnumerable customRegistries = default, string runErrorMessage = default, string updateTriggerToken = default, ImageDescriptor logArtifact = default, ContainerRegistryTaskProvisioningState? provisioningState = default, bool? isArchiveEnabled = default, int? agentCpu = default) + { + return new RunData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + runId is null && status is null && lastUpdatedOn is null && runType is null && agentPoolName is null && createdOn is null && startOn is null && finishOn is null && outputImages is null && task is null && imageUpdateTrigger is null && sourceTrigger is null && timerTrigger is null && platform is null && sourceRegistryAuth is null && customRegistries is null && runErrorMessage is null && updateTriggerToken is null && logArtifact is null && provisioningState is null && isArchiveEnabled is null && agentCpu is null ? default : new RunProperties( + runId, + status, + lastUpdatedOn, + runType, + agentPoolName, + createdOn, + startOn, + finishOn, + (outputImages ?? new ChangeTrackingList()).ToList(), + task, + imageUpdateTrigger, + sourceTrigger, + timerTrigger, + platform, + new AgentProperties(agentCpu, null), + sourceRegistryAuth, + (customRegistries ?? new ChangeTrackingList()).ToList(), + runErrorMessage, + updateTriggerToken, + logArtifact, + provisioningState, + isArchiveEnabled, + null)); + } + + /// Properties for a registry image. + /// The registry login server. + /// The repository name. + /// The tag name. + /// The sha256-based digest of the image manifest. + /// A new instance for mocking. + public static ImageDescriptor ImageDescriptor(string registry = default, string repository = default, string tag = default, string digest = default) + { + return new ImageDescriptor(registry, repository, tag, digest, additionalBinaryDataProperties: null); + } + + /// The image update trigger that caused a build. + /// The unique ID of the trigger. + /// The timestamp when the image update happened. + /// The list of image updates that caused the build. + /// A new instance for mocking. + public static ImageUpdateTrigger ImageUpdateTrigger(string id = default, DateTimeOffset? occurredOn = default, IEnumerable images = default) + { + images ??= new ChangeTrackingList(); + + return new ImageUpdateTrigger(id, occurredOn, images.ToList(), additionalBinaryDataProperties: null); + } + + /// The source trigger that caused a run. + /// The unique ID of the trigger. + /// The event type of the trigger. + /// The unique ID that identifies a commit. + /// The unique ID that identifies pull request. + /// The repository URL. + /// The branch name in the repository. + /// The source control provider type. + /// A new instance for mocking. + public static SourceTriggerDescriptor SourceTriggerDescriptor(string id = default, string eventType = default, string commitId = default, string pullRequestId = default, Uri repositoryUri = default, string branchName = default, string providerType = default) + { + return new SourceTriggerDescriptor( + id, + eventType, + commitId, + pullRequestId, + repositoryUri, + branchName, + providerType, + additionalBinaryDataProperties: null); + } + + /// The TimerTriggerDescriptor. + /// The timer trigger name that caused the run. + /// The occurrence that triggered the run. + /// A new instance for mocking. + public static TimerTriggerDescriptor TimerTriggerDescriptor(string timerTriggerName = default, string scheduleOccurrence = default) + { + return new TimerTriggerDescriptor(timerTriggerName, scheduleOccurrence, additionalBinaryDataProperties: null); + } + + /// The result of get log link operation. + /// The link to logs for a run on a azure container registry. + /// The link to logs in registry for a run on a azure container registry. + /// A new instance for mocking. + public static RunGetLogResult RunGetLogResult(string logLink = default, string logArtifactLink = default) + { + return new RunGetLogResult(logLink, logArtifactLink, additionalBinaryDataProperties: null); + } + + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// The provisioning state of this task run. + /// The request (parameters) for the run. + /// The result of this task run. + /// How the run should be forced to rerun even if the run request configuration has not changed. + /// Identity for the resource. + /// The location of the resource. + /// A new instance for mocking. + public static TaskRunData TaskRunData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, ContainerRegistryTaskProvisioningState? provisioningState = default, RunContent runRequest = default, RunData runResult = default, string forceUpdateTag = default, IdentityProperties identity = default, AzureLocation? location = default) + { + return new TaskRunData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + provisioningState is null && runRequest is null && runResult is null && forceUpdateTag is null ? default : new TaskRunProperties(provisioningState, runRequest, runResult, forceUpdateTag, null), + identity, + location); + } + + /// The value that indicates whether archiving is enabled for the run or not. + /// The dedicated agent pool for the run. + /// The template that describes the repository and tag information for run log artifact. + /// The fully qualified image names including the repository and tag. + /// The value of this property indicates whether the image built should be pushed to the registry or not. + /// The value of this property indicates whether the image cache is enabled or not. + /// The Docker file path relative to the source location. + /// The name of the target build stage for the docker build. + /// The collection of override arguments to be used when executing the run. + /// Run timeout in seconds. + /// The platform properties against which the run has to happen. + /// The CPU configuration in terms of number of cores required for the run. + /// + /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. + /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. + /// + /// The properties that describes a set of credentials that will be used when this run is invoked. + /// A new instance for mocking. + public static DockerBuildContent DockerBuildContent(bool? isArchiveEnabled = default, string agentPoolName = default, string logTemplate = default, IEnumerable imageNames = default, bool? isPushEnabled = default, bool? isCacheDisabled = default, string dockerFilePath = default, string target = default, IEnumerable arguments = default, int? timeoutInSeconds = default, PlatformProperties platform = default, int? agentCpu = default, string sourceLocation = default, ContainerRegistryTaskCredentials credentials = default) + { + imageNames ??= new ChangeTrackingList(); + arguments ??= new ChangeTrackingList(); + + return new DockerBuildContent( + "DockerBuildRequest", + isArchiveEnabled, + agentPoolName, + logTemplate, + additionalBinaryDataProperties: null, + imageNames.ToList(), + isPushEnabled, + isCacheDisabled, + dockerFilePath, + target, + arguments.ToList(), + timeoutInSeconds, + platform, + agentCpu is null ? default : new AgentProperties(agentCpu, null), + sourceLocation, + credentials); + } + + /// The parameters that describes a set of credentials that will be used when a run is invoked. + /// Describes the credential parameters for accessing the source registry. + /// + /// Describes the credential parameters for accessing other custom registries. The key + /// for the dictionary item will be the registry login server (myregistry.azurecr.io) and + /// the value of the item will be the registry credentials for accessing the registry. + /// + /// A new instance for mocking. + public static ContainerRegistryTaskCredentials ContainerRegistryTaskCredentials(SourceRegistryCredentials sourceRegistry = default, IDictionary customRegistries = default) + { + customRegistries ??= new ChangeTrackingDictionary(); + + return new ContainerRegistryTaskCredentials(sourceRegistry, customRegistries, additionalBinaryDataProperties: null); + } + + /// The value that indicates whether archiving is enabled for the run or not. + /// The dedicated agent pool for the run. + /// The template that describes the repository and tag information for run log artifact. + /// The template/definition file path relative to the source. + /// The values/parameters file path relative to the source. + /// The collection of overridable values that can be passed when running a task. + /// Run timeout in seconds. + /// The platform properties against which the run has to happen. + /// The CPU configuration in terms of number of cores required for the run. + /// + /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. + /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. + /// + /// The properties that describes a set of credentials that will be used when this run is invoked. + /// A new instance for mocking. + public static FileTaskRunContent FileTaskRunContent(bool? isArchiveEnabled = default, string agentPoolName = default, string logTemplate = default, string taskFilePath = default, string valuesFilePath = default, IEnumerable values = default, int? timeoutInSeconds = default, PlatformProperties platform = default, int? agentCpu = default, string sourceLocation = default, ContainerRegistryTaskCredentials credentials = default) + { + values ??= new ChangeTrackingList(); + + return new FileTaskRunContent( + "FileTaskRunRequest", + isArchiveEnabled, + agentPoolName, + logTemplate, + additionalBinaryDataProperties: null, + taskFilePath, + valuesFilePath, + values.ToList(), + timeoutInSeconds, + platform, + agentCpu is null ? default : new AgentProperties(agentCpu, null), + sourceLocation, + credentials); + } + + /// The OverrideTaskStepProperties. + /// The source context against which run has to be queued. + /// The file against which run has to be queued. + /// + /// Gets or sets the collection of override arguments to be used when + /// executing a build step. + /// + /// The name of the target build stage for the docker build. + /// The collection of overridable values that can be passed when running a Task. + /// Base64 encoded update trigger token that will be attached with the base image trigger webhook. + /// A new instance for mocking. + public static OverrideTaskStepProperties OverrideTaskStepProperties(string contextPath = default, string @file = default, IEnumerable arguments = default, string target = default, IEnumerable values = default, string updateTriggerToken = default) + { + arguments ??= new ChangeTrackingList(); + values ??= new ChangeTrackingList(); + + return new OverrideTaskStepProperties( + contextPath, + @file, + arguments.ToList(), + target, + values.ToList(), + updateTriggerToken, + additionalBinaryDataProperties: null); + } + + /// The value that indicates whether archiving is enabled for the run or not. + /// The dedicated agent pool for the run. + /// The template that describes the repository and tag information for run log artifact. + /// Base64 encoded value of the template/definition file content. + /// Base64 encoded value of the parameters/values file content. + /// The collection of overridable values that can be passed when running a task. + /// Run timeout in seconds. + /// The platform properties against which the run has to happen. + /// The CPU configuration in terms of number of cores required for the run. + /// + /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. + /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. + /// + /// The properties that describes a set of credentials that will be used when this run is invoked. + /// A new instance for mocking. + public static EncodedTaskRunContent EncodedTaskRunContent(bool? isArchiveEnabled = default, string agentPoolName = default, string logTemplate = default, string encodedTaskContent = default, string encodedValuesContent = default, IEnumerable values = default, int? timeoutInSeconds = default, PlatformProperties platform = default, int? agentCpu = default, string sourceLocation = default, ContainerRegistryTaskCredentials credentials = default) + { + values ??= new ChangeTrackingList(); + + return new EncodedTaskRunContent( + "EncodedTaskRunRequest", + isArchiveEnabled, + agentPoolName, + logTemplate, + additionalBinaryDataProperties: null, + encodedTaskContent, + encodedValuesContent, + values.ToList(), + timeoutInSeconds, + platform, + agentCpu is null ? default : new AgentProperties(agentCpu, null), + sourceLocation, + credentials); + } + + /// Managed identity for the resource. + /// The principal ID of resource identity. + /// The tenant ID of resource. + /// The identity type. + /// + /// The list of user identities associated with the resource. The user identity + /// dictionary key references will be ARM resource ids in the form: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + /// providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + /// + /// A new instance for mocking. + public static IdentityProperties IdentityProperties(string principalId = default, string tenantId = default, ResourceIdentityType? @type = default, IDictionary userAssignedIdentities = default) + { + userAssignedIdentities ??= new ChangeTrackingDictionary(); + + return new IdentityProperties(principalId, tenantId, @type, userAssignedIdentities, additionalBinaryDataProperties: null); + } + + /// The UserIdentityProperties. + /// The principal id of user assigned identity. + /// The client id of user assigned identity. + /// A new instance for mocking. + public static UserIdentityProperties UserIdentityProperties(string principalId = default, string clientId = default) + { + return new UserIdentityProperties(principalId, clientId, additionalBinaryDataProperties: null); + } + + /// Identity for the resource. + /// The request (parameters) for the new run. + /// How the run should be forced to rerun even if the run request configuration has not changed. + /// The location of the resource. + /// The ARM resource tags. + /// A new instance for mocking. + public static TaskRunPatch TaskRunPatch(IdentityProperties identity = default, RunContent runRequest = default, string forceUpdateTag = default, string location = default, IDictionary tags = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new TaskRunPatch(identity, runRequest is null && forceUpdateTag is null ? default : new TaskRunPropertiesUpdateParameters(runRequest, forceUpdateTag, null), location, tags, additionalBinaryDataProperties: null); + } + + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. + /// The provisioning state of the task. + /// The creation date of task. + /// The current status of task. + /// The platform properties against which the run has to happen. + /// The dedicated agent pool for the task. + /// Run timeout in seconds. + /// The properties of a task step. + /// The properties that describe all triggers for the task. + /// The properties that describes a set of credentials that will be used when this run is invoked. + /// The template that describes the repository and tag information for run log artifact. + /// The value of this property indicates whether the task resource is system task or not. + /// The CPU configuration in terms of number of cores required for the run. + /// Identity for the resource. + /// A new instance for mocking. + public static TaskData TaskData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, ContainerRegistryTaskProvisioningState? provisioningState = default, DateTimeOffset? createdOn = default, ContainerRegistryTaskStatus? status = default, PlatformProperties platform = default, string agentPoolName = default, int? timeoutInSeconds = default, TaskStepProperties step = default, TriggerProperties trigger = default, ContainerRegistryTaskCredentials credentials = default, string logTemplate = default, bool? isSystemTask = default, int? agentCpu = default, IdentityProperties identity = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new TaskData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + provisioningState is null && createdOn is null && status is null && platform is null && agentPoolName is null && timeoutInSeconds is null && step is null && trigger is null && credentials is null && logTemplate is null && isSystemTask is null && agentCpu is null ? default : new TaskProperties( + provisioningState, + createdOn, + status, + platform, + new AgentProperties(agentCpu, null), + agentPoolName, + timeoutInSeconds, + step, + trigger, + credentials, + logTemplate, + isSystemTask, + null), + identity); + } + + /// + /// Base properties for any task step. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + /// The type of the step. + /// List of base image dependencies for a step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// A new instance for mocking. + public static TaskStepProperties TaskStepProperties(string @type = default, IEnumerable baseImageDependencies = default, string contextPath = default, string contextAccessToken = default) + { + baseImageDependencies ??= new ChangeTrackingList(); + + return new UnknownTaskStepProperties(new StepType(@type), baseImageDependencies.ToList(), contextPath, contextAccessToken, additionalBinaryDataProperties: null); + } + + /// Properties that describe a base image dependency. + /// The type of the base image dependency. + /// The registry login server. + /// The repository name. + /// The tag name. + /// The sha256-based digest of the image manifest. + /// A new instance for mocking. + public static BaseImageDependency BaseImageDependency(BaseImageDependencyType? @type = default, string registry = default, string repository = default, string tag = default, string digest = default) + { + return new BaseImageDependency( + @type, + registry, + repository, + tag, + digest, + additionalBinaryDataProperties: null); + } + + /// The Docker build step. + /// List of base image dependencies for a step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// The fully qualified image names including the repository and tag. + /// The value of this property indicates whether the image built should be pushed to the registry or not. + /// The value of this property indicates whether the image cache is enabled or not. + /// The Docker file path relative to the source context. + /// The name of the target build stage for the docker build. + /// The collection of override arguments to be used when executing this build step. + /// A new instance for mocking. + public static DockerBuildStep DockerBuildStep(IEnumerable baseImageDependencies = default, string contextPath = default, string contextAccessToken = default, IEnumerable imageNames = default, bool? isPushEnabled = default, bool? isCacheDisabled = default, string dockerFilePath = default, string target = default, IEnumerable arguments = default) + { + baseImageDependencies ??= new ChangeTrackingList(); + imageNames ??= new ChangeTrackingList(); + arguments ??= new ChangeTrackingList(); + + return new DockerBuildStep( + StepType.Docker, + baseImageDependencies.ToList(), + contextPath, + contextAccessToken, + additionalBinaryDataProperties: null, + imageNames.ToList(), + isPushEnabled, + isCacheDisabled, + dockerFilePath, + target, + arguments.ToList()); + } + + /// The properties of a task step. + /// List of base image dependencies for a step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// The task template/definition file path relative to the source context. + /// The task values/parameters file path relative to the source context. + /// The collection of overridable values that can be passed when running a task. + /// A new instance for mocking. + public static FileTaskStep FileTaskStep(IEnumerable baseImageDependencies = default, string contextPath = default, string contextAccessToken = default, string taskFilePath = default, string valuesFilePath = default, IEnumerable values = default) + { + baseImageDependencies ??= new ChangeTrackingList(); + values ??= new ChangeTrackingList(); + + return new FileTaskStep( + StepType.FileTask, + baseImageDependencies.ToList(), + contextPath, + contextAccessToken, + additionalBinaryDataProperties: null, + taskFilePath, + valuesFilePath, + values.ToList()); + } + + /// The properties of a encoded task step. + /// List of base image dependencies for a step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Base64 encoded value of the template/definition file content. + /// Base64 encoded value of the parameters/values file content. + /// The collection of overridable values that can be passed when running a task. + /// A new instance for mocking. + public static EncodedTaskStep EncodedTaskStep(IEnumerable baseImageDependencies = default, string contextPath = default, string contextAccessToken = default, string encodedTaskContent = default, string encodedValuesContent = default, IEnumerable values = default) + { + baseImageDependencies ??= new ChangeTrackingList(); + values ??= new ChangeTrackingList(); + + return new EncodedTaskStep( + StepType.EncodedTask, + baseImageDependencies.ToList(), + contextPath, + contextAccessToken, + additionalBinaryDataProperties: null, + encodedTaskContent, + encodedValuesContent, + values.ToList()); + } + + /// The properties of a trigger. + /// The collection of timer triggers. + /// The collection of triggers based on source code repository. + /// The trigger based on base image dependencies. + /// A new instance for mocking. + public static TriggerProperties TriggerProperties(IEnumerable timerTriggers = default, IEnumerable sourceTriggers = default, BaseImageTrigger baseImageTrigger = default) + { + timerTriggers ??= new ChangeTrackingList(); + sourceTriggers ??= new ChangeTrackingList(); + + return new TriggerProperties(timerTriggers.ToList(), sourceTriggers.ToList(), baseImageTrigger, additionalBinaryDataProperties: null); + } + + /// The properties of a source based trigger. + /// The properties that describes the source(code) for the task. + /// The source event corresponding to the trigger. + /// The current status of trigger. + /// The name of the trigger. + /// A new instance for mocking. + public static SourceTrigger SourceTrigger(SourceProperties sourceRepository = default, IEnumerable sourceTriggerEvents = default, ContainerRegistryTaskTriggerStatus? status = default, string name = default) + { + sourceTriggerEvents ??= new ChangeTrackingList(); + + return new SourceTrigger(sourceRepository, sourceTriggerEvents.ToList(), status, name, additionalBinaryDataProperties: null); + } + + /// Identity for the resource. + /// The current status of task. + /// The platform properties against which the run has to happen. + /// The dedicated agent pool for the task. + /// Run timeout in seconds. + /// The properties for updating a task step. + /// The properties for updating trigger properties. + /// The parameters that describes a set of credentials that will be used when this run is invoked. + /// The template that describes the repository and tag information for run log artifact. + /// The CPU configuration in terms of number of cores required for the run. + /// The ARM resource tags. + /// A new instance for mocking. + public static TaskPatch TaskPatch(IdentityProperties identity = default, ContainerRegistryTaskStatus? status = default, PlatformUpdateContent platform = default, string agentPoolName = default, int? timeoutInSeconds = default, TaskStepUpdateContent step = default, TriggerUpdateContent trigger = default, ContainerRegistryTaskCredentials credentials = default, string logTemplate = default, int? agentCpu = default, IDictionary tags = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new TaskPatch(identity, status is null && platform is null && agentPoolName is null && timeoutInSeconds is null && step is null && trigger is null && credentials is null && logTemplate is null && agentCpu is null ? default : new TaskPropertiesUpdateParameters( + status, + platform, + new AgentProperties(agentCpu, null), + agentPoolName, + timeoutInSeconds, + step, + trigger, + credentials, + logTemplate, + null), tags, additionalBinaryDataProperties: null); + } + + /// The properties for updating a docker build step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// The fully qualified image names including the repository and tag. + /// The value of this property indicates whether the image built should be pushed to the registry or not. + /// The value of this property indicates whether the image cache is enabled or not. + /// The Docker file path relative to the source context. + /// The collection of override arguments to be used when executing this build step. + /// The name of the target build stage for the docker build. + /// A new instance for mocking. + public static DockerBuildStepUpdateContent DockerBuildStepUpdateContent(string contextPath = default, string contextAccessToken = default, IEnumerable imageNames = default, bool? isPushEnabled = default, bool? isCacheDisabled = default, string dockerFilePath = default, IEnumerable arguments = default, string target = default) + { + imageNames ??= new ChangeTrackingList(); + arguments ??= new ChangeTrackingList(); + + return new DockerBuildStepUpdateContent( + StepType.Docker, + contextPath, + contextAccessToken, + additionalBinaryDataProperties: null, + imageNames.ToList(), + isPushEnabled, + isCacheDisabled, + dockerFilePath, + arguments.ToList(), + target); + } + + /// The properties of updating a task step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// The task template/definition file path relative to the source context. + /// The values/parameters file path relative to the source context. + /// The collection of overridable values that can be passed when running a task. + /// A new instance for mocking. + public static FileTaskStepUpdateContent FileTaskStepUpdateContent(string contextPath = default, string contextAccessToken = default, string taskFilePath = default, string valuesFilePath = default, IEnumerable values = default) + { + values ??= new ChangeTrackingList(); + + return new FileTaskStepUpdateContent( + StepType.FileTask, + contextPath, + contextAccessToken, + additionalBinaryDataProperties: null, + taskFilePath, + valuesFilePath, + values.ToList()); + } + + /// The properties for updating encoded task step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Base64 encoded value of the template/definition file content. + /// Base64 encoded value of the parameters/values file content. + /// The collection of overridable values that can be passed when running a task. + /// A new instance for mocking. + public static EncodedTaskStepUpdateContent EncodedTaskStepUpdateContent(string contextPath = default, string contextAccessToken = default, string encodedTaskContent = default, string encodedValuesContent = default, IEnumerable values = default) + { + values ??= new ChangeTrackingList(); + + return new EncodedTaskStepUpdateContent( + StepType.EncodedTask, + contextPath, + contextAccessToken, + additionalBinaryDataProperties: null, + encodedTaskContent, + encodedValuesContent, + values.ToList()); + } + + /// The properties for updating triggers. + /// The collection of timer triggers. + /// The collection of triggers based on source code repository. + /// The trigger based on base image dependencies. + /// A new instance for mocking. + public static TriggerUpdateContent TriggerUpdateContent(IEnumerable timerTriggers = default, IEnumerable sourceTriggers = default, BaseImageTriggerUpdateContent baseImageTrigger = default) + { + timerTriggers ??= new ChangeTrackingList(); + sourceTriggers ??= new ChangeTrackingList(); + + return new TriggerUpdateContent(timerTriggers.ToList(), sourceTriggers.ToList(), baseImageTrigger, additionalBinaryDataProperties: null); + } + + /// The properties for updating a timer trigger. + /// The CRON expression for the task schedule. + /// The current status of trigger. + /// The name of the trigger. + /// A new instance for mocking. + public static TimerTriggerUpdateContent TimerTriggerUpdateContent(string schedule = default, ContainerRegistryTaskTriggerStatus? status = default, string name = default) + { + return new TimerTriggerUpdateContent(schedule, status, name, additionalBinaryDataProperties: null); + } + + /// The properties for updating a source based trigger. + /// The properties that describes the source(code) for the task. + /// The source event corresponding to the trigger. + /// The current status of trigger. + /// The name of the trigger. + /// A new instance for mocking. + public static SourceTriggerUpdateContent SourceTriggerUpdateContent(SourceUpdateContent sourceRepository = default, IEnumerable sourceTriggerEvents = default, ContainerRegistryTaskTriggerStatus? status = default, string name = default) + { + sourceTriggerEvents ??= new ChangeTrackingList(); + + return new SourceTriggerUpdateContent(sourceRepository, sourceTriggerEvents.ToList(), status, name, additionalBinaryDataProperties: null); + } + + /// The properties for updating base image dependency trigger. + /// The type of the auto trigger for base image dependency updates. + /// The endpoint URL for receiving update triggers. + /// Type of Payload body for Base image update triggers. + /// The current status of trigger. + /// The name of the trigger. + /// A new instance for mocking. + public static BaseImageTriggerUpdateContent BaseImageTriggerUpdateContent(BaseImageTriggerType? baseImageTriggerType = default, string updateTriggerEndpoint = default, UpdateTriggerPayloadType? updateTriggerPayloadType = default, ContainerRegistryTaskTriggerStatus? status = default, string name = default) + { + return new BaseImageTriggerUpdateContent( + baseImageTriggerType, + updateTriggerEndpoint, + updateTriggerPayloadType, + status, + name, + additionalBinaryDataProperties: null); + } + + /// The properties of a response to source upload request. + /// The URL where the client can upload the source. + /// The relative path to the source. This is used to submit the subsequent queue build request. + /// A new instance for mocking. + public static SourceUploadResult SourceUploadResult(string uploadUri = default, string relativePath = default) + { + return new SourceUploadResult(uploadUri, relativePath, additionalBinaryDataProperties: null); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/AgentPoolsGetAllAsyncCollectionResultOfT.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/AgentPoolsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..d9ddb4322c38 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/AgentPoolsGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerRegistryTasks.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class AgentPoolsGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly AgentPools _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _registryName; + private readonly RequestContext _context; + + /// Initializes a new instance of AgentPoolsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AgentPools client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Registry. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AgentPoolsGetAllAsyncCollectionResultOfT(AgentPools client, Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _registryName = registryName; + _context = context; + } + + /// Gets the pages of AgentPoolsGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AgentPoolsGetAllAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + AgentPoolListResult result = AgentPoolListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + string nextPageString = result.NextLink; + if (string.IsNullOrEmpty(nextPageString)) + { + yield break; + } + nextPage = new Uri(nextPageString, UriKind.RelativeOrAbsolute); + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _registryName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _registryName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AgentPoolCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/AgentPoolsGetAllCollectionResultOfT.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/AgentPoolsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..4e47150e8b9b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/AgentPoolsGetAllCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerRegistryTasks.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class AgentPoolsGetAllCollectionResultOfT : Pageable + { + private readonly AgentPools _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _registryName; + private readonly RequestContext _context; + + /// Initializes a new instance of AgentPoolsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AgentPools client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Registry. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AgentPoolsGetAllCollectionResultOfT(AgentPools client, Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _registryName = registryName; + _context = context; + } + + /// Gets the pages of AgentPoolsGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AgentPoolsGetAllCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + AgentPoolListResult result = AgentPoolListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + string nextPageString = result.NextLink; + if (string.IsNullOrEmpty(nextPageString)) + { + yield break; + } + nextPage = new Uri(nextPageString, UriKind.RelativeOrAbsolute); + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _registryName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _registryName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AgentPoolCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/RunsGetAllAsyncCollectionResultOfT.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/RunsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..f3cd18d90880 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/RunsGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerRegistryTasks.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class RunsGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly Runs _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _registryName; + private readonly string _filter; + private readonly int? _top; + private readonly RequestContext _context; + + /// Initializes a new instance of RunsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Runs client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Registry. + /// The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except 'Not', 'Has', 'All' are allowed. + /// $top is supported for get list of runs, which limits the maximum number of runs to return. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public RunsGetAllAsyncCollectionResultOfT(Runs client, Guid subscriptionId, string resourceGroupName, string registryName, string filter, int? top, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _registryName = registryName; + _filter = filter; + _top = top; + _context = context; + } + + /// Gets the pages of RunsGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of RunsGetAllAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + RunListResult result = RunListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + string nextPageString = result.NextLink; + if (string.IsNullOrEmpty(nextPageString)) + { + yield break; + } + nextPage = new Uri(nextPageString, UriKind.RelativeOrAbsolute); + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _registryName, _filter, _top, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _registryName, _filter, _top, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("RunCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/RunsGetAllCollectionResultOfT.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/RunsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..ecc2f40f1b35 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/RunsGetAllCollectionResultOfT.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerRegistryTasks.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class RunsGetAllCollectionResultOfT : Pageable + { + private readonly Runs _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _registryName; + private readonly string _filter; + private readonly int? _top; + private readonly RequestContext _context; + + /// Initializes a new instance of RunsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Runs client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Registry. + /// The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except 'Not', 'Has', 'All' are allowed. + /// $top is supported for get list of runs, which limits the maximum number of runs to return. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public RunsGetAllCollectionResultOfT(Runs client, Guid subscriptionId, string resourceGroupName, string registryName, string filter, int? top, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _registryName = registryName; + _filter = filter; + _top = top; + _context = context; + } + + /// Gets the pages of RunsGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of RunsGetAllCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + RunListResult result = RunListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + string nextPageString = result.NextLink; + if (string.IsNullOrEmpty(nextPageString)) + { + yield break; + } + nextPage = new Uri(nextPageString, UriKind.RelativeOrAbsolute); + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _registryName, _filter, _top, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _registryName, _filter, _top, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("RunCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TaskRunsGetAllAsyncCollectionResultOfT.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TaskRunsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..e39a65e737fc --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TaskRunsGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerRegistryTasks.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class TaskRunsGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly TaskRuns _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _registryName; + private readonly RequestContext _context; + + /// Initializes a new instance of TaskRunsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The TaskRuns client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Registry. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public TaskRunsGetAllAsyncCollectionResultOfT(TaskRuns client, Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _registryName = registryName; + _context = context; + } + + /// Gets the pages of TaskRunsGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TaskRunsGetAllAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + TaskRunListResult result = TaskRunListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + string nextPageString = result.NextLink; + if (string.IsNullOrEmpty(nextPageString)) + { + yield break; + } + nextPage = new Uri(nextPageString, UriKind.RelativeOrAbsolute); + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _registryName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _registryName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TaskRunCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TaskRunsGetAllCollectionResultOfT.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TaskRunsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..4d0fa17992f6 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TaskRunsGetAllCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerRegistryTasks.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class TaskRunsGetAllCollectionResultOfT : Pageable + { + private readonly TaskRuns _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _registryName; + private readonly RequestContext _context; + + /// Initializes a new instance of TaskRunsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The TaskRuns client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Registry. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public TaskRunsGetAllCollectionResultOfT(TaskRuns client, Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _registryName = registryName; + _context = context; + } + + /// Gets the pages of TaskRunsGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TaskRunsGetAllCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + TaskRunListResult result = TaskRunListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + string nextPageString = result.NextLink; + if (string.IsNullOrEmpty(nextPageString)) + { + yield break; + } + nextPage = new Uri(nextPageString, UriKind.RelativeOrAbsolute); + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _registryName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _registryName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TaskRunCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TasksGetAllAsyncCollectionResultOfT.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TasksGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..bfb0a7b3c6e1 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TasksGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerRegistryTasks.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class TasksGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly Tasks _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _registryName; + private readonly RequestContext _context; + + /// Initializes a new instance of TasksGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Tasks client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Registry. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public TasksGetAllAsyncCollectionResultOfT(Tasks client, Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _registryName = registryName; + _context = context; + } + + /// Gets the pages of TasksGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TasksGetAllAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + TaskListResult result = TaskListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + string nextPageString = result.NextLink; + if (string.IsNullOrEmpty(nextPageString)) + { + yield break; + } + nextPage = new Uri(nextPageString, UriKind.RelativeOrAbsolute); + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _registryName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _registryName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TaskCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TasksGetAllCollectionResultOfT.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TasksGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..defe3a16d89f --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/CollectionResults/TasksGetAllCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerRegistryTasks.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class TasksGetAllCollectionResultOfT : Pageable + { + private readonly Tasks _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _registryName; + private readonly RequestContext _context; + + /// Initializes a new instance of TasksGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Tasks client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Registry. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public TasksGetAllCollectionResultOfT(Tasks client, Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _registryName = registryName; + _context = context; + } + + /// Gets the pages of TasksGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TasksGetAllCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + TaskListResult result = TaskListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + string nextPageString = result.NextLink; + if (string.IsNullOrEmpty(nextPageString)) + { + yield break; + } + nextPage = new Uri(nextPageString, UriKind.RelativeOrAbsolute); + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _registryName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _registryName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TaskCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Extensions/ContainerRegistryTasksExtensions.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Extensions/ContainerRegistryTasksExtensions.cs new file mode 100644 index 000000000000..fbab91f9821a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Extensions/ContainerRegistryTasksExtensions.cs @@ -0,0 +1,413 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.ContainerRegistryTasks.Mocking; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// A class to add extension methods to Azure.ResourceManager.ContainerRegistryTasks. + public static partial class ContainerRegistryTasksExtensions + { + /// + private static MockableContainerRegistryTasksArmClient GetMockableContainerRegistryTasksArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableContainerRegistryTasksArmClient(client0, ResourceIdentifier.Root)); + } + + /// + private static MockableContainerRegistryTasksResourceGroupResource GetMockableContainerRegistryTasksResourceGroupResource(ResourceGroupResource resourceGroupResource) + { + return resourceGroupResource.GetCachedClient(client => new MockableContainerRegistryTasksResourceGroupResource(client, resourceGroupResource.Id)); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static AgentPoolResource GetAgentPoolResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerRegistryTasksArmClient(client).GetAgentPoolResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static RunResource GetRunResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerRegistryTasksArmClient(client).GetRunResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static TaskRunResource GetTaskRunResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerRegistryTasksArmClient(client).GetTaskRunResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static TaskResource GetTaskResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerRegistryTasksArmClient(client).GetTaskResource(id); + } + + /// + /// Gets a collection of AgentPools in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// is null. + /// An object representing collection of AgentPools and their operations over a AgentPoolResource. + public static AgentPoolCollection GetAgentPools(this ResourceGroupResource resourceGroupResource, string registryName) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetAgentPools(registryName); + } + + /// + /// Gets the detailed information for a given agent pool. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// The name of the agent pool. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetAgentPoolAsync(this ResourceGroupResource resourceGroupResource, string registryName, string agentPoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetAgentPoolAsync(registryName, agentPoolName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the detailed information for a given agent pool. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// The name of the agent pool. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetAgentPool(this ResourceGroupResource resourceGroupResource, string registryName, string agentPoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetAgentPool(registryName, agentPoolName, cancellationToken); + } + + /// + /// Gets a collection of Runs in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// is null. + /// An object representing collection of Runs and their operations over a RunResource. + public static RunCollection GetRuns(this ResourceGroupResource resourceGroupResource, string registryName) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetRuns(registryName); + } + + /// + /// Gets the detailed information for a given run. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// The run ID. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetRunAsync(this ResourceGroupResource resourceGroupResource, string registryName, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetRunAsync(registryName, runId, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the detailed information for a given run. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// The run ID. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetRun(this ResourceGroupResource resourceGroupResource, string registryName, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetRun(registryName, runId, cancellationToken); + } + + /// + /// Gets a collection of TaskRuns in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// is null. + /// An object representing collection of TaskRuns and their operations over a TaskRunResource. + public static TaskRunCollection GetTaskRuns(this ResourceGroupResource resourceGroupResource, string registryName) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetTaskRuns(registryName); + } + + /// + /// Gets the detailed information for a given task run. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// The name of the task run. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetTaskRunAsync(this ResourceGroupResource resourceGroupResource, string registryName, string taskRunName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetTaskRunAsync(registryName, taskRunName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the detailed information for a given task run. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// The name of the task run. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetTaskRun(this ResourceGroupResource resourceGroupResource, string registryName, string taskRunName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetTaskRun(registryName, taskRunName, cancellationToken); + } + + /// + /// Gets a collection of Tasks in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// is null. + /// An object representing collection of Tasks and their operations over a TaskResource. + public static TaskCollection GetTasks(this ResourceGroupResource resourceGroupResource, string registryName) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetTasks(registryName); + } + + /// + /// Get the properties of a specified task. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// The name of the container registry task. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetTaskAsync(this ResourceGroupResource resourceGroupResource, string registryName, string taskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetTaskAsync(registryName, taskName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get the properties of a specified task. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The registryName for the resource. + /// The name of the container registry task. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetTask(this ResourceGroupResource resourceGroupResource, string registryName, string taskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetTask(registryName, taskName, cancellationToken); + } + + /// + /// Schedules a new run based on the request parameters and add it to the run queue. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the container registry. + /// The request body. + /// The cancellation token to use. + /// is null. + public static async Task> ScheduleRunAsync(this ResourceGroupResource resourceGroupResource, string registryName, RunContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).ScheduleRunAsync(registryName, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// Schedules a new run based on the request parameters and add it to the run queue. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the container registry. + /// The request body. + /// The cancellation token to use. + /// is null. + public static Response ScheduleRun(this ResourceGroupResource resourceGroupResource, string registryName, RunContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).ScheduleRun(registryName, content, cancellationToken); + } + + /// + /// Get the upload location for the user to be able to upload the source. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the container registry. + /// The cancellation token to use. + /// is null. + public static async Task> GetBuildSourceUploadUrlAsync(this ResourceGroupResource resourceGroupResource, string registryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetBuildSourceUploadUrlAsync(registryName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get the upload location for the user to be able to upload the source. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the container registry. + /// The cancellation token to use. + /// is null. + public static Response GetBuildSourceUploadUrl(this ResourceGroupResource resourceGroupResource, string registryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContainerRegistryTasksResourceGroupResource(resourceGroupResource).GetBuildSourceUploadUrl(registryName, cancellationToken); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Extensions/MockableContainerRegistryTasksArmClient.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Extensions/MockableContainerRegistryTasksArmClient.cs new file mode 100644 index 000000000000..d6c5efd06075 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Extensions/MockableContainerRegistryTasksArmClient.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Mocking +{ + /// A class to add extension methods to . + public partial class MockableContainerRegistryTasksArmClient : ArmResource + { + /// Initializes a new instance of MockableContainerRegistryTasksArmClient for mocking. + protected MockableContainerRegistryTasksArmClient() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableContainerRegistryTasksArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AgentPoolResource GetAgentPoolResource(ResourceIdentifier id) + { + AgentPoolResource.ValidateResourceId(id); + return new AgentPoolResource(Client, id); + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual RunResource GetRunResource(ResourceIdentifier id) + { + RunResource.ValidateResourceId(id); + return new RunResource(Client, id); + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual TaskRunResource GetTaskRunResource(ResourceIdentifier id) + { + TaskRunResource.ValidateResourceId(id); + return new TaskRunResource(Client, id); + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual TaskResource GetTaskResource(ResourceIdentifier id) + { + TaskResource.ValidateResourceId(id); + return new TaskResource(Client, id); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Extensions/MockableContainerRegistryTasksResourceGroupResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Extensions/MockableContainerRegistryTasksResourceGroupResource.cs new file mode 100644 index 000000000000..70f47a0bda0f --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Extensions/MockableContainerRegistryTasksResourceGroupResource.cs @@ -0,0 +1,515 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ContainerRegistryTasks; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Mocking +{ + /// A class to add extension methods to . + public partial class MockableContainerRegistryTasksResourceGroupResource : ArmResource + { + private ClientDiagnostics _registriesClientDiagnostics; + private Registries _registriesRestClient; + + /// Initializes a new instance of MockableContainerRegistryTasksResourceGroupResource for mocking. + protected MockableContainerRegistryTasksResourceGroupResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableContainerRegistryTasksResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics RegistriesClientDiagnostics => _registriesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.ContainerRegistryTasks.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private Registries RegistriesRestClient => _registriesRestClient ??= new Registries(RegistriesClientDiagnostics, Pipeline, Endpoint, "2025-03-01-preview"); + + /// Gets a collection of AgentPools in the . + /// The registryName for the resource. + /// An object representing collection of AgentPools and their operations over a AgentPoolResource. + public virtual AgentPoolCollection GetAgentPools(string registryName) + { + return GetCachedClient(client => new AgentPoolCollection(client, Id, registryName)); + } + + /// + /// Gets the detailed information for a given agent pool. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The registryName for the resource. + /// The name of the agent pool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAgentPoolAsync(string registryName, string agentPoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentPoolName, nameof(agentPoolName)); + + return await GetAgentPools(registryName).GetAsync(agentPoolName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the detailed information for a given agent pool. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}. + /// + /// + /// Operation Id. + /// AgentPools_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The registryName for the resource. + /// The name of the agent pool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAgentPool(string registryName, string agentPoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentPoolName, nameof(agentPoolName)); + + return GetAgentPools(registryName).Get(agentPoolName, cancellationToken); + } + + /// Gets a collection of Runs in the . + /// The registryName for the resource. + /// An object representing collection of Runs and their operations over a RunResource. + public virtual RunCollection GetRuns(string registryName) + { + return GetCachedClient(client => new RunCollection(client, Id, registryName)); + } + + /// + /// Gets the detailed information for a given run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The registryName for the resource. + /// The run ID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetRunAsync(string registryName, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + return await GetRuns(registryName).GetAsync(runId, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the detailed information for a given run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The registryName for the resource. + /// The run ID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetRun(string registryName, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + return GetRuns(registryName).Get(runId, cancellationToken); + } + + /// Gets a collection of TaskRuns in the . + /// The registryName for the resource. + /// An object representing collection of TaskRuns and their operations over a TaskRunResource. + public virtual TaskRunCollection GetTaskRuns(string registryName) + { + return GetCachedClient(client => new TaskRunCollection(client, Id, registryName)); + } + + /// + /// Gets the detailed information for a given task run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The registryName for the resource. + /// The name of the task run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTaskRunAsync(string registryName, string taskRunName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskRunName, nameof(taskRunName)); + + return await GetTaskRuns(registryName).GetAsync(taskRunName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the detailed information for a given task run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The registryName for the resource. + /// The name of the task run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTaskRun(string registryName, string taskRunName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskRunName, nameof(taskRunName)); + + return GetTaskRuns(registryName).Get(taskRunName, cancellationToken); + } + + /// Gets a collection of Tasks in the . + /// The registryName for the resource. + /// An object representing collection of Tasks and their operations over a TaskResource. + public virtual TaskCollection GetTasks(string registryName) + { + return GetCachedClient(client => new TaskCollection(client, Id, registryName)); + } + + /// + /// Get the properties of a specified task. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The registryName for the resource. + /// The name of the container registry task. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTaskAsync(string registryName, string taskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskName, nameof(taskName)); + + return await GetTasks(registryName).GetAsync(taskName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get the properties of a specified task. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The registryName for the resource. + /// The name of the container registry task. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTask(string registryName, string taskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskName, nameof(taskName)); + + return GetTasks(registryName).Get(taskName, cancellationToken); + } + + /// + /// Schedules a new run based on the request parameters and add it to the run queue. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun. + /// + /// + /// Operation Id. + /// Registries_ScheduleRun. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the container registry. + /// The request body. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ScheduleRunAsync(string registryName, RunContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(registryName, nameof(registryName)); + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = RegistriesClientDiagnostics.CreateScope("MockableContainerRegistryTasksResourceGroupResource.ScheduleRun"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = RegistriesRestClient.CreateScheduleRunRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, registryName, RunContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(RunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new RunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Schedules a new run based on the request parameters and add it to the run queue. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun. + /// + /// + /// Operation Id. + /// Registries_ScheduleRun. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the container registry. + /// The request body. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response ScheduleRun(string registryName, RunContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(registryName, nameof(registryName)); + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = RegistriesClientDiagnostics.CreateScope("MockableContainerRegistryTasksResourceGroupResource.ScheduleRun"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = RegistriesRestClient.CreateScheduleRunRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, registryName, RunContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(RunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new RunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the upload location for the user to be able to upload the source. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl. + /// + /// + /// Operation Id. + /// Registries_GetBuildSourceUploadUrl. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the container registry. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetBuildSourceUploadUrlAsync(string registryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(registryName, nameof(registryName)); + + using DiagnosticScope scope = RegistriesClientDiagnostics.CreateScope("MockableContainerRegistryTasksResourceGroupResource.GetBuildSourceUploadUrl"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = RegistriesRestClient.CreateGetBuildSourceUploadUrlRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, registryName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SourceUploadResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the upload location for the user to be able to upload the source. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl. + /// + /// + /// Operation Id. + /// Registries_GetBuildSourceUploadUrl. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the container registry. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetBuildSourceUploadUrl(string registryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(registryName, nameof(registryName)); + + using DiagnosticScope scope = RegistriesClientDiagnostics.CreateScope("MockableContainerRegistryTasksResourceGroupResource.GetBuildSourceUploadUrl"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = RegistriesRestClient.CreateGetBuildSourceUploadUrlRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, registryName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SourceUploadResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/Argument.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..14e3c8df26b4 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/Argument.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal static partial class Argument + { + /// The value. + /// The name. + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + /// The value. + /// The minimum value. + /// The maximum value. + /// The name. + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + /// The value. + /// The name. + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..b806461b7696 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/AsyncPageableWrapper.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class AsyncPageableWrapper : AsyncPageable + { + /// The source async pageable value of type AsyncPageable<T>. + private AsyncPageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the AsyncPageableWrapper class. + /// The source async pageable value of type AsyncPageable<T>. + /// The converter function from T to U. + public AsyncPageableWrapper(AsyncPageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from AsyncPageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + await foreach (Page page in _source.AsPages(continuationToken, pageSizeHint).ConfigureAwait(false)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..98a47aa18b6d --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerDictionary == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + /// Gets the Keys. + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + /// Gets the Values. + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + /// Gets or sets the value associated with the specified key. + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + /// Gets the Keys. + IEnumerable IReadOnlyDictionary.Keys => Keys; + + /// Gets the Values. + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + /// The item to search for. + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + /// The array to copy. + /// The index. + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + /// The item to remove. + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + /// The key. + /// The value to add. + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + /// The key to search for. + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + /// The key. + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + /// The key to search for. + /// The value. + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ChangeTrackingList.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..da863b6201cd --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + /// The inner list. + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + /// The inner list. + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerList == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureList().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + /// Gets or sets the value associated with the specified key. + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + /// The item. + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + /// The array to copy to. + /// The array index. + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + /// The item. + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + /// The item. + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + /// The inner list. + /// The item. + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + /// The inner list. + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..3b902d582bfa --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions errorOptions) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (errorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions errorOptions) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (errorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..72778edeb7e4 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dfcabf517497 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..38d536e69173 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f36b5f513173 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ErrorResult.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..4bd653b84fd3 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class ErrorResult : Response + { + private readonly Response _response; + private readonly RequestFailedException _exception; + + public ErrorResult(Response response, RequestFailedException exception) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + + /// + public override Response GetRawResponse() + { + return _response; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..096d6afb5c9b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,268 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Runtime.InteropServices; +using System.Text.Json; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + Dictionary dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + List list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + string text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) + { + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + string value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + public static BinaryData GetUtf8Bytes(this JsonElement element) + { +#if NET9_0_OR_GREATER + return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); +#else + return BinaryData.FromString(element.GetRawText()); +#endif + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/Optional.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..2e771fb46321 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal static partial class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(string value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/PageableWrapper.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..5d9342d214ea --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/PageableWrapper.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class PageableWrapper : Pageable + { + /// The source pageable value of type Pageable<T>. + private Pageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the PageableWrapper class. + /// The source pageable value of type Pageable<T>. + /// The converter function from T to U. + public PageableWrapper(Pageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from Pageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + foreach (Page page in _source.AsPages(continuationToken, pageSizeHint)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..df06dc1ed683 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + + public static void UpdateQuery(this RawRequestUriBuilder builder, string name, string value) + { + string currentQuery = builder.Query; + string searchPattern = string.Concat(name, "="); + int paramStartIndex = -1; + if (currentQuery.StartsWith(string.Concat("?", searchPattern))) + { + paramStartIndex = 1; + } + if (paramStartIndex == -1) + { + string prefixedPattern = string.Concat("&", searchPattern); + int prefixedIndex = currentQuery.IndexOf(prefixedPattern); + if (prefixedIndex >= 0) + { + paramStartIndex = prefixedIndex + 1; + } + } + if (paramStartIndex >= 0) + { + int valueStartIndex = paramStartIndex + searchPattern.Length; + int valueEndIndex = currentQuery.IndexOf('&', valueStartIndex); + if (valueEndIndex == -1) + { + valueEndIndex = currentQuery.Length; + } + string beforeParam = currentQuery.Substring(0, valueStartIndex); + string afterParam = currentQuery.Substring(valueEndIndex); + string newQuery = string.Concat(beforeParam, value, afterParam); + builder.Query = newQuery; + } + else + { + builder.AppendQuery(name, value, true); + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/RequestContextExtensions.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..4be66c5d0af2 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/SerializationFormat.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..7e9d21b9be00 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/TypeFormatters.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..fb1f798d7228 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..e71877ef6eae --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + /// Gets the JsonWriter. + public Utf8JsonWriter JsonWriter { get; } + + /// The stream containing the data to be written. + /// The cancellation token to use. + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + /// The stream containing the data to be written. + /// The cancellation token to use. + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + /// + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/AgentPoolOperationSource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/AgentPoolOperationSource.cs new file mode 100644 index 000000000000..e82b419a212f --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/AgentPoolOperationSource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + internal partial class AgentPoolOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal AgentPoolOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + AgentPoolResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + AgentPoolData data = AgentPoolData.DeserializeAgentPoolData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new AgentPoolResource(_client, data); + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + AgentPoolData data = AgentPoolData.DeserializeAgentPoolData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new AgentPoolResource(_client, data); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/ContainerRegistryTasksArmOperation.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/ContainerRegistryTasksArmOperation.cs new file mode 100644 index 000000000000..05ecc14bafb0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/ContainerRegistryTasksArmOperation.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class ContainerRegistryTasksArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of ContainerRegistryTasksArmOperation for mocking. + protected ContainerRegistryTasksArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal ContainerRegistryTasksArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal ContainerRegistryTasksArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "ContainerRegistryTasksArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/ContainerRegistryTasksArmOperationOfT.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/ContainerRegistryTasksArmOperationOfT.cs new file mode 100644 index 000000000000..f713cffdf35b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/ContainerRegistryTasksArmOperationOfT.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class ContainerRegistryTasksArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of ContainerRegistryTasksArmOperation for mocking. + protected ContainerRegistryTasksArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal ContainerRegistryTasksArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal ContainerRegistryTasksArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "ContainerRegistryTasksArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the Value. + public override T Value => _operation.Value; + + /// Gets the HasValue. + public override bool HasValue => _operation.HasValue; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/TaskRunOperationSource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/TaskRunOperationSource.cs new file mode 100644 index 000000000000..b3914c378051 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/LongRunningOperation/TaskRunOperationSource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + internal partial class TaskRunOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal TaskRunOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + TaskRunResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + TaskRunData data = TaskRunData.DeserializeTaskRunData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new TaskRunResource(_client, data); + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + TaskRunData data = TaskRunData.DeserializeTaskRunData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new TaskRunResource(_client, data); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolListResult.Serialization.cs new file mode 100644 index 000000000000..52149dc620d7 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolListResult.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The collection of agent pools. + internal partial class AgentPoolListResult : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentPoolListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentPoolListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentPoolListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(AgentPoolListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AgentPoolListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AgentPoolListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgentPoolListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolListResult)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (AgentPoolData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentPoolListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentPoolListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentPoolListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentPoolListResult DeserializeAgentPoolListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + string nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(AgentPoolData.DeserializeAgentPoolData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + nextLink = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentPoolListResult(value ?? new ChangeTrackingList(), nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolListResult.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolListResult.cs new file mode 100644 index 000000000000..df2d8b9e860f --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The collection of agent pools. + internal partial class AgentPoolListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal AgentPoolListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The collection value. + /// The URI that can be used to request the next set of paged results. + /// Keeps track of any properties unknown to the library. + internal AgentPoolListResult(IList value, string nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The collection value. + public IList Value { get; } + + /// The URI that can be used to request the next set of paged results. + public string NextLink { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPatch.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPatch.Serialization.cs new file mode 100644 index 000000000000..b4dbd5ae280d --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPatch.Serialization.cs @@ -0,0 +1,196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for updating an agent pool. + public partial class AgentPoolPatch : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentPoolPatch PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentPoolPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentPoolPatch)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(AgentPoolPatch)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AgentPoolPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(AgentPoolPatch agentPoolPatch) + { + if (agentPoolPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(agentPoolPatch, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolPatch)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentPoolPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentPoolPatch JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolPatch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentPoolPatch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentPoolPatch DeserializeAgentPoolPatch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentPoolPropertiesUpdateParameters properties = default; + IDictionary tags = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = AgentPoolPropertiesUpdateParameters.DeserializeAgentPoolPropertiesUpdateParameters(prop.Value, options); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentPoolPatch(properties, tags ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPatch.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPatch.cs new file mode 100644 index 000000000000..c6d33976cb16 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPatch.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for updating an agent pool. + public partial class AgentPoolPatch + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AgentPoolPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The properties associated with the agent pool. + /// The ARM resource tags. + /// Keeps track of any properties unknown to the library. + internal AgentPoolPatch(AgentPoolPropertiesUpdateParameters properties, IDictionary tags, IDictionary additionalBinaryDataProperties) + { + Properties = properties; + Tags = tags; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The properties associated with the agent pool. + internal AgentPoolPropertiesUpdateParameters Properties { get; set; } + + /// The ARM resource tags. + public IDictionary Tags { get; } + + /// The count of agent machine. + public int? Count + { + get + { + return Properties is null ? default : Properties.Count; + } + set + { + if (Properties is null) + { + Properties = new AgentPoolPropertiesUpdateParameters(); + } + Properties.Count = value.Value; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolProperties.Serialization.cs new file mode 100644 index 000000000000..8c459901142a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolProperties.Serialization.cs @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of agent pool. + internal partial class AgentPoolProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentPoolProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentPoolProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentPoolProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(AgentPoolProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AgentPoolProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (Optional.IsDefined(Tier)) + { + writer.WritePropertyName("tier"u8); + writer.WriteStringValue(Tier); + } + if (Optional.IsDefined(OS)) + { + writer.WritePropertyName("os"u8); + writer.WriteStringValue(OS.Value.ToString()); + } + if (Optional.IsDefined(VirtualNetworkSubnetResourceId)) + { + writer.WritePropertyName("virtualNetworkSubnetResourceId"u8); + writer.WriteStringValue(VirtualNetworkSubnetResourceId); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentPoolProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentPoolProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentPoolProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentPoolProperties DeserializeAgentPoolProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? count = default; + string tier = default; + ContainerRegistryTaskOS? os = default; + ResourceIdentifier virtualNetworkSubnetResourceId = default; + ContainerRegistryTaskProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("count"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("tier"u8)) + { + tier = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("os"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + os = new ContainerRegistryTaskOS(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("virtualNetworkSubnetResourceId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + virtualNetworkSubnetResourceId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ContainerRegistryTaskProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentPoolProperties( + count, + tier, + os, + virtualNetworkSubnetResourceId, + provisioningState, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolProperties.cs new file mode 100644 index 000000000000..b849bcd1576c --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolProperties.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of agent pool. + internal partial class AgentPoolProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AgentPoolProperties() + { + } + + /// Initializes a new instance of . + /// The count of agent machine. + /// The Tier of agent machine. + /// The OS of agent machine. + /// The Virtual Network Subnet Resource Id of the agent machine. + /// The provisioning state of this agent pool. + /// Keeps track of any properties unknown to the library. + internal AgentPoolProperties(int? count, string tier, ContainerRegistryTaskOS? os, ResourceIdentifier virtualNetworkSubnetResourceId, ContainerRegistryTaskProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + Count = count; + Tier = tier; + OS = os; + VirtualNetworkSubnetResourceId = virtualNetworkSubnetResourceId; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The count of agent machine. + public int? Count { get; set; } + + /// The Tier of agent machine. + public string Tier { get; set; } + + /// The OS of agent machine. + public ContainerRegistryTaskOS? OS { get; set; } + + /// The Virtual Network Subnet Resource Id of the agent machine. + public ResourceIdentifier VirtualNetworkSubnetResourceId { get; set; } + + /// The provisioning state of this agent pool. + public ContainerRegistryTaskProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPropertiesUpdateParameters.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPropertiesUpdateParameters.Serialization.cs new file mode 100644 index 000000000000..58e3b1d367f0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPropertiesUpdateParameters.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The AgentPoolPropertiesUpdateParameters. + internal partial class AgentPoolPropertiesUpdateParameters : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentPoolPropertiesUpdateParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentPoolPropertiesUpdateParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentPoolPropertiesUpdateParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(AgentPoolPropertiesUpdateParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AgentPoolPropertiesUpdateParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolPropertiesUpdateParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentPoolPropertiesUpdateParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentPoolPropertiesUpdateParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolPropertiesUpdateParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentPoolPropertiesUpdateParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentPoolPropertiesUpdateParameters DeserializeAgentPoolPropertiesUpdateParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? count = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("count"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentPoolPropertiesUpdateParameters(count, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPropertiesUpdateParameters.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPropertiesUpdateParameters.cs new file mode 100644 index 000000000000..bfb22548c7e0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolPropertiesUpdateParameters.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The AgentPoolPropertiesUpdateParameters. + internal partial class AgentPoolPropertiesUpdateParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AgentPoolPropertiesUpdateParameters() + { + } + + /// Initializes a new instance of . + /// The count of agent machine. + /// Keeps track of any properties unknown to the library. + internal AgentPoolPropertiesUpdateParameters(int? count, IDictionary additionalBinaryDataProperties) + { + Count = count; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The count of agent machine. + public int? Count { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolQueueStatus.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolQueueStatus.Serialization.cs new file mode 100644 index 000000000000..ce90b7a77dfc --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolQueueStatus.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The QueueStatus of Agent Pool. + public partial class AgentPoolQueueStatus : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentPoolQueueStatus PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentPoolQueueStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentPoolQueueStatus)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(AgentPoolQueueStatus)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AgentPoolQueueStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AgentPoolQueueStatus FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgentPoolQueueStatus(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolQueueStatus)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentPoolQueueStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentPoolQueueStatus JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentPoolQueueStatus)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentPoolQueueStatus(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentPoolQueueStatus DeserializeAgentPoolQueueStatus(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? count = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("count"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentPoolQueueStatus(count, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolQueueStatus.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolQueueStatus.cs new file mode 100644 index 000000000000..937f1ff6f118 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentPoolQueueStatus.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The QueueStatus of Agent Pool. + public partial class AgentPoolQueueStatus + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal AgentPoolQueueStatus() + { + } + + /// Initializes a new instance of . + /// The number of pending runs in the queue. + /// Keeps track of any properties unknown to the library. + internal AgentPoolQueueStatus(int? count, IDictionary additionalBinaryDataProperties) + { + Count = count; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The number of pending runs in the queue. + public int? Count { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentProperties.Serialization.cs new file mode 100644 index 000000000000..4da415663865 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentProperties.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties that determine the run agent configuration. + internal partial class AgentProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(AgentProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AgentProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Cpu)) + { + writer.WritePropertyName("cpu"u8); + writer.WriteNumberValue(Cpu.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentProperties DeserializeAgentProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? cpu = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("cpu"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cpu = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentProperties(cpu, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentProperties.cs new file mode 100644 index 000000000000..b01e311e0460 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AgentProperties.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties that determine the run agent configuration. + internal partial class AgentProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AgentProperties() + { + } + + /// Initializes a new instance of . + /// The CPU configuration in terms of number of cores required for the run. + /// Keeps track of any properties unknown to the library. + internal AgentProperties(int? cpu, IDictionary additionalBinaryDataProperties) + { + Cpu = cpu; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The CPU configuration in terms of number of cores required for the run. + public int? Cpu { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfo.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfo.Serialization.cs new file mode 100644 index 000000000000..699aa1c0e06e --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfo.Serialization.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The authorization properties for accessing the source code repository. + public partial class AuthInfo : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AuthInfo() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AuthInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAuthInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AuthInfo)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(AuthInfo)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AuthInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AuthInfo)} does not support writing '{format}' format."); + } + writer.WritePropertyName("tokenType"u8); + writer.WriteStringValue(TokenType.ToString()); + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + if (Optional.IsDefined(RefreshToken)) + { + writer.WritePropertyName("refreshToken"u8); + writer.WriteStringValue(RefreshToken); + } + if (Optional.IsDefined(Scope)) + { + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + } + if (Optional.IsDefined(ExpiresInSeconds)) + { + writer.WritePropertyName("expiresIn"u8); + writer.WriteNumberValue(ExpiresInSeconds.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AuthInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AuthInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AuthInfo)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAuthInfo(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AuthInfo DeserializeAuthInfo(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ContainerRegistryTaskTokenType tokenType = default; + string token = default; + string refreshToken = default; + string scope = default; + int? expiresInSeconds = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("tokenType"u8)) + { + tokenType = new ContainerRegistryTaskTokenType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("token"u8)) + { + token = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("refreshToken"u8)) + { + refreshToken = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("expiresIn"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiresInSeconds = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AuthInfo( + tokenType, + token, + refreshToken, + scope, + expiresInSeconds, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfo.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfo.cs new file mode 100644 index 000000000000..713fbeccfb7b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfo.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The authorization properties for accessing the source code repository. + public partial class AuthInfo + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of Auth token. + /// The access token used to access the source control provider. + /// is null. + public AuthInfo(ContainerRegistryTaskTokenType tokenType, string token) + { + Argument.AssertNotNull(token, nameof(token)); + + TokenType = tokenType; + Token = token; + } + + /// Initializes a new instance of . + /// The type of Auth token. + /// The access token used to access the source control provider. + /// The refresh token used to refresh the access token. + /// The scope of the access token. + /// Time in seconds that the token remains valid. + /// Keeps track of any properties unknown to the library. + internal AuthInfo(ContainerRegistryTaskTokenType tokenType, string token, string refreshToken, string scope, int? expiresInSeconds, IDictionary additionalBinaryDataProperties) + { + TokenType = tokenType; + Token = token; + RefreshToken = refreshToken; + Scope = scope; + ExpiresInSeconds = expiresInSeconds; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of Auth token. + public ContainerRegistryTaskTokenType TokenType { get; set; } + + /// The access token used to access the source control provider. + public string Token { get; set; } + + /// The refresh token used to refresh the access token. + public string RefreshToken { get; set; } + + /// The scope of the access token. + public string Scope { get; set; } + + /// Time in seconds that the token remains valid. + public int? ExpiresInSeconds { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfoUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfoUpdateContent.Serialization.cs new file mode 100644 index 000000000000..6121665f92e9 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfoUpdateContent.Serialization.cs @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The authorization properties for accessing the source code repository. + public partial class AuthInfoUpdateContent : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AuthInfoUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAuthInfoUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AuthInfoUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(AuthInfoUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AuthInfoUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AuthInfoUpdateContent)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(TokenType)) + { + writer.WritePropertyName("tokenType"u8); + writer.WriteStringValue(TokenType.Value.ToString()); + } + if (Optional.IsDefined(Token)) + { + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + } + if (Optional.IsDefined(RefreshToken)) + { + writer.WritePropertyName("refreshToken"u8); + writer.WriteStringValue(RefreshToken); + } + if (Optional.IsDefined(Scope)) + { + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + } + if (Optional.IsDefined(ExpiresInSeconds)) + { + writer.WritePropertyName("expiresIn"u8); + writer.WriteNumberValue(ExpiresInSeconds.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AuthInfoUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AuthInfoUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AuthInfoUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAuthInfoUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AuthInfoUpdateContent DeserializeAuthInfoUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ContainerRegistryTaskTokenType? tokenType = default; + string token = default; + string refreshToken = default; + string scope = default; + int? expiresInSeconds = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("tokenType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + tokenType = new ContainerRegistryTaskTokenType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("token"u8)) + { + token = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("refreshToken"u8)) + { + refreshToken = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("expiresIn"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiresInSeconds = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AuthInfoUpdateContent( + tokenType, + token, + refreshToken, + scope, + expiresInSeconds, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfoUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfoUpdateContent.cs new file mode 100644 index 000000000000..c36822d72b18 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AuthInfoUpdateContent.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The authorization properties for accessing the source code repository. + public partial class AuthInfoUpdateContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AuthInfoUpdateContent() + { + } + + /// Initializes a new instance of . + /// The type of Auth token. + /// The access token used to access the source control provider. + /// The refresh token used to refresh the access token. + /// The scope of the access token. + /// Time in seconds that the token remains valid. + /// Keeps track of any properties unknown to the library. + internal AuthInfoUpdateContent(ContainerRegistryTaskTokenType? tokenType, string token, string refreshToken, string scope, int? expiresInSeconds, IDictionary additionalBinaryDataProperties) + { + TokenType = tokenType; + Token = token; + RefreshToken = refreshToken; + Scope = scope; + ExpiresInSeconds = expiresInSeconds; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of Auth token. + public ContainerRegistryTaskTokenType? TokenType { get; set; } + + /// The access token used to access the source control provider. + public string Token { get; set; } + + /// The refresh token used to refresh the access token. + public string RefreshToken { get; set; } + + /// The scope of the access token. + public string Scope { get; set; } + + /// Time in seconds that the token remains valid. + public int? ExpiresInSeconds { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AzureResourceManagerContainerRegistryTasksContext.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AzureResourceManagerContainerRegistryTasksContext.cs new file mode 100644 index 000000000000..1716fdfce6d5 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/AzureResourceManagerContainerRegistryTasksContext.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(AgentPoolData))] + [ModelReaderWriterBuildable(typeof(AgentPoolListResult))] + [ModelReaderWriterBuildable(typeof(AgentPoolPatch))] + [ModelReaderWriterBuildable(typeof(AgentPoolProperties))] + [ModelReaderWriterBuildable(typeof(AgentPoolPropertiesUpdateParameters))] + [ModelReaderWriterBuildable(typeof(AgentPoolQueueStatus))] + [ModelReaderWriterBuildable(typeof(AgentPoolResource))] + [ModelReaderWriterBuildable(typeof(AgentProperties))] + [ModelReaderWriterBuildable(typeof(AuthInfo))] + [ModelReaderWriterBuildable(typeof(AuthInfoUpdateContent))] + [ModelReaderWriterBuildable(typeof(BaseImageDependency))] + [ModelReaderWriterBuildable(typeof(BaseImageTrigger))] + [ModelReaderWriterBuildable(typeof(BaseImageTriggerUpdateContent))] + [ModelReaderWriterBuildable(typeof(ContainerRegistryTaskArgument))] + [ModelReaderWriterBuildable(typeof(ContainerRegistryTaskCredentials))] + [ModelReaderWriterBuildable(typeof(ContainerRegistryTaskSecretObject))] + [ModelReaderWriterBuildable(typeof(ContainerRegistryTaskSetValue))] + [ModelReaderWriterBuildable(typeof(CustomRegistryCredentials))] + [ModelReaderWriterBuildable(typeof(DockerBuildContent))] + [ModelReaderWriterBuildable(typeof(DockerBuildStep))] + [ModelReaderWriterBuildable(typeof(DockerBuildStepUpdateContent))] + [ModelReaderWriterBuildable(typeof(EncodedTaskRunContent))] + [ModelReaderWriterBuildable(typeof(EncodedTaskStep))] + [ModelReaderWriterBuildable(typeof(EncodedTaskStepUpdateContent))] + [ModelReaderWriterBuildable(typeof(FileTaskRunContent))] + [ModelReaderWriterBuildable(typeof(FileTaskStep))] + [ModelReaderWriterBuildable(typeof(FileTaskStepUpdateContent))] + [ModelReaderWriterBuildable(typeof(IdentityProperties))] + [ModelReaderWriterBuildable(typeof(ImageDescriptor))] + [ModelReaderWriterBuildable(typeof(ImageUpdateTrigger))] + [ModelReaderWriterBuildable(typeof(OverrideTaskStepProperties))] + [ModelReaderWriterBuildable(typeof(PlatformProperties))] + [ModelReaderWriterBuildable(typeof(PlatformUpdateContent))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(RunContent))] + [ModelReaderWriterBuildable(typeof(RunData))] + [ModelReaderWriterBuildable(typeof(RunGetLogResult))] + [ModelReaderWriterBuildable(typeof(RunListResult))] + [ModelReaderWriterBuildable(typeof(RunPatch))] + [ModelReaderWriterBuildable(typeof(RunProperties))] + [ModelReaderWriterBuildable(typeof(RunResource))] + [ModelReaderWriterBuildable(typeof(SourceProperties))] + [ModelReaderWriterBuildable(typeof(SourceRegistryCredentials))] + [ModelReaderWriterBuildable(typeof(SourceTrigger))] + [ModelReaderWriterBuildable(typeof(SourceTriggerDescriptor))] + [ModelReaderWriterBuildable(typeof(SourceTriggerUpdateContent))] + [ModelReaderWriterBuildable(typeof(SourceUpdateContent))] + [ModelReaderWriterBuildable(typeof(SourceUploadResult))] + [ModelReaderWriterBuildable(typeof(SystemData))] + [ModelReaderWriterBuildable(typeof(TaskData))] + [ModelReaderWriterBuildable(typeof(TaskListResult))] + [ModelReaderWriterBuildable(typeof(TaskPatch))] + [ModelReaderWriterBuildable(typeof(TaskProperties))] + [ModelReaderWriterBuildable(typeof(TaskPropertiesUpdateParameters))] + [ModelReaderWriterBuildable(typeof(TaskResource))] + [ModelReaderWriterBuildable(typeof(TaskRunContent))] + [ModelReaderWriterBuildable(typeof(TaskRunData))] + [ModelReaderWriterBuildable(typeof(TaskRunListResult))] + [ModelReaderWriterBuildable(typeof(TaskRunPatch))] + [ModelReaderWriterBuildable(typeof(TaskRunProperties))] + [ModelReaderWriterBuildable(typeof(TaskRunPropertiesUpdateParameters))] + [ModelReaderWriterBuildable(typeof(TaskRunResource))] + [ModelReaderWriterBuildable(typeof(TaskStepProperties))] + [ModelReaderWriterBuildable(typeof(TaskStepUpdateContent))] + [ModelReaderWriterBuildable(typeof(TimerTrigger))] + [ModelReaderWriterBuildable(typeof(TimerTriggerDescriptor))] + [ModelReaderWriterBuildable(typeof(TimerTriggerUpdateContent))] + [ModelReaderWriterBuildable(typeof(TriggerProperties))] + [ModelReaderWriterBuildable(typeof(TriggerUpdateContent))] + [ModelReaderWriterBuildable(typeof(UnknownRunContent))] + [ModelReaderWriterBuildable(typeof(UnknownTaskStepProperties))] + [ModelReaderWriterBuildable(typeof(UnknownTaskStepUpdateContent))] + [ModelReaderWriterBuildable(typeof(UserIdentityProperties))] + public partial class AzureResourceManagerContainerRegistryTasksContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageDependency.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageDependency.Serialization.cs new file mode 100644 index 000000000000..8d44db146a3a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageDependency.Serialization.cs @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Properties that describe a base image dependency. + public partial class BaseImageDependency : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BaseImageDependency PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBaseImageDependency(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BaseImageDependency)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(BaseImageDependency)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BaseImageDependency IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BaseImageDependency)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsDefined(Registry)) + { + writer.WritePropertyName("registry"u8); + writer.WriteStringValue(Registry); + } + if (Optional.IsDefined(Repository)) + { + writer.WritePropertyName("repository"u8); + writer.WriteStringValue(Repository); + } + if (Optional.IsDefined(Tag)) + { + writer.WritePropertyName("tag"u8); + writer.WriteStringValue(Tag); + } + if (Optional.IsDefined(Digest)) + { + writer.WritePropertyName("digest"u8); + writer.WriteStringValue(Digest); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BaseImageDependency IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BaseImageDependency JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BaseImageDependency)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBaseImageDependency(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BaseImageDependency DeserializeBaseImageDependency(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BaseImageDependencyType? @type = default; + string registry = default; + string repository = default; + string tag = default; + string digest = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @type = new BaseImageDependencyType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("registry"u8)) + { + registry = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("repository"u8)) + { + repository = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tag"u8)) + { + tag = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("digest"u8)) + { + digest = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BaseImageDependency( + @type, + registry, + repository, + tag, + digest, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageDependency.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageDependency.cs new file mode 100644 index 000000000000..8fa5640ca190 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageDependency.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Properties that describe a base image dependency. + public partial class BaseImageDependency + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal BaseImageDependency() + { + } + + /// Initializes a new instance of . + /// The type of the base image dependency. + /// The registry login server. + /// The repository name. + /// The tag name. + /// The sha256-based digest of the image manifest. + /// Keeps track of any properties unknown to the library. + internal BaseImageDependency(BaseImageDependencyType? @type, string registry, string repository, string tag, string digest, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Registry = registry; + Repository = repository; + Tag = tag; + Digest = digest; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of the base image dependency. + public BaseImageDependencyType? Type { get; } + + /// The registry login server. + public string Registry { get; } + + /// The repository name. + public string Repository { get; } + + /// The tag name. + public string Tag { get; } + + /// The sha256-based digest of the image manifest. + public string Digest { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageDependencyType.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageDependencyType.cs new file mode 100644 index 000000000000..82db9c9406d7 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageDependencyType.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The type of the base image dependency. + public readonly partial struct BaseImageDependencyType : IEquatable + { + private readonly string _value; + private const string BuildTimeValue = "BuildTime"; + private const string RunTimeValue = "RunTime"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public BaseImageDependencyType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the BuildTime. + public static BaseImageDependencyType BuildTime { get; } = new BaseImageDependencyType(BuildTimeValue); + + /// Gets the RunTime. + public static BaseImageDependencyType RunTime { get; } = new BaseImageDependencyType(RunTimeValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(BaseImageDependencyType left, BaseImageDependencyType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(BaseImageDependencyType left, BaseImageDependencyType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator BaseImageDependencyType(string value) => new BaseImageDependencyType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator BaseImageDependencyType?(string value) => value == null ? null : new BaseImageDependencyType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is BaseImageDependencyType other && Equals(other); + + /// + public bool Equals(BaseImageDependencyType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTrigger.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTrigger.Serialization.cs new file mode 100644 index 000000000000..cac98eb011a3 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTrigger.Serialization.cs @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The trigger based on base image dependency. + public partial class BaseImageTrigger : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BaseImageTrigger() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BaseImageTrigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBaseImageTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BaseImageTrigger)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(BaseImageTrigger)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BaseImageTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BaseImageTrigger)} does not support writing '{format}' format."); + } + writer.WritePropertyName("baseImageTriggerType"u8); + writer.WriteStringValue(BaseImageTriggerType.ToString()); + if (Optional.IsDefined(UpdateTriggerEndpoint)) + { + writer.WritePropertyName("updateTriggerEndpoint"u8); + writer.WriteStringValue(UpdateTriggerEndpoint); + } + if (Optional.IsDefined(UpdateTriggerPayloadType)) + { + writer.WritePropertyName("updateTriggerPayloadType"u8); + writer.WriteStringValue(UpdateTriggerPayloadType.Value.ToString()); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BaseImageTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BaseImageTrigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BaseImageTrigger)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBaseImageTrigger(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BaseImageTrigger DeserializeBaseImageTrigger(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BaseImageTriggerType baseImageTriggerType = default; + string updateTriggerEndpoint = default; + UpdateTriggerPayloadType? updateTriggerPayloadType = default; + ContainerRegistryTaskTriggerStatus? status = default; + string name = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("baseImageTriggerType"u8)) + { + baseImageTriggerType = new BaseImageTriggerType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("updateTriggerEndpoint"u8)) + { + updateTriggerEndpoint = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("updateTriggerPayloadType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updateTriggerPayloadType = new UpdateTriggerPayloadType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ContainerRegistryTaskTriggerStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BaseImageTrigger( + baseImageTriggerType, + updateTriggerEndpoint, + updateTriggerPayloadType, + status, + name, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTrigger.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTrigger.cs new file mode 100644 index 000000000000..7692226b901d --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTrigger.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The trigger based on base image dependency. + public partial class BaseImageTrigger + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of the auto trigger for base image dependency updates. + /// The name of the trigger. + /// is null. + public BaseImageTrigger(BaseImageTriggerType baseImageTriggerType, string name) + { + Argument.AssertNotNull(name, nameof(name)); + + BaseImageTriggerType = baseImageTriggerType; + Name = name; + } + + /// Initializes a new instance of . + /// The type of the auto trigger for base image dependency updates. + /// The endpoint URL for receiving update triggers. + /// Type of Payload body for Base image update triggers. + /// The current status of trigger. + /// The name of the trigger. + /// Keeps track of any properties unknown to the library. + internal BaseImageTrigger(BaseImageTriggerType baseImageTriggerType, string updateTriggerEndpoint, UpdateTriggerPayloadType? updateTriggerPayloadType, ContainerRegistryTaskTriggerStatus? status, string name, IDictionary additionalBinaryDataProperties) + { + BaseImageTriggerType = baseImageTriggerType; + UpdateTriggerEndpoint = updateTriggerEndpoint; + UpdateTriggerPayloadType = updateTriggerPayloadType; + Status = status; + Name = name; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of the auto trigger for base image dependency updates. + public BaseImageTriggerType BaseImageTriggerType { get; set; } + + /// The endpoint URL for receiving update triggers. + public string UpdateTriggerEndpoint { get; set; } + + /// Type of Payload body for Base image update triggers. + public UpdateTriggerPayloadType? UpdateTriggerPayloadType { get; set; } + + /// The current status of trigger. + public ContainerRegistryTaskTriggerStatus? Status { get; set; } + + /// The name of the trigger. + public string Name { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTriggerType.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTriggerType.cs new file mode 100644 index 000000000000..fa21e490eaaa --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTriggerType.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The type of the auto trigger for base image dependency updates. + public readonly partial struct BaseImageTriggerType : IEquatable + { + private readonly string _value; + private const string AllValue = "All"; + private const string RuntimeValue = "Runtime"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public BaseImageTriggerType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the All. + public static BaseImageTriggerType All { get; } = new BaseImageTriggerType(AllValue); + + /// Gets the Runtime. + public static BaseImageTriggerType Runtime { get; } = new BaseImageTriggerType(RuntimeValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(BaseImageTriggerType left, BaseImageTriggerType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(BaseImageTriggerType left, BaseImageTriggerType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator BaseImageTriggerType(string value) => new BaseImageTriggerType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator BaseImageTriggerType?(string value) => value == null ? null : new BaseImageTriggerType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is BaseImageTriggerType other && Equals(other); + + /// + public bool Equals(BaseImageTriggerType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTriggerUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTriggerUpdateContent.Serialization.cs new file mode 100644 index 000000000000..67a5f4613b0e --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTriggerUpdateContent.Serialization.cs @@ -0,0 +1,205 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating base image dependency trigger. + public partial class BaseImageTriggerUpdateContent : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BaseImageTriggerUpdateContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BaseImageTriggerUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBaseImageTriggerUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BaseImageTriggerUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(BaseImageTriggerUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BaseImageTriggerUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BaseImageTriggerUpdateContent)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(BaseImageTriggerType)) + { + writer.WritePropertyName("baseImageTriggerType"u8); + writer.WriteStringValue(BaseImageTriggerType.Value.ToString()); + } + if (Optional.IsDefined(UpdateTriggerEndpoint)) + { + writer.WritePropertyName("updateTriggerEndpoint"u8); + writer.WriteStringValue(UpdateTriggerEndpoint); + } + if (Optional.IsDefined(UpdateTriggerPayloadType)) + { + writer.WritePropertyName("updateTriggerPayloadType"u8); + writer.WriteStringValue(UpdateTriggerPayloadType.Value.ToString()); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BaseImageTriggerUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BaseImageTriggerUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BaseImageTriggerUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBaseImageTriggerUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BaseImageTriggerUpdateContent DeserializeBaseImageTriggerUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BaseImageTriggerType? baseImageTriggerType = default; + string updateTriggerEndpoint = default; + UpdateTriggerPayloadType? updateTriggerPayloadType = default; + ContainerRegistryTaskTriggerStatus? status = default; + string name = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("baseImageTriggerType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + baseImageTriggerType = new BaseImageTriggerType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("updateTriggerEndpoint"u8)) + { + updateTriggerEndpoint = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("updateTriggerPayloadType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updateTriggerPayloadType = new UpdateTriggerPayloadType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ContainerRegistryTaskTriggerStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BaseImageTriggerUpdateContent( + baseImageTriggerType, + updateTriggerEndpoint, + updateTriggerPayloadType, + status, + name, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTriggerUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTriggerUpdateContent.cs new file mode 100644 index 000000000000..a14a6d45d1b3 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/BaseImageTriggerUpdateContent.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating base image dependency trigger. + public partial class BaseImageTriggerUpdateContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the trigger. + /// is null. + public BaseImageTriggerUpdateContent(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + /// Initializes a new instance of . + /// The type of the auto trigger for base image dependency updates. + /// The endpoint URL for receiving update triggers. + /// Type of Payload body for Base image update triggers. + /// The current status of trigger. + /// The name of the trigger. + /// Keeps track of any properties unknown to the library. + internal BaseImageTriggerUpdateContent(BaseImageTriggerType? baseImageTriggerType, string updateTriggerEndpoint, UpdateTriggerPayloadType? updateTriggerPayloadType, ContainerRegistryTaskTriggerStatus? status, string name, IDictionary additionalBinaryDataProperties) + { + BaseImageTriggerType = baseImageTriggerType; + UpdateTriggerEndpoint = updateTriggerEndpoint; + UpdateTriggerPayloadType = updateTriggerPayloadType; + Status = status; + Name = name; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of the auto trigger for base image dependency updates. + public BaseImageTriggerType? BaseImageTriggerType { get; set; } + + /// The endpoint URL for receiving update triggers. + public string UpdateTriggerEndpoint { get; set; } + + /// Type of Payload body for Base image update triggers. + public UpdateTriggerPayloadType? UpdateTriggerPayloadType { get; set; } + + /// The current status of trigger. + public ContainerRegistryTaskTriggerStatus? Status { get; set; } + + /// The name of the trigger. + public string Name { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskArchitecture.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskArchitecture.cs new file mode 100644 index 000000000000..21b31496eb4c --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskArchitecture.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The OS architecture. + public readonly partial struct ContainerRegistryTaskArchitecture : IEquatable + { + private readonly string _value; + private const string Amd64Value = "amd64"; + private const string X86Value = "x86"; + private const string _386Value = "386"; + private const string ArmValue = "arm"; + private const string Arm64Value = "arm64"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ContainerRegistryTaskArchitecture(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Amd64. + public static ContainerRegistryTaskArchitecture Amd64 { get; } = new ContainerRegistryTaskArchitecture(Amd64Value); + + /// Gets the X86. + public static ContainerRegistryTaskArchitecture X86 { get; } = new ContainerRegistryTaskArchitecture(X86Value); + + /// Gets the _386. + public static ContainerRegistryTaskArchitecture _386 { get; } = new ContainerRegistryTaskArchitecture(_386Value); + + /// Gets the Arm. + public static ContainerRegistryTaskArchitecture Arm { get; } = new ContainerRegistryTaskArchitecture(ArmValue); + + /// Gets the Arm64. + public static ContainerRegistryTaskArchitecture Arm64 { get; } = new ContainerRegistryTaskArchitecture(Arm64Value); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ContainerRegistryTaskArchitecture left, ContainerRegistryTaskArchitecture right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ContainerRegistryTaskArchitecture left, ContainerRegistryTaskArchitecture right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskArchitecture(string value) => new ContainerRegistryTaskArchitecture(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskArchitecture?(string value) => value == null ? null : new ContainerRegistryTaskArchitecture(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerRegistryTaskArchitecture other && Equals(other); + + /// + public bool Equals(ContainerRegistryTaskArchitecture other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskArgument.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskArgument.Serialization.cs new file mode 100644 index 000000000000..496ef860ba98 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskArgument.Serialization.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a run argument. + public partial class ContainerRegistryTaskArgument : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ContainerRegistryTaskArgument() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContainerRegistryTaskArgument PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeContainerRegistryTaskArgument(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ContainerRegistryTaskArgument)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(ContainerRegistryTaskArgument)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ContainerRegistryTaskArgument IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerRegistryTaskArgument)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + if (Optional.IsDefined(IsSecret)) + { + writer.WritePropertyName("isSecret"u8); + writer.WriteBooleanValue(IsSecret.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ContainerRegistryTaskArgument IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContainerRegistryTaskArgument JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerRegistryTaskArgument)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeContainerRegistryTaskArgument(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ContainerRegistryTaskArgument DeserializeContainerRegistryTaskArgument(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string value = default; + bool? isSecret = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("isSecret"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isSecret = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ContainerRegistryTaskArgument(name, value, isSecret, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskArgument.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskArgument.cs new file mode 100644 index 000000000000..891458c9e66b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskArgument.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a run argument. + public partial class ContainerRegistryTaskArgument + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the argument. + /// The value of the argument. + /// or is null. + public ContainerRegistryTaskArgument(string name, string value) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(value, nameof(value)); + + Name = name; + Value = value; + } + + /// Initializes a new instance of . + /// The name of the argument. + /// The value of the argument. + /// Flag to indicate whether the argument represents a secret and want to be removed from build logs. + /// Keeps track of any properties unknown to the library. + internal ContainerRegistryTaskArgument(string name, string value, bool? isSecret, IDictionary additionalBinaryDataProperties) + { + Name = name; + Value = value; + IsSecret = isSecret; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the argument. + public string Name { get; set; } + + /// The value of the argument. + public string Value { get; set; } + + /// Flag to indicate whether the argument represents a secret and want to be removed from build logs. + public bool? IsSecret { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskCredentials.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskCredentials.Serialization.cs new file mode 100644 index 000000000000..7283f9b21238 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskCredentials.Serialization.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters that describes a set of credentials that will be used when a run is invoked. + public partial class ContainerRegistryTaskCredentials : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContainerRegistryTaskCredentials PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeContainerRegistryTaskCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ContainerRegistryTaskCredentials)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(ContainerRegistryTaskCredentials)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ContainerRegistryTaskCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerRegistryTaskCredentials)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(SourceRegistry)) + { + writer.WritePropertyName("sourceRegistry"u8); + writer.WriteObjectValue(SourceRegistry, options); + } + if (Optional.IsCollectionDefined(CustomRegistries)) + { + writer.WritePropertyName("customRegistries"u8); + writer.WriteStartObject(); + foreach (var item in CustomRegistries) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ContainerRegistryTaskCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContainerRegistryTaskCredentials JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerRegistryTaskCredentials)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeContainerRegistryTaskCredentials(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ContainerRegistryTaskCredentials DeserializeContainerRegistryTaskCredentials(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SourceRegistryCredentials sourceRegistry = default; + IDictionary customRegistries = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("sourceRegistry"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceRegistry = SourceRegistryCredentials.DeserializeSourceRegistryCredentials(prop.Value, options); + continue; + } + if (prop.NameEquals("customRegistries"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, CustomRegistryCredentials.DeserializeCustomRegistryCredentials(prop0.Value, options)); + } + customRegistries = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ContainerRegistryTaskCredentials(sourceRegistry, customRegistries ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskCredentials.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskCredentials.cs new file mode 100644 index 000000000000..1b94116f7199 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskCredentials.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters that describes a set of credentials that will be used when a run is invoked. + public partial class ContainerRegistryTaskCredentials + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ContainerRegistryTaskCredentials() + { + CustomRegistries = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Describes the credential parameters for accessing the source registry. + /// + /// Describes the credential parameters for accessing other custom registries. The key + /// for the dictionary item will be the registry login server (myregistry.azurecr.io) and + /// the value of the item will be the registry credentials for accessing the registry. + /// + /// Keeps track of any properties unknown to the library. + internal ContainerRegistryTaskCredentials(SourceRegistryCredentials sourceRegistry, IDictionary customRegistries, IDictionary additionalBinaryDataProperties) + { + SourceRegistry = sourceRegistry; + CustomRegistries = customRegistries; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Describes the credential parameters for accessing the source registry. + public SourceRegistryCredentials SourceRegistry { get; set; } + + /// + /// Describes the credential parameters for accessing other custom registries. The key + /// for the dictionary item will be the registry login server (myregistry.azurecr.io) and + /// the value of the item will be the registry credentials for accessing the registry. + /// + public IDictionary CustomRegistries { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskOS.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskOS.cs new file mode 100644 index 000000000000..8c87fcbe112b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskOS.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The OS of agent machine. + public readonly partial struct ContainerRegistryTaskOS : IEquatable + { + private readonly string _value; + private const string WindowsValue = "Windows"; + private const string LinuxValue = "Linux"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ContainerRegistryTaskOS(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Windows. + public static ContainerRegistryTaskOS Windows { get; } = new ContainerRegistryTaskOS(WindowsValue); + + /// Gets the Linux. + public static ContainerRegistryTaskOS Linux { get; } = new ContainerRegistryTaskOS(LinuxValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ContainerRegistryTaskOS left, ContainerRegistryTaskOS right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ContainerRegistryTaskOS left, ContainerRegistryTaskOS right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskOS(string value) => new ContainerRegistryTaskOS(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskOS?(string value) => value == null ? null : new ContainerRegistryTaskOS(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerRegistryTaskOS other && Equals(other); + + /// + public bool Equals(ContainerRegistryTaskOS other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskProvisioningState.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskProvisioningState.cs new file mode 100644 index 000000000000..4e2009572816 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskProvisioningState.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The provisioning state of this agent pool. + public readonly partial struct ContainerRegistryTaskProvisioningState : IEquatable + { + private readonly string _value; + private const string CreatingValue = "Creating"; + private const string UpdatingValue = "Updating"; + private const string DeletingValue = "Deleting"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ContainerRegistryTaskProvisioningState(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Creating. + public static ContainerRegistryTaskProvisioningState Creating { get; } = new ContainerRegistryTaskProvisioningState(CreatingValue); + + /// Gets the Updating. + public static ContainerRegistryTaskProvisioningState Updating { get; } = new ContainerRegistryTaskProvisioningState(UpdatingValue); + + /// Gets the Deleting. + public static ContainerRegistryTaskProvisioningState Deleting { get; } = new ContainerRegistryTaskProvisioningState(DeletingValue); + + /// Gets the Succeeded. + public static ContainerRegistryTaskProvisioningState Succeeded { get; } = new ContainerRegistryTaskProvisioningState(SucceededValue); + + /// Gets the Failed. + public static ContainerRegistryTaskProvisioningState Failed { get; } = new ContainerRegistryTaskProvisioningState(FailedValue); + + /// Gets the Canceled. + public static ContainerRegistryTaskProvisioningState Canceled { get; } = new ContainerRegistryTaskProvisioningState(CanceledValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ContainerRegistryTaskProvisioningState left, ContainerRegistryTaskProvisioningState right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ContainerRegistryTaskProvisioningState left, ContainerRegistryTaskProvisioningState right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskProvisioningState(string value) => new ContainerRegistryTaskProvisioningState(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskProvisioningState?(string value) => value == null ? null : new ContainerRegistryTaskProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerRegistryTaskProvisioningState other && Equals(other); + + /// + public bool Equals(ContainerRegistryTaskProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskRunStatus.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskRunStatus.cs new file mode 100644 index 000000000000..8559997f6f3e --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskRunStatus.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The current status of the run. + public readonly partial struct ContainerRegistryTaskRunStatus : IEquatable + { + private readonly string _value; + private const string QueuedValue = "Queued"; + private const string StartedValue = "Started"; + private const string RunningValue = "Running"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + private const string ErrorValue = "Error"; + private const string TimeoutValue = "Timeout"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ContainerRegistryTaskRunStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Queued. + public static ContainerRegistryTaskRunStatus Queued { get; } = new ContainerRegistryTaskRunStatus(QueuedValue); + + /// Gets the Started. + public static ContainerRegistryTaskRunStatus Started { get; } = new ContainerRegistryTaskRunStatus(StartedValue); + + /// Gets the Running. + public static ContainerRegistryTaskRunStatus Running { get; } = new ContainerRegistryTaskRunStatus(RunningValue); + + /// Gets the Succeeded. + public static ContainerRegistryTaskRunStatus Succeeded { get; } = new ContainerRegistryTaskRunStatus(SucceededValue); + + /// Gets the Failed. + public static ContainerRegistryTaskRunStatus Failed { get; } = new ContainerRegistryTaskRunStatus(FailedValue); + + /// Gets the Canceled. + public static ContainerRegistryTaskRunStatus Canceled { get; } = new ContainerRegistryTaskRunStatus(CanceledValue); + + /// Gets the Error. + public static ContainerRegistryTaskRunStatus Error { get; } = new ContainerRegistryTaskRunStatus(ErrorValue); + + /// Gets the Timeout. + public static ContainerRegistryTaskRunStatus Timeout { get; } = new ContainerRegistryTaskRunStatus(TimeoutValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ContainerRegistryTaskRunStatus left, ContainerRegistryTaskRunStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ContainerRegistryTaskRunStatus left, ContainerRegistryTaskRunStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskRunStatus(string value) => new ContainerRegistryTaskRunStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskRunStatus?(string value) => value == null ? null : new ContainerRegistryTaskRunStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerRegistryTaskRunStatus other && Equals(other); + + /// + public bool Equals(ContainerRegistryTaskRunStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskRunType.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskRunType.cs new file mode 100644 index 000000000000..dcfac6c90d13 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskRunType.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The type of run. + public readonly partial struct ContainerRegistryTaskRunType : IEquatable + { + private readonly string _value; + private const string QuickBuildValue = "QuickBuild"; + private const string QuickRunValue = "QuickRun"; + private const string AutoBuildValue = "AutoBuild"; + private const string AutoRunValue = "AutoRun"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ContainerRegistryTaskRunType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the QuickBuild. + public static ContainerRegistryTaskRunType QuickBuild { get; } = new ContainerRegistryTaskRunType(QuickBuildValue); + + /// Gets the QuickRun. + public static ContainerRegistryTaskRunType QuickRun { get; } = new ContainerRegistryTaskRunType(QuickRunValue); + + /// Gets the AutoBuild. + public static ContainerRegistryTaskRunType AutoBuild { get; } = new ContainerRegistryTaskRunType(AutoBuildValue); + + /// Gets the AutoRun. + public static ContainerRegistryTaskRunType AutoRun { get; } = new ContainerRegistryTaskRunType(AutoRunValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ContainerRegistryTaskRunType left, ContainerRegistryTaskRunType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ContainerRegistryTaskRunType left, ContainerRegistryTaskRunType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskRunType(string value) => new ContainerRegistryTaskRunType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskRunType?(string value) => value == null ? null : new ContainerRegistryTaskRunType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerRegistryTaskRunType other && Equals(other); + + /// + public bool Equals(ContainerRegistryTaskRunType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSecretObject.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSecretObject.Serialization.cs new file mode 100644 index 000000000000..2806c5270887 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSecretObject.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Describes the properties of a secret object value. + public partial class ContainerRegistryTaskSecretObject : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContainerRegistryTaskSecretObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeContainerRegistryTaskSecretObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ContainerRegistryTaskSecretObject)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(ContainerRegistryTaskSecretObject)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ContainerRegistryTaskSecretObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerRegistryTaskSecretObject)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ContainerRegistryTaskSecretObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContainerRegistryTaskSecretObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerRegistryTaskSecretObject)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeContainerRegistryTaskSecretObject(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ContainerRegistryTaskSecretObject DeserializeContainerRegistryTaskSecretObject(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + ContainerRegistryTaskSecretObjectType? @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + value = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @type = new ContainerRegistryTaskSecretObjectType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ContainerRegistryTaskSecretObject(value, @type, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSecretObject.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSecretObject.cs new file mode 100644 index 000000000000..73b1a8ca450f --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSecretObject.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Describes the properties of a secret object value. + public partial class ContainerRegistryTaskSecretObject + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ContainerRegistryTaskSecretObject() + { + } + + /// Initializes a new instance of . + /// + /// The value of the secret. The format of this value will be determined + /// based on the type of the secret object. If the type is Opaque, the value will be + /// used as is without any modification. + /// + /// + /// The type of the secret object which determines how the value of the secret object has to be + /// interpreted. + /// + /// Keeps track of any properties unknown to the library. + internal ContainerRegistryTaskSecretObject(string value, ContainerRegistryTaskSecretObjectType? @type, IDictionary additionalBinaryDataProperties) + { + Value = value; + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The value of the secret. The format of this value will be determined + /// based on the type of the secret object. If the type is Opaque, the value will be + /// used as is without any modification. + /// + public string Value { get; set; } + + /// + /// The type of the secret object which determines how the value of the secret object has to be + /// interpreted. + /// + public ContainerRegistryTaskSecretObjectType? Type { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSecretObjectType.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSecretObjectType.cs new file mode 100644 index 000000000000..37876d0a4823 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSecretObjectType.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// + /// The type of the secret object which determines how the value of the secret object has to be + /// interpreted. + /// + public readonly partial struct ContainerRegistryTaskSecretObjectType : IEquatable + { + private readonly string _value; + private const string OpaqueValue = "Opaque"; + private const string VaultSecretValue = "Vaultsecret"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ContainerRegistryTaskSecretObjectType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Opaque. + public static ContainerRegistryTaskSecretObjectType Opaque { get; } = new ContainerRegistryTaskSecretObjectType(OpaqueValue); + + /// Gets the VaultSecret. + public static ContainerRegistryTaskSecretObjectType VaultSecret { get; } = new ContainerRegistryTaskSecretObjectType(VaultSecretValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ContainerRegistryTaskSecretObjectType left, ContainerRegistryTaskSecretObjectType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ContainerRegistryTaskSecretObjectType left, ContainerRegistryTaskSecretObjectType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskSecretObjectType(string value) => new ContainerRegistryTaskSecretObjectType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskSecretObjectType?(string value) => value == null ? null : new ContainerRegistryTaskSecretObjectType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerRegistryTaskSecretObjectType other && Equals(other); + + /// + public bool Equals(ContainerRegistryTaskSecretObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSetValue.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSetValue.Serialization.cs new file mode 100644 index 000000000000..6d1a1f05420b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSetValue.Serialization.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a overridable value that can be passed to a task template. + public partial class ContainerRegistryTaskSetValue : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ContainerRegistryTaskSetValue() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContainerRegistryTaskSetValue PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeContainerRegistryTaskSetValue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ContainerRegistryTaskSetValue)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(ContainerRegistryTaskSetValue)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ContainerRegistryTaskSetValue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerRegistryTaskSetValue)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + if (Optional.IsDefined(IsSecret)) + { + writer.WritePropertyName("isSecret"u8); + writer.WriteBooleanValue(IsSecret.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ContainerRegistryTaskSetValue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContainerRegistryTaskSetValue JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerRegistryTaskSetValue)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeContainerRegistryTaskSetValue(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ContainerRegistryTaskSetValue DeserializeContainerRegistryTaskSetValue(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string value = default; + bool? isSecret = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("isSecret"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isSecret = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ContainerRegistryTaskSetValue(name, value, isSecret, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSetValue.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSetValue.cs new file mode 100644 index 000000000000..c8f09341c634 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskSetValue.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a overridable value that can be passed to a task template. + public partial class ContainerRegistryTaskSetValue + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the overridable value. + /// The overridable value. + /// or is null. + public ContainerRegistryTaskSetValue(string name, string value) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(value, nameof(value)); + + Name = name; + Value = value; + } + + /// Initializes a new instance of . + /// The name of the overridable value. + /// The overridable value. + /// Flag to indicate whether the value represents a secret or not. + /// Keeps track of any properties unknown to the library. + internal ContainerRegistryTaskSetValue(string name, string value, bool? isSecret, IDictionary additionalBinaryDataProperties) + { + Name = name; + Value = value; + IsSecret = isSecret; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the overridable value. + public string Name { get; set; } + + /// The overridable value. + public string Value { get; set; } + + /// Flag to indicate whether the value represents a secret or not. + public bool? IsSecret { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskStatus.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskStatus.cs new file mode 100644 index 000000000000..2509eec6343a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskStatus.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The current status of task. + public readonly partial struct ContainerRegistryTaskStatus : IEquatable + { + private readonly string _value; + private const string DisabledValue = "Disabled"; + private const string EnabledValue = "Enabled"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ContainerRegistryTaskStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Disabled. + public static ContainerRegistryTaskStatus Disabled { get; } = new ContainerRegistryTaskStatus(DisabledValue); + + /// Gets the Enabled. + public static ContainerRegistryTaskStatus Enabled { get; } = new ContainerRegistryTaskStatus(EnabledValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ContainerRegistryTaskStatus left, ContainerRegistryTaskStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ContainerRegistryTaskStatus left, ContainerRegistryTaskStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskStatus(string value) => new ContainerRegistryTaskStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskStatus?(string value) => value == null ? null : new ContainerRegistryTaskStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerRegistryTaskStatus other && Equals(other); + + /// + public bool Equals(ContainerRegistryTaskStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskTokenType.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskTokenType.cs new file mode 100644 index 000000000000..a905d2e61905 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskTokenType.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The type of Auth token. + public readonly partial struct ContainerRegistryTaskTokenType : IEquatable + { + private readonly string _value; + private const string PATValue = "PAT"; + private const string OAuthValue = "OAuth"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ContainerRegistryTaskTokenType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the PAT. + public static ContainerRegistryTaskTokenType PAT { get; } = new ContainerRegistryTaskTokenType(PATValue); + + /// Gets the OAuth. + public static ContainerRegistryTaskTokenType OAuth { get; } = new ContainerRegistryTaskTokenType(OAuthValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ContainerRegistryTaskTokenType left, ContainerRegistryTaskTokenType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ContainerRegistryTaskTokenType left, ContainerRegistryTaskTokenType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskTokenType(string value) => new ContainerRegistryTaskTokenType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskTokenType?(string value) => value == null ? null : new ContainerRegistryTaskTokenType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerRegistryTaskTokenType other && Equals(other); + + /// + public bool Equals(ContainerRegistryTaskTokenType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskTriggerStatus.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskTriggerStatus.cs new file mode 100644 index 000000000000..bdce66e12263 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskTriggerStatus.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The current status of trigger. + public readonly partial struct ContainerRegistryTaskTriggerStatus : IEquatable + { + private readonly string _value; + private const string DisabledValue = "Disabled"; + private const string EnabledValue = "Enabled"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ContainerRegistryTaskTriggerStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Disabled. + public static ContainerRegistryTaskTriggerStatus Disabled { get; } = new ContainerRegistryTaskTriggerStatus(DisabledValue); + + /// Gets the Enabled. + public static ContainerRegistryTaskTriggerStatus Enabled { get; } = new ContainerRegistryTaskTriggerStatus(EnabledValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ContainerRegistryTaskTriggerStatus left, ContainerRegistryTaskTriggerStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ContainerRegistryTaskTriggerStatus left, ContainerRegistryTaskTriggerStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskTriggerStatus(string value) => new ContainerRegistryTaskTriggerStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskTriggerStatus?(string value) => value == null ? null : new ContainerRegistryTaskTriggerStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerRegistryTaskTriggerStatus other && Equals(other); + + /// + public bool Equals(ContainerRegistryTaskTriggerStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskVariant.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskVariant.cs new file mode 100644 index 000000000000..520cef4d3e46 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ContainerRegistryTaskVariant.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Variant of the CPU. + public readonly partial struct ContainerRegistryTaskVariant : IEquatable + { + private readonly string _value; + private const string V6Value = "v6"; + private const string V7Value = "v7"; + private const string V8Value = "v8"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ContainerRegistryTaskVariant(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the V6. + public static ContainerRegistryTaskVariant V6 { get; } = new ContainerRegistryTaskVariant(V6Value); + + /// Gets the V7. + public static ContainerRegistryTaskVariant V7 { get; } = new ContainerRegistryTaskVariant(V7Value); + + /// Gets the V8. + public static ContainerRegistryTaskVariant V8 { get; } = new ContainerRegistryTaskVariant(V8Value); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ContainerRegistryTaskVariant left, ContainerRegistryTaskVariant right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ContainerRegistryTaskVariant left, ContainerRegistryTaskVariant right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskVariant(string value) => new ContainerRegistryTaskVariant(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ContainerRegistryTaskVariant?(string value) => value == null ? null : new ContainerRegistryTaskVariant(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerRegistryTaskVariant other && Equals(other); + + /// + public bool Equals(ContainerRegistryTaskVariant other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/CustomRegistryCredentials.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/CustomRegistryCredentials.Serialization.cs new file mode 100644 index 000000000000..5d97cccf1a6a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/CustomRegistryCredentials.Serialization.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Describes the credentials that will be used to access a custom registry during a run. + public partial class CustomRegistryCredentials : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual CustomRegistryCredentials PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeCustomRegistryCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CustomRegistryCredentials)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(CustomRegistryCredentials)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + CustomRegistryCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CustomRegistryCredentials)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(UserName)) + { + writer.WritePropertyName("userName"u8); + writer.WriteObjectValue(UserName, options); + } + if (Optional.IsDefined(Password)) + { + writer.WritePropertyName("password"u8); + writer.WriteObjectValue(Password, options); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + writer.WriteStringValue(Identity); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + CustomRegistryCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual CustomRegistryCredentials JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CustomRegistryCredentials)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCustomRegistryCredentials(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CustomRegistryCredentials DeserializeCustomRegistryCredentials(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ContainerRegistryTaskSecretObject userName = default; + ContainerRegistryTaskSecretObject password = default; + string identity = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("userName"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userName = ContainerRegistryTaskSecretObject.DeserializeContainerRegistryTaskSecretObject(prop.Value, options); + continue; + } + if (prop.NameEquals("password"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + password = ContainerRegistryTaskSecretObject.DeserializeContainerRegistryTaskSecretObject(prop.Value, options); + continue; + } + if (prop.NameEquals("identity"u8)) + { + identity = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new CustomRegistryCredentials(userName, password, identity, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/CustomRegistryCredentials.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/CustomRegistryCredentials.cs new file mode 100644 index 000000000000..f786ce549593 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/CustomRegistryCredentials.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Describes the credentials that will be used to access a custom registry during a run. + public partial class CustomRegistryCredentials + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public CustomRegistryCredentials() + { + } + + /// Initializes a new instance of . + /// The username for logging into the custom registry. + /// + /// The password for logging into the custom registry. The password is a secret + /// object that allows multiple ways of providing the value for it. + /// + /// + /// Indicates the managed identity assigned to the custom credential. If a user-assigned identity + /// this value is the Client ID. If a system-assigned identity, the value will be `system`. In + /// the case of a system-assigned identity, the Client ID will be determined by the runner. This + /// identity may be used to authenticate to key vault to retrieve credentials or it may be the only + /// source of authentication used for accessing the registry. + /// + /// Keeps track of any properties unknown to the library. + internal CustomRegistryCredentials(ContainerRegistryTaskSecretObject userName, ContainerRegistryTaskSecretObject password, string identity, IDictionary additionalBinaryDataProperties) + { + UserName = userName; + Password = password; + Identity = identity; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The username for logging into the custom registry. + public ContainerRegistryTaskSecretObject UserName { get; set; } + + /// + /// The password for logging into the custom registry. The password is a secret + /// object that allows multiple ways of providing the value for it. + /// + public ContainerRegistryTaskSecretObject Password { get; set; } + + /// + /// Indicates the managed identity assigned to the custom credential. If a user-assigned identity + /// this value is the Client ID. If a system-assigned identity, the value will be `system`. In + /// the case of a system-assigned identity, the Client ID will be determined by the runner. This + /// identity may be used to authenticate to key vault to retrieve credentials or it may be the only + /// source of authentication used for accessing the registry. + /// + public string Identity { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildContent.Serialization.cs new file mode 100644 index 000000000000..5242ac4189d9 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildContent.Serialization.cs @@ -0,0 +1,340 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for a docker quick build. + public partial class DockerBuildContent : RunContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal DockerBuildContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override RunContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDockerBuildContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DockerBuildContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(DockerBuildContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + DockerBuildContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DockerBuildContent)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DockerBuildContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(ImageNames)) + { + writer.WritePropertyName("imageNames"u8); + writer.WriteStartArray(); + foreach (string item in ImageNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(IsPushEnabled)) + { + writer.WritePropertyName("isPushEnabled"u8); + writer.WriteBooleanValue(IsPushEnabled.Value); + } + if (Optional.IsDefined(IsCacheDisabled)) + { + writer.WritePropertyName("noCache"u8); + writer.WriteBooleanValue(IsCacheDisabled.Value); + } + writer.WritePropertyName("dockerFilePath"u8); + writer.WriteStringValue(DockerFilePath); + if (Optional.IsDefined(Target)) + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + if (Optional.IsCollectionDefined(Arguments)) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskArgument item in Arguments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(TimeoutInSeconds)) + { + writer.WritePropertyName("timeout"u8); + writer.WriteNumberValue(TimeoutInSeconds.Value); + } + writer.WritePropertyName("platform"u8); + writer.WriteObjectValue(Platform, options); + if (Optional.IsDefined(AgentConfiguration)) + { + writer.WritePropertyName("agentConfiguration"u8); + writer.WriteObjectValue(AgentConfiguration, options); + } + if (Optional.IsDefined(SourceLocation)) + { + writer.WritePropertyName("sourceLocation"u8); + writer.WriteStringValue(SourceLocation); + } + if (Optional.IsDefined(Credentials)) + { + writer.WritePropertyName("credentials"u8); + writer.WriteObjectValue(Credentials, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + DockerBuildContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DockerBuildContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override RunContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DockerBuildContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDockerBuildContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DockerBuildContent DeserializeDockerBuildContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "DockerBuildRequest"; + bool? isArchiveEnabled = default; + string agentPoolName = default; + string logTemplate = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList imageNames = default; + bool? isPushEnabled = default; + bool? isCacheDisabled = default; + string dockerFilePath = default; + string target = default; + IList arguments = default; + int? timeoutInSeconds = default; + PlatformProperties platform = default; + AgentProperties agentConfiguration = default; + string sourceLocation = default; + ContainerRegistryTaskCredentials credentials = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("isArchiveEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isArchiveEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("agentPoolName"u8)) + { + agentPoolName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logTemplate"u8)) + { + logTemplate = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("imageNames"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + imageNames = array; + continue; + } + if (prop.NameEquals("isPushEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isPushEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("noCache"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isCacheDisabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("dockerFilePath"u8)) + { + dockerFilePath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("target"u8)) + { + target = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskArgument.DeserializeContainerRegistryTaskArgument(item, options)); + } + arguments = array; + continue; + } + if (prop.NameEquals("timeout"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeoutInSeconds = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("platform"u8)) + { + platform = PlatformProperties.DeserializePlatformProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("agentConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentConfiguration = AgentProperties.DeserializeAgentProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("sourceLocation"u8)) + { + sourceLocation = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("credentials"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + credentials = ContainerRegistryTaskCredentials.DeserializeContainerRegistryTaskCredentials(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DockerBuildContent( + @type, + isArchiveEnabled, + agentPoolName, + logTemplate, + additionalBinaryDataProperties, + imageNames ?? new ChangeTrackingList(), + isPushEnabled, + isCacheDisabled, + dockerFilePath, + target, + arguments ?? new ChangeTrackingList(), + timeoutInSeconds, + platform, + agentConfiguration, + sourceLocation, + credentials); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildContent.cs new file mode 100644 index 000000000000..02edc26e3d83 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildContent.cs @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for a docker quick build. + public partial class DockerBuildContent : RunContent + { + /// Initializes a new instance of . + /// The Docker file path relative to the source location. + /// The platform properties against which the run has to happen. + /// or is null. + public DockerBuildContent(string dockerFilePath, PlatformProperties platform) : base("DockerBuildRequest") + { + Argument.AssertNotNull(dockerFilePath, nameof(dockerFilePath)); + Argument.AssertNotNull(platform, nameof(platform)); + + ImageNames = new ChangeTrackingList(); + DockerFilePath = dockerFilePath; + Arguments = new ChangeTrackingList(); + Platform = platform; + } + + /// Initializes a new instance of . + /// The type of the run request. + /// The value that indicates whether archiving is enabled for the run or not. + /// The dedicated agent pool for the run. + /// The template that describes the repository and tag information for run log artifact. + /// Keeps track of any properties unknown to the library. + /// The fully qualified image names including the repository and tag. + /// The value of this property indicates whether the image built should be pushed to the registry or not. + /// The value of this property indicates whether the image cache is enabled or not. + /// The Docker file path relative to the source location. + /// The name of the target build stage for the docker build. + /// The collection of override arguments to be used when executing the run. + /// Run timeout in seconds. + /// The platform properties against which the run has to happen. + /// The machine configuration of the run agent. + /// + /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. + /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. + /// + /// The properties that describes a set of credentials that will be used when this run is invoked. + internal DockerBuildContent(string @type, bool? isArchiveEnabled, string agentPoolName, string logTemplate, IDictionary additionalBinaryDataProperties, IList imageNames, bool? isPushEnabled, bool? isCacheDisabled, string dockerFilePath, string target, IList arguments, int? timeoutInSeconds, PlatformProperties platform, AgentProperties agentConfiguration, string sourceLocation, ContainerRegistryTaskCredentials credentials) : base(@type, isArchiveEnabled, agentPoolName, logTemplate, additionalBinaryDataProperties) + { + ImageNames = imageNames; + IsPushEnabled = isPushEnabled; + IsCacheDisabled = isCacheDisabled; + DockerFilePath = dockerFilePath; + Target = target; + Arguments = arguments; + TimeoutInSeconds = timeoutInSeconds; + Platform = platform; + AgentConfiguration = agentConfiguration; + SourceLocation = sourceLocation; + Credentials = credentials; + } + + /// The fully qualified image names including the repository and tag. + public IList ImageNames { get; } + + /// The value of this property indicates whether the image built should be pushed to the registry or not. + public bool? IsPushEnabled { get; set; } + + /// The value of this property indicates whether the image cache is enabled or not. + public bool? IsCacheDisabled { get; set; } + + /// The Docker file path relative to the source location. + public string DockerFilePath { get; set; } + + /// The name of the target build stage for the docker build. + public string Target { get; set; } + + /// The collection of override arguments to be used when executing the run. + public IList Arguments { get; } + + /// Run timeout in seconds. + public int? TimeoutInSeconds { get; set; } + + /// The platform properties against which the run has to happen. + public PlatformProperties Platform { get; set; } + + /// The machine configuration of the run agent. + internal AgentProperties AgentConfiguration { get; set; } + + /// + /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. + /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. + /// + public string SourceLocation { get; set; } + + /// The properties that describes a set of credentials that will be used when this run is invoked. + public ContainerRegistryTaskCredentials Credentials { get; set; } + + /// The CPU configuration in terms of number of cores required for the run. + public int? AgentCpu + { + get + { + return AgentConfiguration is null ? default : AgentConfiguration.Cpu; + } + set + { + if (AgentConfiguration is null) + { + AgentConfiguration = new AgentProperties(); + } + AgentConfiguration.Cpu = value; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStep.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStep.Serialization.cs new file mode 100644 index 000000000000..0203573832b6 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStep.Serialization.cs @@ -0,0 +1,276 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The Docker build step. + public partial class DockerBuildStep : TaskStepProperties, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal DockerBuildStep() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override TaskStepProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDockerBuildStep(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DockerBuildStep)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(DockerBuildStep)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + DockerBuildStep IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DockerBuildStep)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DockerBuildStep)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(ImageNames)) + { + writer.WritePropertyName("imageNames"u8); + writer.WriteStartArray(); + foreach (string item in ImageNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(IsPushEnabled)) + { + writer.WritePropertyName("isPushEnabled"u8); + writer.WriteBooleanValue(IsPushEnabled.Value); + } + if (Optional.IsDefined(IsCacheDisabled)) + { + writer.WritePropertyName("noCache"u8); + writer.WriteBooleanValue(IsCacheDisabled.Value); + } + writer.WritePropertyName("dockerFilePath"u8); + writer.WriteStringValue(DockerFilePath); + if (Optional.IsDefined(Target)) + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + if (Optional.IsCollectionDefined(Arguments)) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskArgument item in Arguments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + DockerBuildStep IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DockerBuildStep)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TaskStepProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DockerBuildStep)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDockerBuildStep(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DockerBuildStep DeserializeDockerBuildStep(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StepType @type = default; + IReadOnlyList baseImageDependencies = default; + string contextPath = default; + string contextAccessToken = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList imageNames = default; + bool? isPushEnabled = default; + bool? isCacheDisabled = default; + string dockerFilePath = default; + string target = default; + IList arguments = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new StepType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("baseImageDependencies"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(BaseImageDependency.DeserializeBaseImageDependency(item, options)); + } + baseImageDependencies = array; + continue; + } + if (prop.NameEquals("contextPath"u8)) + { + contextPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("contextAccessToken"u8)) + { + contextAccessToken = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("imageNames"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + imageNames = array; + continue; + } + if (prop.NameEquals("isPushEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isPushEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("noCache"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isCacheDisabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("dockerFilePath"u8)) + { + dockerFilePath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("target"u8)) + { + target = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskArgument.DeserializeContainerRegistryTaskArgument(item, options)); + } + arguments = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DockerBuildStep( + @type, + baseImageDependencies ?? new ChangeTrackingList(), + contextPath, + contextAccessToken, + additionalBinaryDataProperties, + imageNames ?? new ChangeTrackingList(), + isPushEnabled, + isCacheDisabled, + dockerFilePath, + target, + arguments ?? new ChangeTrackingList()); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStep.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStep.cs new file mode 100644 index 000000000000..81e9978624e4 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStep.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The Docker build step. + public partial class DockerBuildStep : TaskStepProperties + { + /// Initializes a new instance of . + /// The Docker file path relative to the source context. + /// is null. + public DockerBuildStep(string dockerFilePath) : base(StepType.Docker) + { + Argument.AssertNotNull(dockerFilePath, nameof(dockerFilePath)); + + ImageNames = new ChangeTrackingList(); + DockerFilePath = dockerFilePath; + Arguments = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The type of the step. + /// List of base image dependencies for a step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Keeps track of any properties unknown to the library. + /// The fully qualified image names including the repository and tag. + /// The value of this property indicates whether the image built should be pushed to the registry or not. + /// The value of this property indicates whether the image cache is enabled or not. + /// The Docker file path relative to the source context. + /// The name of the target build stage for the docker build. + /// The collection of override arguments to be used when executing this build step. + internal DockerBuildStep(StepType @type, IReadOnlyList baseImageDependencies, string contextPath, string contextAccessToken, IDictionary additionalBinaryDataProperties, IList imageNames, bool? isPushEnabled, bool? isCacheDisabled, string dockerFilePath, string target, IList arguments) : base(@type, baseImageDependencies, contextPath, contextAccessToken, additionalBinaryDataProperties) + { + ImageNames = imageNames; + IsPushEnabled = isPushEnabled; + IsCacheDisabled = isCacheDisabled; + DockerFilePath = dockerFilePath; + Target = target; + Arguments = arguments; + } + + /// The fully qualified image names including the repository and tag. + public IList ImageNames { get; } + + /// The value of this property indicates whether the image built should be pushed to the registry or not. + public bool? IsPushEnabled { get; set; } + + /// The value of this property indicates whether the image cache is enabled or not. + public bool? IsCacheDisabled { get; set; } + + /// The Docker file path relative to the source context. + public string DockerFilePath { get; set; } + + /// The name of the target build stage for the docker build. + public string Target { get; set; } + + /// The collection of override arguments to be used when executing this build step. + public IList Arguments { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStepUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStepUpdateContent.Serialization.cs new file mode 100644 index 000000000000..cf3500c9e2d5 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStepUpdateContent.Serialization.cs @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating a docker build step. + public partial class DockerBuildStepUpdateContent : TaskStepUpdateContent, IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected override TaskStepUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDockerBuildStepUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DockerBuildStepUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(DockerBuildStepUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + DockerBuildStepUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DockerBuildStepUpdateContent)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DockerBuildStepUpdateContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(ImageNames)) + { + writer.WritePropertyName("imageNames"u8); + writer.WriteStartArray(); + foreach (string item in ImageNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(IsPushEnabled)) + { + writer.WritePropertyName("isPushEnabled"u8); + writer.WriteBooleanValue(IsPushEnabled.Value); + } + if (Optional.IsDefined(IsCacheDisabled)) + { + writer.WritePropertyName("noCache"u8); + writer.WriteBooleanValue(IsCacheDisabled.Value); + } + if (Optional.IsDefined(DockerFilePath)) + { + writer.WritePropertyName("dockerFilePath"u8); + writer.WriteStringValue(DockerFilePath); + } + if (Optional.IsCollectionDefined(Arguments)) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskArgument item in Arguments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Target)) + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + DockerBuildStepUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DockerBuildStepUpdateContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TaskStepUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DockerBuildStepUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDockerBuildStepUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DockerBuildStepUpdateContent DeserializeDockerBuildStepUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StepType @type = default; + string contextPath = default; + string contextAccessToken = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList imageNames = default; + bool? isPushEnabled = default; + bool? isCacheDisabled = default; + string dockerFilePath = default; + IList arguments = default; + string target = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new StepType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("contextPath"u8)) + { + contextPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("contextAccessToken"u8)) + { + contextAccessToken = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("imageNames"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + imageNames = array; + continue; + } + if (prop.NameEquals("isPushEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isPushEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("noCache"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isCacheDisabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("dockerFilePath"u8)) + { + dockerFilePath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskArgument.DeserializeContainerRegistryTaskArgument(item, options)); + } + arguments = array; + continue; + } + if (prop.NameEquals("target"u8)) + { + target = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DockerBuildStepUpdateContent( + @type, + contextPath, + contextAccessToken, + additionalBinaryDataProperties, + imageNames ?? new ChangeTrackingList(), + isPushEnabled, + isCacheDisabled, + dockerFilePath, + arguments ?? new ChangeTrackingList(), + target); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStepUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStepUpdateContent.cs new file mode 100644 index 000000000000..b6b2662aa322 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/DockerBuildStepUpdateContent.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating a docker build step. + public partial class DockerBuildStepUpdateContent : TaskStepUpdateContent + { + /// Initializes a new instance of . + public DockerBuildStepUpdateContent() : base(StepType.Docker) + { + ImageNames = new ChangeTrackingList(); + Arguments = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The type of the step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Keeps track of any properties unknown to the library. + /// The fully qualified image names including the repository and tag. + /// The value of this property indicates whether the image built should be pushed to the registry or not. + /// The value of this property indicates whether the image cache is enabled or not. + /// The Docker file path relative to the source context. + /// The collection of override arguments to be used when executing this build step. + /// The name of the target build stage for the docker build. + internal DockerBuildStepUpdateContent(StepType @type, string contextPath, string contextAccessToken, IDictionary additionalBinaryDataProperties, IList imageNames, bool? isPushEnabled, bool? isCacheDisabled, string dockerFilePath, IList arguments, string target) : base(@type, contextPath, contextAccessToken, additionalBinaryDataProperties) + { + ImageNames = imageNames; + IsPushEnabled = isPushEnabled; + IsCacheDisabled = isCacheDisabled; + DockerFilePath = dockerFilePath; + Arguments = arguments; + Target = target; + } + + /// The fully qualified image names including the repository and tag. + public IList ImageNames { get; } + + /// The value of this property indicates whether the image built should be pushed to the registry or not. + public bool? IsPushEnabled { get; set; } + + /// The value of this property indicates whether the image cache is enabled or not. + public bool? IsCacheDisabled { get; set; } + + /// The Docker file path relative to the source context. + public string DockerFilePath { get; set; } + + /// The collection of override arguments to be used when executing this build step. + public IList Arguments { get; } + + /// The name of the target build stage for the docker build. + public string Target { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskRunContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskRunContent.Serialization.cs new file mode 100644 index 000000000000..7e314a1e6e07 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskRunContent.Serialization.cs @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for a quick task run request. + public partial class EncodedTaskRunContent : RunContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EncodedTaskRunContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override RunContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEncodedTaskRunContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EncodedTaskRunContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(EncodedTaskRunContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + EncodedTaskRunContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EncodedTaskRunContent)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EncodedTaskRunContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("encodedTaskContent"u8); + writer.WriteStringValue(EncodedTaskContent); + if (Optional.IsDefined(EncodedValuesContent)) + { + writer.WritePropertyName("encodedValuesContent"u8); + writer.WriteStringValue(EncodedValuesContent); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskSetValue item in Values) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(TimeoutInSeconds)) + { + writer.WritePropertyName("timeout"u8); + writer.WriteNumberValue(TimeoutInSeconds.Value); + } + writer.WritePropertyName("platform"u8); + writer.WriteObjectValue(Platform, options); + if (Optional.IsDefined(AgentConfiguration)) + { + writer.WritePropertyName("agentConfiguration"u8); + writer.WriteObjectValue(AgentConfiguration, options); + } + if (Optional.IsDefined(SourceLocation)) + { + writer.WritePropertyName("sourceLocation"u8); + writer.WriteStringValue(SourceLocation); + } + if (Optional.IsDefined(Credentials)) + { + writer.WritePropertyName("credentials"u8); + writer.WriteObjectValue(Credentials, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EncodedTaskRunContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EncodedTaskRunContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override RunContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EncodedTaskRunContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEncodedTaskRunContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EncodedTaskRunContent DeserializeEncodedTaskRunContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "EncodedTaskRunRequest"; + bool? isArchiveEnabled = default; + string agentPoolName = default; + string logTemplate = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string encodedTaskContent = default; + string encodedValuesContent = default; + IList values = default; + int? timeoutInSeconds = default; + PlatformProperties platform = default; + AgentProperties agentConfiguration = default; + string sourceLocation = default; + ContainerRegistryTaskCredentials credentials = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("isArchiveEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isArchiveEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("agentPoolName"u8)) + { + agentPoolName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logTemplate"u8)) + { + logTemplate = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("encodedTaskContent"u8)) + { + encodedTaskContent = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("encodedValuesContent"u8)) + { + encodedValuesContent = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("values"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskSetValue.DeserializeContainerRegistryTaskSetValue(item, options)); + } + values = array; + continue; + } + if (prop.NameEquals("timeout"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeoutInSeconds = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("platform"u8)) + { + platform = PlatformProperties.DeserializePlatformProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("agentConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentConfiguration = AgentProperties.DeserializeAgentProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("sourceLocation"u8)) + { + sourceLocation = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("credentials"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + credentials = ContainerRegistryTaskCredentials.DeserializeContainerRegistryTaskCredentials(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EncodedTaskRunContent( + @type, + isArchiveEnabled, + agentPoolName, + logTemplate, + additionalBinaryDataProperties, + encodedTaskContent, + encodedValuesContent, + values ?? new ChangeTrackingList(), + timeoutInSeconds, + platform, + agentConfiguration, + sourceLocation, + credentials); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskRunContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskRunContent.cs new file mode 100644 index 000000000000..19de86a3bdf0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskRunContent.cs @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for a quick task run request. + public partial class EncodedTaskRunContent : RunContent + { + /// Initializes a new instance of . + /// Base64 encoded value of the template/definition file content. + /// The platform properties against which the run has to happen. + /// or is null. + public EncodedTaskRunContent(string encodedTaskContent, PlatformProperties platform) : base("EncodedTaskRunRequest") + { + Argument.AssertNotNull(encodedTaskContent, nameof(encodedTaskContent)); + Argument.AssertNotNull(platform, nameof(platform)); + + EncodedTaskContent = encodedTaskContent; + Values = new ChangeTrackingList(); + Platform = platform; + } + + /// Initializes a new instance of . + /// The type of the run request. + /// The value that indicates whether archiving is enabled for the run or not. + /// The dedicated agent pool for the run. + /// The template that describes the repository and tag information for run log artifact. + /// Keeps track of any properties unknown to the library. + /// Base64 encoded value of the template/definition file content. + /// Base64 encoded value of the parameters/values file content. + /// The collection of overridable values that can be passed when running a task. + /// Run timeout in seconds. + /// The platform properties against which the run has to happen. + /// The machine configuration of the run agent. + /// + /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. + /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. + /// + /// The properties that describes a set of credentials that will be used when this run is invoked. + internal EncodedTaskRunContent(string @type, bool? isArchiveEnabled, string agentPoolName, string logTemplate, IDictionary additionalBinaryDataProperties, string encodedTaskContent, string encodedValuesContent, IList values, int? timeoutInSeconds, PlatformProperties platform, AgentProperties agentConfiguration, string sourceLocation, ContainerRegistryTaskCredentials credentials) : base(@type, isArchiveEnabled, agentPoolName, logTemplate, additionalBinaryDataProperties) + { + EncodedTaskContent = encodedTaskContent; + EncodedValuesContent = encodedValuesContent; + Values = values; + TimeoutInSeconds = timeoutInSeconds; + Platform = platform; + AgentConfiguration = agentConfiguration; + SourceLocation = sourceLocation; + Credentials = credentials; + } + + /// Base64 encoded value of the template/definition file content. + public string EncodedTaskContent { get; set; } + + /// Base64 encoded value of the parameters/values file content. + public string EncodedValuesContent { get; set; } + + /// The collection of overridable values that can be passed when running a task. + public IList Values { get; } + + /// Run timeout in seconds. + public int? TimeoutInSeconds { get; set; } + + /// The platform properties against which the run has to happen. + public PlatformProperties Platform { get; set; } + + /// The machine configuration of the run agent. + internal AgentProperties AgentConfiguration { get; set; } + + /// + /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. + /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. + /// + public string SourceLocation { get; set; } + + /// The properties that describes a set of credentials that will be used when this run is invoked. + public ContainerRegistryTaskCredentials Credentials { get; set; } + + /// The CPU configuration in terms of number of cores required for the run. + public int? AgentCpu + { + get + { + return AgentConfiguration is null ? default : AgentConfiguration.Cpu; + } + set + { + if (AgentConfiguration is null) + { + AgentConfiguration = new AgentProperties(); + } + AgentConfiguration.Cpu = value; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStep.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStep.Serialization.cs new file mode 100644 index 000000000000..e6ad785f5871 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStep.Serialization.cs @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a encoded task step. + public partial class EncodedTaskStep : TaskStepProperties, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EncodedTaskStep() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override TaskStepProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEncodedTaskStep(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EncodedTaskStep)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(EncodedTaskStep)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + EncodedTaskStep IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EncodedTaskStep)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EncodedTaskStep)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("encodedTaskContent"u8); + writer.WriteStringValue(EncodedTaskContent); + if (Optional.IsDefined(EncodedValuesContent)) + { + writer.WritePropertyName("encodedValuesContent"u8); + writer.WriteStringValue(EncodedValuesContent); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskSetValue item in Values) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EncodedTaskStep IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EncodedTaskStep)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TaskStepProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EncodedTaskStep)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEncodedTaskStep(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EncodedTaskStep DeserializeEncodedTaskStep(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StepType @type = default; + IReadOnlyList baseImageDependencies = default; + string contextPath = default; + string contextAccessToken = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string encodedTaskContent = default; + string encodedValuesContent = default; + IList values = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new StepType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("baseImageDependencies"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(BaseImageDependency.DeserializeBaseImageDependency(item, options)); + } + baseImageDependencies = array; + continue; + } + if (prop.NameEquals("contextPath"u8)) + { + contextPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("contextAccessToken"u8)) + { + contextAccessToken = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("encodedTaskContent"u8)) + { + encodedTaskContent = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("encodedValuesContent"u8)) + { + encodedValuesContent = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("values"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskSetValue.DeserializeContainerRegistryTaskSetValue(item, options)); + } + values = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EncodedTaskStep( + @type, + baseImageDependencies ?? new ChangeTrackingList(), + contextPath, + contextAccessToken, + additionalBinaryDataProperties, + encodedTaskContent, + encodedValuesContent, + values ?? new ChangeTrackingList()); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStep.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStep.cs new file mode 100644 index 000000000000..68b3bf5be71a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStep.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a encoded task step. + public partial class EncodedTaskStep : TaskStepProperties + { + /// Initializes a new instance of . + /// Base64 encoded value of the template/definition file content. + /// is null. + public EncodedTaskStep(string encodedTaskContent) : base(StepType.EncodedTask) + { + Argument.AssertNotNull(encodedTaskContent, nameof(encodedTaskContent)); + + EncodedTaskContent = encodedTaskContent; + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The type of the step. + /// List of base image dependencies for a step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Keeps track of any properties unknown to the library. + /// Base64 encoded value of the template/definition file content. + /// Base64 encoded value of the parameters/values file content. + /// The collection of overridable values that can be passed when running a task. + internal EncodedTaskStep(StepType @type, IReadOnlyList baseImageDependencies, string contextPath, string contextAccessToken, IDictionary additionalBinaryDataProperties, string encodedTaskContent, string encodedValuesContent, IList values) : base(@type, baseImageDependencies, contextPath, contextAccessToken, additionalBinaryDataProperties) + { + EncodedTaskContent = encodedTaskContent; + EncodedValuesContent = encodedValuesContent; + Values = values; + } + + /// Base64 encoded value of the template/definition file content. + public string EncodedTaskContent { get; set; } + + /// Base64 encoded value of the parameters/values file content. + public string EncodedValuesContent { get; set; } + + /// The collection of overridable values that can be passed when running a task. + public IList Values { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStepUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStepUpdateContent.Serialization.cs new file mode 100644 index 000000000000..473603da5947 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStepUpdateContent.Serialization.cs @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating encoded task step. + public partial class EncodedTaskStepUpdateContent : TaskStepUpdateContent, IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected override TaskStepUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEncodedTaskStepUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EncodedTaskStepUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(EncodedTaskStepUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + EncodedTaskStepUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EncodedTaskStepUpdateContent)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EncodedTaskStepUpdateContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(EncodedTaskContent)) + { + writer.WritePropertyName("encodedTaskContent"u8); + writer.WriteStringValue(EncodedTaskContent); + } + if (Optional.IsDefined(EncodedValuesContent)) + { + writer.WritePropertyName("encodedValuesContent"u8); + writer.WriteStringValue(EncodedValuesContent); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskSetValue item in Values) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EncodedTaskStepUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EncodedTaskStepUpdateContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TaskStepUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EncodedTaskStepUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEncodedTaskStepUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EncodedTaskStepUpdateContent DeserializeEncodedTaskStepUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StepType @type = default; + string contextPath = default; + string contextAccessToken = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string encodedTaskContent = default; + string encodedValuesContent = default; + IList values = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new StepType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("contextPath"u8)) + { + contextPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("contextAccessToken"u8)) + { + contextAccessToken = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("encodedTaskContent"u8)) + { + encodedTaskContent = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("encodedValuesContent"u8)) + { + encodedValuesContent = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("values"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskSetValue.DeserializeContainerRegistryTaskSetValue(item, options)); + } + values = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EncodedTaskStepUpdateContent( + @type, + contextPath, + contextAccessToken, + additionalBinaryDataProperties, + encodedTaskContent, + encodedValuesContent, + values ?? new ChangeTrackingList()); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStepUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStepUpdateContent.cs new file mode 100644 index 000000000000..37ef7ed81bbe --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/EncodedTaskStepUpdateContent.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating encoded task step. + public partial class EncodedTaskStepUpdateContent : TaskStepUpdateContent + { + /// Initializes a new instance of . + public EncodedTaskStepUpdateContent() : base(StepType.EncodedTask) + { + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The type of the step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Keeps track of any properties unknown to the library. + /// Base64 encoded value of the template/definition file content. + /// Base64 encoded value of the parameters/values file content. + /// The collection of overridable values that can be passed when running a task. + internal EncodedTaskStepUpdateContent(StepType @type, string contextPath, string contextAccessToken, IDictionary additionalBinaryDataProperties, string encodedTaskContent, string encodedValuesContent, IList values) : base(@type, contextPath, contextAccessToken, additionalBinaryDataProperties) + { + EncodedTaskContent = encodedTaskContent; + EncodedValuesContent = encodedValuesContent; + Values = values; + } + + /// Base64 encoded value of the template/definition file content. + public string EncodedTaskContent { get; set; } + + /// Base64 encoded value of the parameters/values file content. + public string EncodedValuesContent { get; set; } + + /// The collection of overridable values that can be passed when running a task. + public IList Values { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskRunContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskRunContent.Serialization.cs new file mode 100644 index 000000000000..7fac5df0c218 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskRunContent.Serialization.cs @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The request parameters for a scheduling run against a task file. + public partial class FileTaskRunContent : RunContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal FileTaskRunContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override RunContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeFileTaskRunContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileTaskRunContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(FileTaskRunContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + FileTaskRunContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (FileTaskRunContent)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileTaskRunContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("taskFilePath"u8); + writer.WriteStringValue(TaskFilePath); + if (Optional.IsDefined(ValuesFilePath)) + { + writer.WritePropertyName("valuesFilePath"u8); + writer.WriteStringValue(ValuesFilePath); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskSetValue item in Values) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(TimeoutInSeconds)) + { + writer.WritePropertyName("timeout"u8); + writer.WriteNumberValue(TimeoutInSeconds.Value); + } + writer.WritePropertyName("platform"u8); + writer.WriteObjectValue(Platform, options); + if (Optional.IsDefined(AgentConfiguration)) + { + writer.WritePropertyName("agentConfiguration"u8); + writer.WriteObjectValue(AgentConfiguration, options); + } + if (Optional.IsDefined(SourceLocation)) + { + writer.WritePropertyName("sourceLocation"u8); + writer.WriteStringValue(SourceLocation); + } + if (Optional.IsDefined(Credentials)) + { + writer.WritePropertyName("credentials"u8); + writer.WriteObjectValue(Credentials, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + FileTaskRunContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (FileTaskRunContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override RunContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileTaskRunContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileTaskRunContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FileTaskRunContent DeserializeFileTaskRunContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "FileTaskRunRequest"; + bool? isArchiveEnabled = default; + string agentPoolName = default; + string logTemplate = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string taskFilePath = default; + string valuesFilePath = default; + IList values = default; + int? timeoutInSeconds = default; + PlatformProperties platform = default; + AgentProperties agentConfiguration = default; + string sourceLocation = default; + ContainerRegistryTaskCredentials credentials = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("isArchiveEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isArchiveEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("agentPoolName"u8)) + { + agentPoolName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logTemplate"u8)) + { + logTemplate = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("taskFilePath"u8)) + { + taskFilePath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("valuesFilePath"u8)) + { + valuesFilePath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("values"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskSetValue.DeserializeContainerRegistryTaskSetValue(item, options)); + } + values = array; + continue; + } + if (prop.NameEquals("timeout"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeoutInSeconds = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("platform"u8)) + { + platform = PlatformProperties.DeserializePlatformProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("agentConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentConfiguration = AgentProperties.DeserializeAgentProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("sourceLocation"u8)) + { + sourceLocation = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("credentials"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + credentials = ContainerRegistryTaskCredentials.DeserializeContainerRegistryTaskCredentials(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FileTaskRunContent( + @type, + isArchiveEnabled, + agentPoolName, + logTemplate, + additionalBinaryDataProperties, + taskFilePath, + valuesFilePath, + values ?? new ChangeTrackingList(), + timeoutInSeconds, + platform, + agentConfiguration, + sourceLocation, + credentials); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskRunContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskRunContent.cs new file mode 100644 index 000000000000..a9c1d78cb833 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskRunContent.cs @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The request parameters for a scheduling run against a task file. + public partial class FileTaskRunContent : RunContent + { + /// Initializes a new instance of . + /// The template/definition file path relative to the source. + /// The platform properties against which the run has to happen. + /// or is null. + public FileTaskRunContent(string taskFilePath, PlatformProperties platform) : base("FileTaskRunRequest") + { + Argument.AssertNotNull(taskFilePath, nameof(taskFilePath)); + Argument.AssertNotNull(platform, nameof(platform)); + + TaskFilePath = taskFilePath; + Values = new ChangeTrackingList(); + Platform = platform; + } + + /// Initializes a new instance of . + /// The type of the run request. + /// The value that indicates whether archiving is enabled for the run or not. + /// The dedicated agent pool for the run. + /// The template that describes the repository and tag information for run log artifact. + /// Keeps track of any properties unknown to the library. + /// The template/definition file path relative to the source. + /// The values/parameters file path relative to the source. + /// The collection of overridable values that can be passed when running a task. + /// Run timeout in seconds. + /// The platform properties against which the run has to happen. + /// The machine configuration of the run agent. + /// + /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. + /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. + /// + /// The properties that describes a set of credentials that will be used when this run is invoked. + internal FileTaskRunContent(string @type, bool? isArchiveEnabled, string agentPoolName, string logTemplate, IDictionary additionalBinaryDataProperties, string taskFilePath, string valuesFilePath, IList values, int? timeoutInSeconds, PlatformProperties platform, AgentProperties agentConfiguration, string sourceLocation, ContainerRegistryTaskCredentials credentials) : base(@type, isArchiveEnabled, agentPoolName, logTemplate, additionalBinaryDataProperties) + { + TaskFilePath = taskFilePath; + ValuesFilePath = valuesFilePath; + Values = values; + TimeoutInSeconds = timeoutInSeconds; + Platform = platform; + AgentConfiguration = agentConfiguration; + SourceLocation = sourceLocation; + Credentials = credentials; + } + + /// The template/definition file path relative to the source. + public string TaskFilePath { get; set; } + + /// The values/parameters file path relative to the source. + public string ValuesFilePath { get; set; } + + /// The collection of overridable values that can be passed when running a task. + public IList Values { get; } + + /// Run timeout in seconds. + public int? TimeoutInSeconds { get; set; } + + /// The platform properties against which the run has to happen. + public PlatformProperties Platform { get; set; } + + /// The machine configuration of the run agent. + internal AgentProperties AgentConfiguration { get; set; } + + /// + /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. + /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. + /// + public string SourceLocation { get; set; } + + /// The properties that describes a set of credentials that will be used when this run is invoked. + public ContainerRegistryTaskCredentials Credentials { get; set; } + + /// The CPU configuration in terms of number of cores required for the run. + public int? AgentCpu + { + get + { + return AgentConfiguration is null ? default : AgentConfiguration.Cpu; + } + set + { + if (AgentConfiguration is null) + { + AgentConfiguration = new AgentProperties(); + } + AgentConfiguration.Cpu = value; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStep.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStep.Serialization.cs new file mode 100644 index 000000000000..1a8a34614bd9 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStep.Serialization.cs @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a task step. + public partial class FileTaskStep : TaskStepProperties, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal FileTaskStep() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override TaskStepProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeFileTaskStep(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileTaskStep)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(FileTaskStep)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + FileTaskStep IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (FileTaskStep)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileTaskStep)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("taskFilePath"u8); + writer.WriteStringValue(TaskFilePath); + if (Optional.IsDefined(ValuesFilePath)) + { + writer.WritePropertyName("valuesFilePath"u8); + writer.WriteStringValue(ValuesFilePath); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskSetValue item in Values) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + FileTaskStep IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (FileTaskStep)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TaskStepProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileTaskStep)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileTaskStep(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FileTaskStep DeserializeFileTaskStep(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StepType @type = default; + IReadOnlyList baseImageDependencies = default; + string contextPath = default; + string contextAccessToken = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string taskFilePath = default; + string valuesFilePath = default; + IList values = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new StepType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("baseImageDependencies"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(BaseImageDependency.DeserializeBaseImageDependency(item, options)); + } + baseImageDependencies = array; + continue; + } + if (prop.NameEquals("contextPath"u8)) + { + contextPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("contextAccessToken"u8)) + { + contextAccessToken = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("taskFilePath"u8)) + { + taskFilePath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("valuesFilePath"u8)) + { + valuesFilePath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("values"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskSetValue.DeserializeContainerRegistryTaskSetValue(item, options)); + } + values = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FileTaskStep( + @type, + baseImageDependencies ?? new ChangeTrackingList(), + contextPath, + contextAccessToken, + additionalBinaryDataProperties, + taskFilePath, + valuesFilePath, + values ?? new ChangeTrackingList()); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStep.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStep.cs new file mode 100644 index 000000000000..702da883841a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStep.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a task step. + public partial class FileTaskStep : TaskStepProperties + { + /// Initializes a new instance of . + /// The task template/definition file path relative to the source context. + /// is null. + public FileTaskStep(string taskFilePath) : base(StepType.FileTask) + { + Argument.AssertNotNull(taskFilePath, nameof(taskFilePath)); + + TaskFilePath = taskFilePath; + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The type of the step. + /// List of base image dependencies for a step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Keeps track of any properties unknown to the library. + /// The task template/definition file path relative to the source context. + /// The task values/parameters file path relative to the source context. + /// The collection of overridable values that can be passed when running a task. + internal FileTaskStep(StepType @type, IReadOnlyList baseImageDependencies, string contextPath, string contextAccessToken, IDictionary additionalBinaryDataProperties, string taskFilePath, string valuesFilePath, IList values) : base(@type, baseImageDependencies, contextPath, contextAccessToken, additionalBinaryDataProperties) + { + TaskFilePath = taskFilePath; + ValuesFilePath = valuesFilePath; + Values = values; + } + + /// The task template/definition file path relative to the source context. + public string TaskFilePath { get; set; } + + /// The task values/parameters file path relative to the source context. + public string ValuesFilePath { get; set; } + + /// The collection of overridable values that can be passed when running a task. + public IList Values { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStepUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStepUpdateContent.Serialization.cs new file mode 100644 index 000000000000..baaf9106abba --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStepUpdateContent.Serialization.cs @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of updating a task step. + public partial class FileTaskStepUpdateContent : TaskStepUpdateContent, IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected override TaskStepUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeFileTaskStepUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileTaskStepUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(FileTaskStepUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + FileTaskStepUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (FileTaskStepUpdateContent)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileTaskStepUpdateContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(TaskFilePath)) + { + writer.WritePropertyName("taskFilePath"u8); + writer.WriteStringValue(TaskFilePath); + } + if (Optional.IsDefined(ValuesFilePath)) + { + writer.WritePropertyName("valuesFilePath"u8); + writer.WriteStringValue(ValuesFilePath); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskSetValue item in Values) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + FileTaskStepUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (FileTaskStepUpdateContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TaskStepUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileTaskStepUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileTaskStepUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FileTaskStepUpdateContent DeserializeFileTaskStepUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StepType @type = default; + string contextPath = default; + string contextAccessToken = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string taskFilePath = default; + string valuesFilePath = default; + IList values = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new StepType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("contextPath"u8)) + { + contextPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("contextAccessToken"u8)) + { + contextAccessToken = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("taskFilePath"u8)) + { + taskFilePath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("valuesFilePath"u8)) + { + valuesFilePath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("values"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskSetValue.DeserializeContainerRegistryTaskSetValue(item, options)); + } + values = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FileTaskStepUpdateContent( + @type, + contextPath, + contextAccessToken, + additionalBinaryDataProperties, + taskFilePath, + valuesFilePath, + values ?? new ChangeTrackingList()); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStepUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStepUpdateContent.cs new file mode 100644 index 000000000000..caad189649ee --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/FileTaskStepUpdateContent.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of updating a task step. + public partial class FileTaskStepUpdateContent : TaskStepUpdateContent + { + /// Initializes a new instance of . + public FileTaskStepUpdateContent() : base(StepType.FileTask) + { + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The type of the step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Keeps track of any properties unknown to the library. + /// The task template/definition file path relative to the source context. + /// The values/parameters file path relative to the source context. + /// The collection of overridable values that can be passed when running a task. + internal FileTaskStepUpdateContent(StepType @type, string contextPath, string contextAccessToken, IDictionary additionalBinaryDataProperties, string taskFilePath, string valuesFilePath, IList values) : base(@type, contextPath, contextAccessToken, additionalBinaryDataProperties) + { + TaskFilePath = taskFilePath; + ValuesFilePath = valuesFilePath; + Values = values; + } + + /// The task template/definition file path relative to the source context. + public string TaskFilePath { get; set; } + + /// The values/parameters file path relative to the source context. + public string ValuesFilePath { get; set; } + + /// The collection of overridable values that can be passed when running a task. + public IList Values { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/IdentityProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/IdentityProperties.Serialization.cs new file mode 100644 index 000000000000..e3ef9a521b62 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/IdentityProperties.Serialization.cs @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Managed identity for the resource. + public partial class IdentityProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IdentityProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeIdentityProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IdentityProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(IdentityProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + IdentityProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IdentityProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(PrincipalId)) + { + writer.WritePropertyName("principalId"u8); + writer.WriteStringValue(PrincipalId); + } + if (options.Format != "W" && Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToSerialString()); + } + if (Optional.IsCollectionDefined(UserAssignedIdentities)) + { + writer.WritePropertyName("userAssignedIdentities"u8); + writer.WriteStartObject(); + foreach (var item in UserAssignedIdentities) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + IdentityProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IdentityProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IdentityProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIdentityProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IdentityProperties DeserializeIdentityProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string principalId = default; + string tenantId = default; + ResourceIdentityType? @type = default; + IDictionary userAssignedIdentities = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("principalId"u8)) + { + principalId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tenantId"u8)) + { + tenantId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @type = prop.Value.GetString().ToResourceIdentityType(); + continue; + } + if (prop.NameEquals("userAssignedIdentities"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, UserIdentityProperties.DeserializeUserIdentityProperties(prop0.Value, options)); + } + userAssignedIdentities = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new IdentityProperties(principalId, tenantId, @type, userAssignedIdentities ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/IdentityProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/IdentityProperties.cs new file mode 100644 index 000000000000..ebff1f993ac0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/IdentityProperties.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Managed identity for the resource. + public partial class IdentityProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public IdentityProperties() + { + UserAssignedIdentities = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The principal ID of resource identity. + /// The tenant ID of resource. + /// The identity type. + /// + /// The list of user identities associated with the resource. The user identity + /// dictionary key references will be ARM resource ids in the form: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + /// providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + /// + /// Keeps track of any properties unknown to the library. + internal IdentityProperties(string principalId, string tenantId, ResourceIdentityType? @type, IDictionary userAssignedIdentities, IDictionary additionalBinaryDataProperties) + { + PrincipalId = principalId; + TenantId = tenantId; + Type = @type; + UserAssignedIdentities = userAssignedIdentities; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The principal ID of resource identity. + public string PrincipalId { get; } + + /// The tenant ID of resource. + public string TenantId { get; } + + /// The identity type. + public ResourceIdentityType? Type { get; set; } + + /// + /// The list of user identities associated with the resource. The user identity + /// dictionary key references will be ARM resource ids in the form: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + /// providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + /// + public IDictionary UserAssignedIdentities { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageDescriptor.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageDescriptor.Serialization.cs new file mode 100644 index 000000000000..e242539e3a46 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageDescriptor.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Properties for a registry image. + public partial class ImageDescriptor : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ImageDescriptor PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeImageDescriptor(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageDescriptor)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(ImageDescriptor)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ImageDescriptor IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageDescriptor)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Registry)) + { + writer.WritePropertyName("registry"u8); + writer.WriteStringValue(Registry); + } + if (Optional.IsDefined(Repository)) + { + writer.WritePropertyName("repository"u8); + writer.WriteStringValue(Repository); + } + if (Optional.IsDefined(Tag)) + { + writer.WritePropertyName("tag"u8); + writer.WriteStringValue(Tag); + } + if (Optional.IsDefined(Digest)) + { + writer.WritePropertyName("digest"u8); + writer.WriteStringValue(Digest); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ImageDescriptor IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ImageDescriptor JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageDescriptor)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageDescriptor(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ImageDescriptor DeserializeImageDescriptor(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string registry = default; + string repository = default; + string tag = default; + string digest = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("registry"u8)) + { + registry = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("repository"u8)) + { + repository = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tag"u8)) + { + tag = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("digest"u8)) + { + digest = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ImageDescriptor(registry, repository, tag, digest, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageDescriptor.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageDescriptor.cs new file mode 100644 index 000000000000..ef0e0059c92d --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageDescriptor.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Properties for a registry image. + public partial class ImageDescriptor + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal ImageDescriptor() + { + } + + /// Initializes a new instance of . + /// The registry login server. + /// The repository name. + /// The tag name. + /// The sha256-based digest of the image manifest. + /// Keeps track of any properties unknown to the library. + internal ImageDescriptor(string registry, string repository, string tag, string digest, IDictionary additionalBinaryDataProperties) + { + Registry = registry; + Repository = repository; + Tag = tag; + Digest = digest; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The registry login server. + public string Registry { get; } + + /// The repository name. + public string Repository { get; } + + /// The tag name. + public string Tag { get; } + + /// The sha256-based digest of the image manifest. + public string Digest { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageUpdateTrigger.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageUpdateTrigger.Serialization.cs new file mode 100644 index 000000000000..12fdca0672c0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageUpdateTrigger.Serialization.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The image update trigger that caused a build. + public partial class ImageUpdateTrigger : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ImageUpdateTrigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeImageUpdateTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageUpdateTrigger)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(ImageUpdateTrigger)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ImageUpdateTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageUpdateTrigger)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(OccurredOn)) + { + writer.WritePropertyName("timestamp"u8); + writer.WriteStringValue(OccurredOn.Value, "O"); + } + if (Optional.IsCollectionDefined(Images)) + { + writer.WritePropertyName("images"u8); + writer.WriteStartArray(); + foreach (ImageDescriptor item in Images) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ImageUpdateTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ImageUpdateTrigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageUpdateTrigger)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageUpdateTrigger(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ImageUpdateTrigger DeserializeImageUpdateTrigger(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + DateTimeOffset? occurredOn = default; + IList images = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("timestamp"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + occurredOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("images"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ImageDescriptor.DeserializeImageDescriptor(item, options)); + } + images = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ImageUpdateTrigger(id, occurredOn, images ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageUpdateTrigger.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageUpdateTrigger.cs new file mode 100644 index 000000000000..e27cb6caaf2c --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ImageUpdateTrigger.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The image update trigger that caused a build. + public partial class ImageUpdateTrigger + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal ImageUpdateTrigger() + { + Images = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The unique ID of the trigger. + /// The timestamp when the image update happened. + /// The list of image updates that caused the build. + /// Keeps track of any properties unknown to the library. + internal ImageUpdateTrigger(string id, DateTimeOffset? occurredOn, IList images, IDictionary additionalBinaryDataProperties) + { + Id = id; + OccurredOn = occurredOn; + Images = images; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique ID of the trigger. + public string Id { get; } + + /// The timestamp when the image update happened. + public DateTimeOffset? OccurredOn { get; } + + /// The list of image updates that caused the build. + public IList Images { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/OverrideTaskStepProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/OverrideTaskStepProperties.Serialization.cs new file mode 100644 index 000000000000..cab3e622d1ff --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/OverrideTaskStepProperties.Serialization.cs @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The OverrideTaskStepProperties. + public partial class OverrideTaskStepProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OverrideTaskStepProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOverrideTaskStepProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OverrideTaskStepProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(OverrideTaskStepProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + OverrideTaskStepProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OverrideTaskStepProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ContextPath)) + { + writer.WritePropertyName("contextPath"u8); + writer.WriteStringValue(ContextPath); + } + if (Optional.IsDefined(File)) + { + writer.WritePropertyName("file"u8); + writer.WriteStringValue(File); + } + if (Optional.IsCollectionDefined(Arguments)) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskArgument item in Arguments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Target)) + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (ContainerRegistryTaskSetValue item in Values) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(UpdateTriggerToken)) + { + writer.WritePropertyName("updateTriggerToken"u8); + writer.WriteStringValue(UpdateTriggerToken); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OverrideTaskStepProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OverrideTaskStepProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OverrideTaskStepProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOverrideTaskStepProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OverrideTaskStepProperties DeserializeOverrideTaskStepProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string contextPath = default; + string @file = default; + IList arguments = default; + string target = default; + IList values = default; + string updateTriggerToken = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("contextPath"u8)) + { + contextPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file"u8)) + { + @file = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskArgument.DeserializeContainerRegistryTaskArgument(item, options)); + } + arguments = array; + continue; + } + if (prop.NameEquals("target"u8)) + { + target = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("values"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ContainerRegistryTaskSetValue.DeserializeContainerRegistryTaskSetValue(item, options)); + } + values = array; + continue; + } + if (prop.NameEquals("updateTriggerToken"u8)) + { + updateTriggerToken = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OverrideTaskStepProperties( + contextPath, + @file, + arguments ?? new ChangeTrackingList(), + target, + values ?? new ChangeTrackingList(), + updateTriggerToken, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/OverrideTaskStepProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/OverrideTaskStepProperties.cs new file mode 100644 index 000000000000..f0434fd6623a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/OverrideTaskStepProperties.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The OverrideTaskStepProperties. + public partial class OverrideTaskStepProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public OverrideTaskStepProperties() + { + Arguments = new ChangeTrackingList(); + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The source context against which run has to be queued. + /// The file against which run has to be queued. + /// + /// Gets or sets the collection of override arguments to be used when + /// executing a build step. + /// + /// The name of the target build stage for the docker build. + /// The collection of overridable values that can be passed when running a Task. + /// Base64 encoded update trigger token that will be attached with the base image trigger webhook. + /// Keeps track of any properties unknown to the library. + internal OverrideTaskStepProperties(string contextPath, string @file, IList arguments, string target, IList values, string updateTriggerToken, IDictionary additionalBinaryDataProperties) + { + ContextPath = contextPath; + File = @file; + Arguments = arguments; + Target = target; + Values = values; + UpdateTriggerToken = updateTriggerToken; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The source context against which run has to be queued. + public string ContextPath { get; set; } + + /// The file against which run has to be queued. + public string File { get; set; } + + /// + /// Gets or sets the collection of override arguments to be used when + /// executing a build step. + /// + public IList Arguments { get; } + + /// The name of the target build stage for the docker build. + public string Target { get; set; } + + /// The collection of overridable values that can be passed when running a Task. + public IList Values { get; } + + /// Base64 encoded update trigger token that will be attached with the base image trigger webhook. + public string UpdateTriggerToken { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformProperties.Serialization.cs new file mode 100644 index 000000000000..881c8f9c939c --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformProperties.Serialization.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The platform properties against which the run has to happen. + public partial class PlatformProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PlatformProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PlatformProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePlatformProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PlatformProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(PlatformProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + PlatformProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PlatformProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("os"u8); + writer.WriteStringValue(OS.ToString()); + if (Optional.IsDefined(Architecture)) + { + writer.WritePropertyName("architecture"u8); + writer.WriteStringValue(Architecture.Value.ToString()); + } + if (Optional.IsDefined(Variant)) + { + writer.WritePropertyName("variant"u8); + writer.WriteStringValue(Variant.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PlatformProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PlatformProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PlatformProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePlatformProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PlatformProperties DeserializePlatformProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ContainerRegistryTaskOS os = default; + ContainerRegistryTaskArchitecture? architecture = default; + ContainerRegistryTaskVariant? variant = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("os"u8)) + { + os = new ContainerRegistryTaskOS(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("architecture"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + architecture = new ContainerRegistryTaskArchitecture(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("variant"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + variant = new ContainerRegistryTaskVariant(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PlatformProperties(os, architecture, variant, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformProperties.cs new file mode 100644 index 000000000000..75430fd7ac99 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformProperties.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The platform properties against which the run has to happen. + public partial class PlatformProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The operating system type required for the run. + public PlatformProperties(ContainerRegistryTaskOS os) + { + OS = os; + } + + /// Initializes a new instance of . + /// The operating system type required for the run. + /// The OS architecture. + /// Variant of the CPU. + /// Keeps track of any properties unknown to the library. + internal PlatformProperties(ContainerRegistryTaskOS os, ContainerRegistryTaskArchitecture? architecture, ContainerRegistryTaskVariant? variant, IDictionary additionalBinaryDataProperties) + { + OS = os; + Architecture = architecture; + Variant = variant; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The operating system type required for the run. + public ContainerRegistryTaskOS OS { get; set; } + + /// The OS architecture. + public ContainerRegistryTaskArchitecture? Architecture { get; set; } + + /// Variant of the CPU. + public ContainerRegistryTaskVariant? Variant { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformUpdateContent.Serialization.cs new file mode 100644 index 000000000000..ed48e616ec2a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformUpdateContent.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating the platform configuration. + public partial class PlatformUpdateContent : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PlatformUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePlatformUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PlatformUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(PlatformUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + PlatformUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PlatformUpdateContent)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(OS)) + { + writer.WritePropertyName("os"u8); + writer.WriteStringValue(OS.Value.ToString()); + } + if (Optional.IsDefined(Architecture)) + { + writer.WritePropertyName("architecture"u8); + writer.WriteStringValue(Architecture.Value.ToString()); + } + if (Optional.IsDefined(Variant)) + { + writer.WritePropertyName("variant"u8); + writer.WriteStringValue(Variant.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PlatformUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PlatformUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PlatformUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePlatformUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PlatformUpdateContent DeserializePlatformUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ContainerRegistryTaskOS? os = default; + ContainerRegistryTaskArchitecture? architecture = default; + ContainerRegistryTaskVariant? variant = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("os"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + os = new ContainerRegistryTaskOS(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("architecture"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + architecture = new ContainerRegistryTaskArchitecture(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("variant"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + variant = new ContainerRegistryTaskVariant(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PlatformUpdateContent(os, architecture, variant, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformUpdateContent.cs new file mode 100644 index 000000000000..7eae224c5631 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/PlatformUpdateContent.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating the platform configuration. + public partial class PlatformUpdateContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public PlatformUpdateContent() + { + } + + /// Initializes a new instance of . + /// The operating system type required for the run. + /// The OS architecture. + /// Variant of the CPU. + /// Keeps track of any properties unknown to the library. + internal PlatformUpdateContent(ContainerRegistryTaskOS? os, ContainerRegistryTaskArchitecture? architecture, ContainerRegistryTaskVariant? variant, IDictionary additionalBinaryDataProperties) + { + OS = os; + Architecture = architecture; + Variant = variant; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The operating system type required for the run. + public ContainerRegistryTaskOS? OS { get; set; } + + /// The OS architecture. + public ContainerRegistryTaskArchitecture? Architecture { get; set; } + + /// Variant of the CPU. + public ContainerRegistryTaskVariant? Variant { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ResourceIdentityType.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ResourceIdentityType.Serialization.cs new file mode 100644 index 000000000000..782cef824b1f --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ResourceIdentityType.Serialization.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + internal static partial class ResourceIdentityTypeExtensions + { + /// The value to serialize. + public static string ToSerialString(this ResourceIdentityType value) => value switch + { + ResourceIdentityType.SystemAssigned => "SystemAssigned", + ResourceIdentityType.UserAssigned => "UserAssigned", + ResourceIdentityType.SystemAssignedUserAssigned => "SystemAssigned, UserAssigned", + ResourceIdentityType.None => "None", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResourceIdentityType value.") + }; + + /// The value to deserialize. + public static ResourceIdentityType ToResourceIdentityType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "SystemAssigned")) + { + return ResourceIdentityType.SystemAssigned; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "UserAssigned")) + { + return ResourceIdentityType.UserAssigned; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "SystemAssigned, UserAssigned")) + { + return ResourceIdentityType.SystemAssignedUserAssigned; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "None")) + { + return ResourceIdentityType.None; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResourceIdentityType value."); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ResourceIdentityType.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ResourceIdentityType.cs new file mode 100644 index 000000000000..59504b5cfce0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/ResourceIdentityType.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The identity type. + public enum ResourceIdentityType + { + /// SystemAssigned. + SystemAssigned, + /// UserAssigned. + UserAssigned, + /// SystemAssignedUserAssigned. + SystemAssignedUserAssigned, + /// None. + None + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunContent.Serialization.cs new file mode 100644 index 000000000000..41c825858b54 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunContent.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// + /// The request parameters for scheduling a run. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + [PersistableModelProxy(typeof(UnknownRunContent))] + public abstract partial class RunContent : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal RunContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RunContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRunContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(RunContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RunContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(RunContent runContent) + { + if (runContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(runContent, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunContent)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (Optional.IsDefined(IsArchiveEnabled)) + { + writer.WritePropertyName("isArchiveEnabled"u8); + writer.WriteBooleanValue(IsArchiveEnabled.Value); + } + if (Optional.IsDefined(AgentPoolName)) + { + writer.WritePropertyName("agentPoolName"u8); + writer.WriteStringValue(AgentPoolName); + } + if (Optional.IsDefined(LogTemplate)) + { + writer.WritePropertyName("logTemplate"u8); + writer.WriteStringValue(LogTemplate); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RunContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RunContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RunContent DeserializeRunContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "DockerBuildRequest": + return DockerBuildContent.DeserializeDockerBuildContent(element, options); + case "FileTaskRunRequest": + return FileTaskRunContent.DeserializeFileTaskRunContent(element, options); + case "TaskRunRequest": + return TaskRunContent.DeserializeTaskRunContent(element, options); + case "EncodedTaskRunRequest": + return EncodedTaskRunContent.DeserializeEncodedTaskRunContent(element, options); + } + } + return UnknownRunContent.DeserializeUnknownRunContent(element, options); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunContent.cs new file mode 100644 index 000000000000..00e47792d829 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunContent.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// + /// The request parameters for scheduling a run. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + public abstract partial class RunContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of the run request. + private protected RunContent(string @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// The type of the run request. + /// The value that indicates whether archiving is enabled for the run or not. + /// The dedicated agent pool for the run. + /// The template that describes the repository and tag information for run log artifact. + /// Keeps track of any properties unknown to the library. + internal RunContent(string @type, bool? isArchiveEnabled, string agentPoolName, string logTemplate, IDictionary additionalBinaryDataProperties) + { + Type = @type; + IsArchiveEnabled = isArchiveEnabled; + AgentPoolName = agentPoolName; + LogTemplate = logTemplate; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of the run request. + internal string Type { get; set; } + + /// The value that indicates whether archiving is enabled for the run or not. + public bool? IsArchiveEnabled { get; set; } + + /// The dedicated agent pool for the run. + public string AgentPoolName { get; set; } + + /// The template that describes the repository and tag information for run log artifact. + public string LogTemplate { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunGetLogResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunGetLogResult.Serialization.cs new file mode 100644 index 000000000000..1d55d8856be0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunGetLogResult.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The result of get log link operation. + public partial class RunGetLogResult : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RunGetLogResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRunGetLogResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunGetLogResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(RunGetLogResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RunGetLogResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static RunGetLogResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunGetLogResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunGetLogResult)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(LogLink)) + { + writer.WritePropertyName("logLink"u8); + writer.WriteStringValue(LogLink); + } + if (Optional.IsDefined(LogArtifactLink)) + { + writer.WritePropertyName("logArtifactLink"u8); + writer.WriteStringValue(LogArtifactLink); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RunGetLogResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RunGetLogResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunGetLogResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunGetLogResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RunGetLogResult DeserializeRunGetLogResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string logLink = default; + string logArtifactLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("logLink"u8)) + { + logLink = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logArtifactLink"u8)) + { + logArtifactLink = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RunGetLogResult(logLink, logArtifactLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunGetLogResult.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunGetLogResult.cs new file mode 100644 index 000000000000..400b3a5422cf --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunGetLogResult.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The result of get log link operation. + public partial class RunGetLogResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal RunGetLogResult() + { + } + + /// Initializes a new instance of . + /// The link to logs for a run on a azure container registry. + /// The link to logs in registry for a run on a azure container registry. + /// Keeps track of any properties unknown to the library. + internal RunGetLogResult(string logLink, string logArtifactLink, IDictionary additionalBinaryDataProperties) + { + LogLink = logLink; + LogArtifactLink = logArtifactLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The link to logs for a run on a azure container registry. + public string LogLink { get; } + + /// The link to logs in registry for a run on a azure container registry. + public string LogArtifactLink { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunListResult.Serialization.cs new file mode 100644 index 000000000000..540af5be8a73 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunListResult.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The collection of runs. + internal partial class RunListResult : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RunListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRunListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(RunListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RunListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static RunListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunListResult)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (RunData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RunListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RunListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RunListResult DeserializeRunListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + string nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(RunData.DeserializeRunData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + nextLink = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RunListResult(value ?? new ChangeTrackingList(), nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunListResult.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunListResult.cs new file mode 100644 index 000000000000..f1efd8fbea3f --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The collection of runs. + internal partial class RunListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal RunListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The collection value. + /// The URI that can be used to request the next set of paged results. + /// Keeps track of any properties unknown to the library. + internal RunListResult(IList value, string nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The collection value. + public IList Value { get; } + + /// The URI that can be used to request the next set of paged results. + public string NextLink { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunPatch.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunPatch.Serialization.cs new file mode 100644 index 000000000000..8698435b74ea --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunPatch.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The set of run properties that can be updated. + public partial class RunPatch : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RunPatch PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRunPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunPatch)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(RunPatch)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RunPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(RunPatch runPatch) + { + if (runPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(runPatch, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunPatch)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(IsArchiveEnabled)) + { + writer.WritePropertyName("isArchiveEnabled"u8); + writer.WriteBooleanValue(IsArchiveEnabled.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RunPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RunPatch JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunPatch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunPatch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RunPatch DeserializeRunPatch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? isArchiveEnabled = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("isArchiveEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isArchiveEnabled = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RunPatch(isArchiveEnabled, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunPatch.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunPatch.cs new file mode 100644 index 000000000000..ef3a80b72882 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunPatch.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The set of run properties that can be updated. + public partial class RunPatch + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public RunPatch() + { + } + + /// Initializes a new instance of . + /// The value that indicates whether archiving is enabled or not. + /// Keeps track of any properties unknown to the library. + internal RunPatch(bool? isArchiveEnabled, IDictionary additionalBinaryDataProperties) + { + IsArchiveEnabled = isArchiveEnabled; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The value that indicates whether archiving is enabled or not. + public bool? IsArchiveEnabled { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunProperties.Serialization.cs new file mode 100644 index 000000000000..2e90481d5265 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunProperties.Serialization.cs @@ -0,0 +1,491 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for a run. + internal partial class RunProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RunProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRunProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(RunProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RunProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(RunId)) + { + writer.WritePropertyName("runId"u8); + writer.WriteStringValue(RunId); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (Optional.IsDefined(LastUpdatedOn)) + { + writer.WritePropertyName("lastUpdatedTime"u8); + writer.WriteStringValue(LastUpdatedOn.Value, "O"); + } + if (Optional.IsDefined(RunType)) + { + writer.WritePropertyName("runType"u8); + writer.WriteStringValue(RunType.Value.ToString()); + } + if (Optional.IsDefined(AgentPoolName)) + { + writer.WritePropertyName("agentPoolName"u8); + writer.WriteStringValue(AgentPoolName); + } + if (Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("createTime"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (Optional.IsDefined(StartOn)) + { + writer.WritePropertyName("startTime"u8); + writer.WriteStringValue(StartOn.Value, "O"); + } + if (Optional.IsDefined(FinishOn)) + { + writer.WritePropertyName("finishTime"u8); + writer.WriteStringValue(FinishOn.Value, "O"); + } + if (Optional.IsCollectionDefined(OutputImages)) + { + writer.WritePropertyName("outputImages"u8); + writer.WriteStartArray(); + foreach (ImageDescriptor item in OutputImages) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Task)) + { + writer.WritePropertyName("task"u8); + writer.WriteStringValue(Task); + } + if (Optional.IsDefined(ImageUpdateTrigger)) + { + writer.WritePropertyName("imageUpdateTrigger"u8); + writer.WriteObjectValue(ImageUpdateTrigger, options); + } + if (Optional.IsDefined(SourceTrigger)) + { + writer.WritePropertyName("sourceTrigger"u8); + writer.WriteObjectValue(SourceTrigger, options); + } + if (Optional.IsDefined(TimerTrigger)) + { + writer.WritePropertyName("timerTrigger"u8); + writer.WriteObjectValue(TimerTrigger, options); + } + if (Optional.IsDefined(Platform)) + { + writer.WritePropertyName("platform"u8); + writer.WriteObjectValue(Platform, options); + } + if (Optional.IsDefined(AgentConfiguration)) + { + writer.WritePropertyName("agentConfiguration"u8); + writer.WriteObjectValue(AgentConfiguration, options); + } + if (Optional.IsDefined(SourceRegistryAuth)) + { + writer.WritePropertyName("sourceRegistryAuth"u8); + writer.WriteStringValue(SourceRegistryAuth); + } + if (Optional.IsCollectionDefined(CustomRegistries)) + { + writer.WritePropertyName("customRegistries"u8); + writer.WriteStartArray(); + foreach (string item in CustomRegistries) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(RunErrorMessage)) + { + writer.WritePropertyName("runErrorMessage"u8); + writer.WriteStringValue(RunErrorMessage); + } + if (Optional.IsDefined(UpdateTriggerToken)) + { + writer.WritePropertyName("updateTriggerToken"u8); + writer.WriteStringValue(UpdateTriggerToken); + } + if (options.Format != "W" && Optional.IsDefined(LogArtifact)) + { + writer.WritePropertyName("logArtifact"u8); + writer.WriteObjectValue(LogArtifact, options); + } + if (Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(IsArchiveEnabled)) + { + writer.WritePropertyName("isArchiveEnabled"u8); + writer.WriteBooleanValue(IsArchiveEnabled.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RunProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RunProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RunProperties DeserializeRunProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string runId = default; + ContainerRegistryTaskRunStatus? status = default; + DateTimeOffset? lastUpdatedOn = default; + ContainerRegistryTaskRunType? runType = default; + string agentPoolName = default; + DateTimeOffset? createdOn = default; + DateTimeOffset? startOn = default; + DateTimeOffset? finishOn = default; + IList outputImages = default; + string task = default; + ImageUpdateTrigger imageUpdateTrigger = default; + SourceTriggerDescriptor sourceTrigger = default; + TimerTriggerDescriptor timerTrigger = default; + PlatformProperties platform = default; + AgentProperties agentConfiguration = default; + string sourceRegistryAuth = default; + IList customRegistries = default; + string runErrorMessage = default; + string updateTriggerToken = default; + ImageDescriptor logArtifact = default; + ContainerRegistryTaskProvisioningState? provisioningState = default; + bool? isArchiveEnabled = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("runId"u8)) + { + runId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ContainerRegistryTaskRunStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("lastUpdatedTime"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastUpdatedOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("runType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + runType = new ContainerRegistryTaskRunType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("agentPoolName"u8)) + { + agentPoolName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("createTime"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("startTime"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("finishTime"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + finishOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("outputImages"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ImageDescriptor.DeserializeImageDescriptor(item, options)); + } + outputImages = array; + continue; + } + if (prop.NameEquals("task"u8)) + { + task = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("imageUpdateTrigger"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + imageUpdateTrigger = ImageUpdateTrigger.DeserializeImageUpdateTrigger(prop.Value, options); + continue; + } + if (prop.NameEquals("sourceTrigger"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceTrigger = SourceTriggerDescriptor.DeserializeSourceTriggerDescriptor(prop.Value, options); + continue; + } + if (prop.NameEquals("timerTrigger"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timerTrigger = TimerTriggerDescriptor.DeserializeTimerTriggerDescriptor(prop.Value, options); + continue; + } + if (prop.NameEquals("platform"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + platform = PlatformProperties.DeserializePlatformProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("agentConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentConfiguration = AgentProperties.DeserializeAgentProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("sourceRegistryAuth"u8)) + { + sourceRegistryAuth = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("customRegistries"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + customRegistries = array; + continue; + } + if (prop.NameEquals("runErrorMessage"u8)) + { + runErrorMessage = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("updateTriggerToken"u8)) + { + updateTriggerToken = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logArtifact"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + logArtifact = ImageDescriptor.DeserializeImageDescriptor(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ContainerRegistryTaskProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("isArchiveEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isArchiveEnabled = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RunProperties( + runId, + status, + lastUpdatedOn, + runType, + agentPoolName, + createdOn, + startOn, + finishOn, + outputImages ?? new ChangeTrackingList(), + task, + imageUpdateTrigger, + sourceTrigger, + timerTrigger, + platform, + agentConfiguration, + sourceRegistryAuth, + customRegistries ?? new ChangeTrackingList(), + runErrorMessage, + updateTriggerToken, + logArtifact, + provisioningState, + isArchiveEnabled, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunProperties.cs new file mode 100644 index 000000000000..ed0c923ae384 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/RunProperties.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for a run. + internal partial class RunProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal RunProperties() + { + OutputImages = new ChangeTrackingList(); + CustomRegistries = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The unique identifier for the run. + /// The current status of the run. + /// The last updated time for the run. + /// The type of run. + /// The dedicated agent pool for the run. + /// The time the run was scheduled. + /// The time the run started. + /// The time the run finished. + /// The list of all images that were generated from the run. This is applicable if the run generates base image dependencies. + /// The task against which run was scheduled. + /// The image update trigger that caused the run. This is applicable if the task has base image trigger configured. + /// The source trigger that caused the run. + /// The timer trigger that caused the run. + /// The platform properties against which the run will happen. + /// The machine configuration of the run agent. + /// The scope of the credentials that were used to login to the source registry during this run. + /// The list of custom registries that were logged in during this run. + /// The error message received from backend systems after the run is scheduled. + /// The update trigger token passed for the Run. + /// The image description for the log artifact. + /// The provisioning state of a run. + /// The value that indicates whether archiving is enabled or not. + /// Keeps track of any properties unknown to the library. + internal RunProperties(string runId, ContainerRegistryTaskRunStatus? status, DateTimeOffset? lastUpdatedOn, ContainerRegistryTaskRunType? runType, string agentPoolName, DateTimeOffset? createdOn, DateTimeOffset? startOn, DateTimeOffset? finishOn, IList outputImages, string task, ImageUpdateTrigger imageUpdateTrigger, SourceTriggerDescriptor sourceTrigger, TimerTriggerDescriptor timerTrigger, PlatformProperties platform, AgentProperties agentConfiguration, string sourceRegistryAuth, IList customRegistries, string runErrorMessage, string updateTriggerToken, ImageDescriptor logArtifact, ContainerRegistryTaskProvisioningState? provisioningState, bool? isArchiveEnabled, IDictionary additionalBinaryDataProperties) + { + RunId = runId; + Status = status; + LastUpdatedOn = lastUpdatedOn; + RunType = runType; + AgentPoolName = agentPoolName; + CreatedOn = createdOn; + StartOn = startOn; + FinishOn = finishOn; + OutputImages = outputImages; + Task = task; + ImageUpdateTrigger = imageUpdateTrigger; + SourceTrigger = sourceTrigger; + TimerTrigger = timerTrigger; + Platform = platform; + AgentConfiguration = agentConfiguration; + SourceRegistryAuth = sourceRegistryAuth; + CustomRegistries = customRegistries; + RunErrorMessage = runErrorMessage; + UpdateTriggerToken = updateTriggerToken; + LogArtifact = logArtifact; + ProvisioningState = provisioningState; + IsArchiveEnabled = isArchiveEnabled; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique identifier for the run. + public string RunId { get; } + + /// The current status of the run. + public ContainerRegistryTaskRunStatus? Status { get; } + + /// The last updated time for the run. + public DateTimeOffset? LastUpdatedOn { get; } + + /// The type of run. + public ContainerRegistryTaskRunType? RunType { get; } + + /// The dedicated agent pool for the run. + public string AgentPoolName { get; } + + /// The time the run was scheduled. + public DateTimeOffset? CreatedOn { get; } + + /// The time the run started. + public DateTimeOffset? StartOn { get; } + + /// The time the run finished. + public DateTimeOffset? FinishOn { get; } + + /// The list of all images that were generated from the run. This is applicable if the run generates base image dependencies. + public IList OutputImages { get; } = new ChangeTrackingList(); + + /// The task against which run was scheduled. + public string Task { get; } + + /// The image update trigger that caused the run. This is applicable if the task has base image trigger configured. + public ImageUpdateTrigger ImageUpdateTrigger { get; } + + /// The source trigger that caused the run. + public SourceTriggerDescriptor SourceTrigger { get; } + + /// The timer trigger that caused the run. + public TimerTriggerDescriptor TimerTrigger { get; } + + /// The platform properties against which the run will happen. + public PlatformProperties Platform { get; } + + /// The machine configuration of the run agent. + internal AgentProperties AgentConfiguration { get; } + + /// The scope of the credentials that were used to login to the source registry during this run. + public string SourceRegistryAuth { get; } + + /// The list of custom registries that were logged in during this run. + public IList CustomRegistries { get; } = new ChangeTrackingList(); + + /// The error message received from backend systems after the run is scheduled. + public string RunErrorMessage { get; } + + /// The update trigger token passed for the Run. + public string UpdateTriggerToken { get; } + + /// The image description for the log artifact. + public ImageDescriptor LogArtifact { get; } + + /// The provisioning state of a run. + public ContainerRegistryTaskProvisioningState? ProvisioningState { get; } + + /// The value that indicates whether archiving is enabled or not. + public bool? IsArchiveEnabled { get; } + + /// The CPU configuration in terms of number of cores required for the run. + public int? AgentCpu + { + get + { + return AgentConfiguration.Cpu; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceControlType.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceControlType.cs new file mode 100644 index 000000000000..f353f9cb64e8 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceControlType.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The type of source control service. + public readonly partial struct SourceControlType : IEquatable + { + private readonly string _value; + private const string GithubValue = "Github"; + private const string VisualStudioTeamServiceValue = "VisualStudioTeamService"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public SourceControlType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Github. + public static SourceControlType Github { get; } = new SourceControlType(GithubValue); + + /// Gets the VisualStudioTeamService. + public static SourceControlType VisualStudioTeamService { get; } = new SourceControlType(VisualStudioTeamServiceValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(SourceControlType left, SourceControlType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(SourceControlType left, SourceControlType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator SourceControlType(string value) => new SourceControlType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator SourceControlType?(string value) => value == null ? null : new SourceControlType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SourceControlType other && Equals(other); + + /// + public bool Equals(SourceControlType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceProperties.Serialization.cs new file mode 100644 index 000000000000..ed7d7c9c2cda --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceProperties.Serialization.cs @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of the source code repository. + public partial class SourceProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SourceProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SourceProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(SourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("sourceControlType"u8); + writer.WriteStringValue(SourceControlType.ToString()); + writer.WritePropertyName("repositoryUrl"u8); + writer.WriteStringValue(RepositoryUri.AbsoluteUri); + if (Optional.IsDefined(Branch)) + { + writer.WritePropertyName("branch"u8); + writer.WriteStringValue(Branch); + } + if (Optional.IsDefined(SourceControlAuthProperties)) + { + writer.WritePropertyName("sourceControlAuthProperties"u8); + writer.WriteObjectValue(SourceControlAuthProperties, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SourceProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SourceProperties DeserializeSourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SourceControlType sourceControlType = default; + Uri repositoryUri = default; + string branch = default; + AuthInfo sourceControlAuthProperties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("sourceControlType"u8)) + { + sourceControlType = new SourceControlType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("repositoryUrl"u8)) + { + repositoryUri = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (prop.NameEquals("branch"u8)) + { + branch = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("sourceControlAuthProperties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceControlAuthProperties = AuthInfo.DeserializeAuthInfo(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SourceProperties(sourceControlType, repositoryUri, branch, sourceControlAuthProperties, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceProperties.cs new file mode 100644 index 000000000000..492bb323df09 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceProperties.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of the source code repository. + public partial class SourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of source control service. + /// The full URL to the source code repository. + /// is null. + public SourceProperties(SourceControlType sourceControlType, Uri repositoryUri) + { + Argument.AssertNotNull(repositoryUri, nameof(repositoryUri)); + + SourceControlType = sourceControlType; + RepositoryUri = repositoryUri; + } + + /// Initializes a new instance of . + /// The type of source control service. + /// The full URL to the source code repository. + /// The branch name of the source code. + /// + /// The authorization properties for accessing the source code repository and to set up + /// webhooks for notifications. + /// + /// Keeps track of any properties unknown to the library. + internal SourceProperties(SourceControlType sourceControlType, Uri repositoryUri, string branch, AuthInfo sourceControlAuthProperties, IDictionary additionalBinaryDataProperties) + { + SourceControlType = sourceControlType; + RepositoryUri = repositoryUri; + Branch = branch; + SourceControlAuthProperties = sourceControlAuthProperties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of source control service. + public SourceControlType SourceControlType { get; set; } + + /// The full URL to the source code repository. + public Uri RepositoryUri { get; set; } + + /// The branch name of the source code. + public string Branch { get; set; } + + /// + /// The authorization properties for accessing the source code repository and to set up + /// webhooks for notifications. + /// + public AuthInfo SourceControlAuthProperties { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceRegistryCredentials.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceRegistryCredentials.Serialization.cs new file mode 100644 index 000000000000..1dc7173c149b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceRegistryCredentials.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Describes the credential parameters for accessing the source registry. + public partial class SourceRegistryCredentials : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SourceRegistryCredentials PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSourceRegistryCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SourceRegistryCredentials)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(SourceRegistryCredentials)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SourceRegistryCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceRegistryCredentials)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + writer.WriteStringValue(Identity); + } + if (Optional.IsDefined(LoginMode)) + { + writer.WritePropertyName("loginMode"u8); + writer.WriteStringValue(LoginMode.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SourceRegistryCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SourceRegistryCredentials JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceRegistryCredentials)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSourceRegistryCredentials(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SourceRegistryCredentials DeserializeSourceRegistryCredentials(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string identity = default; + SourceRegistryLoginMode? loginMode = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("identity"u8)) + { + identity = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("loginMode"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + loginMode = new SourceRegistryLoginMode(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SourceRegistryCredentials(identity, loginMode, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceRegistryCredentials.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceRegistryCredentials.cs new file mode 100644 index 000000000000..1974ef5cd4d2 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceRegistryCredentials.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Describes the credential parameters for accessing the source registry. + public partial class SourceRegistryCredentials + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SourceRegistryCredentials() + { + } + + /// Initializes a new instance of . + /// + /// The Entra identity used for source registry login. + /// The value is `[system]` for system-assigned managed identity, `[caller]` for caller identity, + /// and client ID for user-assigned managed identity. + /// + /// + /// The authentication mode which determines the source registry login scope. The credentials for the source registry + /// will be generated using the given scope. These credentials will be used to login to + /// the source registry during the run. + /// + /// Keeps track of any properties unknown to the library. + internal SourceRegistryCredentials(string identity, SourceRegistryLoginMode? loginMode, IDictionary additionalBinaryDataProperties) + { + Identity = identity; + LoginMode = loginMode; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The Entra identity used for source registry login. + /// The value is `[system]` for system-assigned managed identity, `[caller]` for caller identity, + /// and client ID for user-assigned managed identity. + /// + public string Identity { get; set; } + + /// + /// The authentication mode which determines the source registry login scope. The credentials for the source registry + /// will be generated using the given scope. These credentials will be used to login to + /// the source registry during the run. + /// + public SourceRegistryLoginMode? LoginMode { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceRegistryLoginMode.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceRegistryLoginMode.cs new file mode 100644 index 000000000000..c3913774a119 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceRegistryLoginMode.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// + /// The authentication mode which determines the source registry login scope. The credentials for the source registry + /// will be generated using the given scope. These credentials will be used to login to + /// the source registry during the run. + /// + public readonly partial struct SourceRegistryLoginMode : IEquatable + { + private readonly string _value; + private const string NoneValue = "None"; + private const string DefaultValue = "Default"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public SourceRegistryLoginMode(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the None. + public static SourceRegistryLoginMode None { get; } = new SourceRegistryLoginMode(NoneValue); + + /// Gets the Default. + public static SourceRegistryLoginMode Default { get; } = new SourceRegistryLoginMode(DefaultValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(SourceRegistryLoginMode left, SourceRegistryLoginMode right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(SourceRegistryLoginMode left, SourceRegistryLoginMode right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator SourceRegistryLoginMode(string value) => new SourceRegistryLoginMode(value); + + /// Converts a string to a . + /// The value. + public static implicit operator SourceRegistryLoginMode?(string value) => value == null ? null : new SourceRegistryLoginMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SourceRegistryLoginMode other && Equals(other); + + /// + public bool Equals(SourceRegistryLoginMode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTrigger.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTrigger.Serialization.cs new file mode 100644 index 000000000000..2b7b2ea96df5 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTrigger.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a source based trigger. + public partial class SourceTrigger : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SourceTrigger() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SourceTrigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSourceTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SourceTrigger)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(SourceTrigger)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SourceTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceTrigger)} does not support writing '{format}' format."); + } + writer.WritePropertyName("sourceRepository"u8); + writer.WriteObjectValue(SourceRepository, options); + writer.WritePropertyName("sourceTriggerEvents"u8); + writer.WriteStartArray(); + foreach (SourceTriggerEvent item in SourceTriggerEvents) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SourceTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SourceTrigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceTrigger)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSourceTrigger(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SourceTrigger DeserializeSourceTrigger(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SourceProperties sourceRepository = default; + IList sourceTriggerEvents = default; + ContainerRegistryTaskTriggerStatus? status = default; + string name = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("sourceRepository"u8)) + { + sourceRepository = SourceProperties.DeserializeSourceProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("sourceTriggerEvents"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new SourceTriggerEvent(item.GetString())); + } + sourceTriggerEvents = array; + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ContainerRegistryTaskTriggerStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SourceTrigger(sourceRepository, sourceTriggerEvents, status, name, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTrigger.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTrigger.cs new file mode 100644 index 000000000000..2ccd1f5fdf00 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTrigger.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a source based trigger. + public partial class SourceTrigger + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The properties that describes the source(code) for the task. + /// The source event corresponding to the trigger. + /// The name of the trigger. + /// , or is null. + public SourceTrigger(SourceProperties sourceRepository, IEnumerable sourceTriggerEvents, string name) + { + Argument.AssertNotNull(sourceRepository, nameof(sourceRepository)); + Argument.AssertNotNull(sourceTriggerEvents, nameof(sourceTriggerEvents)); + Argument.AssertNotNull(name, nameof(name)); + + SourceRepository = sourceRepository; + SourceTriggerEvents = sourceTriggerEvents.ToList(); + Name = name; + } + + /// Initializes a new instance of . + /// The properties that describes the source(code) for the task. + /// The source event corresponding to the trigger. + /// The current status of trigger. + /// The name of the trigger. + /// Keeps track of any properties unknown to the library. + internal SourceTrigger(SourceProperties sourceRepository, IList sourceTriggerEvents, ContainerRegistryTaskTriggerStatus? status, string name, IDictionary additionalBinaryDataProperties) + { + SourceRepository = sourceRepository; + SourceTriggerEvents = sourceTriggerEvents; + Status = status; + Name = name; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The properties that describes the source(code) for the task. + public SourceProperties SourceRepository { get; set; } + + /// The source event corresponding to the trigger. + public IList SourceTriggerEvents { get; } + + /// The current status of trigger. + public ContainerRegistryTaskTriggerStatus? Status { get; set; } + + /// The name of the trigger. + public string Name { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerDescriptor.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerDescriptor.Serialization.cs new file mode 100644 index 000000000000..e632b470b07b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerDescriptor.Serialization.cs @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The source trigger that caused a run. + public partial class SourceTriggerDescriptor : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SourceTriggerDescriptor PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSourceTriggerDescriptor(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SourceTriggerDescriptor)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(SourceTriggerDescriptor)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SourceTriggerDescriptor IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceTriggerDescriptor)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(EventType)) + { + writer.WritePropertyName("eventType"u8); + writer.WriteStringValue(EventType); + } + if (Optional.IsDefined(CommitId)) + { + writer.WritePropertyName("commitId"u8); + writer.WriteStringValue(CommitId); + } + if (Optional.IsDefined(PullRequestId)) + { + writer.WritePropertyName("pullRequestId"u8); + writer.WriteStringValue(PullRequestId); + } + if (Optional.IsDefined(RepositoryUri)) + { + writer.WritePropertyName("repositoryUrl"u8); + writer.WriteStringValue(RepositoryUri.AbsoluteUri); + } + if (Optional.IsDefined(BranchName)) + { + writer.WritePropertyName("branchName"u8); + writer.WriteStringValue(BranchName); + } + if (Optional.IsDefined(ProviderType)) + { + writer.WritePropertyName("providerType"u8); + writer.WriteStringValue(ProviderType); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SourceTriggerDescriptor IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SourceTriggerDescriptor JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceTriggerDescriptor)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSourceTriggerDescriptor(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SourceTriggerDescriptor DeserializeSourceTriggerDescriptor(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string eventType = default; + string commitId = default; + string pullRequestId = default; + Uri repositoryUri = default; + string branchName = default; + string providerType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("eventType"u8)) + { + eventType = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("commitId"u8)) + { + commitId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("pullRequestId"u8)) + { + pullRequestId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("repositoryUrl"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + repositoryUri = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (prop.NameEquals("branchName"u8)) + { + branchName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("providerType"u8)) + { + providerType = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SourceTriggerDescriptor( + id, + eventType, + commitId, + pullRequestId, + repositoryUri, + branchName, + providerType, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerDescriptor.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerDescriptor.cs new file mode 100644 index 000000000000..ba2b0d1d1074 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerDescriptor.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The source trigger that caused a run. + public partial class SourceTriggerDescriptor + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal SourceTriggerDescriptor() + { + } + + /// Initializes a new instance of . + /// The unique ID of the trigger. + /// The event type of the trigger. + /// The unique ID that identifies a commit. + /// The unique ID that identifies pull request. + /// The repository URL. + /// The branch name in the repository. + /// The source control provider type. + /// Keeps track of any properties unknown to the library. + internal SourceTriggerDescriptor(string id, string eventType, string commitId, string pullRequestId, Uri repositoryUri, string branchName, string providerType, IDictionary additionalBinaryDataProperties) + { + Id = id; + EventType = eventType; + CommitId = commitId; + PullRequestId = pullRequestId; + RepositoryUri = repositoryUri; + BranchName = branchName; + ProviderType = providerType; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique ID of the trigger. + public string Id { get; } + + /// The event type of the trigger. + public string EventType { get; } + + /// The unique ID that identifies a commit. + public string CommitId { get; } + + /// The unique ID that identifies pull request. + public string PullRequestId { get; } + + /// The repository URL. + public Uri RepositoryUri { get; } + + /// The branch name in the repository. + public string BranchName { get; } + + /// The source control provider type. + public string ProviderType { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerEvent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerEvent.cs new file mode 100644 index 000000000000..3c5184dacddd --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerEvent.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// + public readonly partial struct SourceTriggerEvent : IEquatable + { + private readonly string _value; + private const string CommitValue = "commit"; + private const string PullRequestValue = "pullrequest"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public SourceTriggerEvent(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Commit. + public static SourceTriggerEvent Commit { get; } = new SourceTriggerEvent(CommitValue); + + /// Gets the PullRequest. + public static SourceTriggerEvent PullRequest { get; } = new SourceTriggerEvent(PullRequestValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(SourceTriggerEvent left, SourceTriggerEvent right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(SourceTriggerEvent left, SourceTriggerEvent right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator SourceTriggerEvent(string value) => new SourceTriggerEvent(value); + + /// Converts a string to a . + /// The value. + public static implicit operator SourceTriggerEvent?(string value) => value == null ? null : new SourceTriggerEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SourceTriggerEvent other && Equals(other); + + /// + public bool Equals(SourceTriggerEvent other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerUpdateContent.Serialization.cs new file mode 100644 index 000000000000..f768967d4692 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerUpdateContent.Serialization.cs @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating a source based trigger. + public partial class SourceTriggerUpdateContent : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SourceTriggerUpdateContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SourceTriggerUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSourceTriggerUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SourceTriggerUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(SourceTriggerUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SourceTriggerUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceTriggerUpdateContent)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(SourceRepository)) + { + writer.WritePropertyName("sourceRepository"u8); + writer.WriteObjectValue(SourceRepository, options); + } + if (Optional.IsCollectionDefined(SourceTriggerEvents)) + { + writer.WritePropertyName("sourceTriggerEvents"u8); + writer.WriteStartArray(); + foreach (SourceTriggerEvent item in SourceTriggerEvents) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SourceTriggerUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SourceTriggerUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceTriggerUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSourceTriggerUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SourceTriggerUpdateContent DeserializeSourceTriggerUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SourceUpdateContent sourceRepository = default; + IList sourceTriggerEvents = default; + ContainerRegistryTaskTriggerStatus? status = default; + string name = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("sourceRepository"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceRepository = SourceUpdateContent.DeserializeSourceUpdateContent(prop.Value, options); + continue; + } + if (prop.NameEquals("sourceTriggerEvents"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new SourceTriggerEvent(item.GetString())); + } + sourceTriggerEvents = array; + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ContainerRegistryTaskTriggerStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SourceTriggerUpdateContent(sourceRepository, sourceTriggerEvents ?? new ChangeTrackingList(), status, name, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerUpdateContent.cs new file mode 100644 index 000000000000..0ed020185fc3 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceTriggerUpdateContent.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating a source based trigger. + public partial class SourceTriggerUpdateContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the trigger. + /// is null. + public SourceTriggerUpdateContent(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + SourceTriggerEvents = new ChangeTrackingList(); + Name = name; + } + + /// Initializes a new instance of . + /// The properties that describes the source(code) for the task. + /// The source event corresponding to the trigger. + /// The current status of trigger. + /// The name of the trigger. + /// Keeps track of any properties unknown to the library. + internal SourceTriggerUpdateContent(SourceUpdateContent sourceRepository, IList sourceTriggerEvents, ContainerRegistryTaskTriggerStatus? status, string name, IDictionary additionalBinaryDataProperties) + { + SourceRepository = sourceRepository; + SourceTriggerEvents = sourceTriggerEvents; + Status = status; + Name = name; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The properties that describes the source(code) for the task. + public SourceUpdateContent SourceRepository { get; set; } + + /// The source event corresponding to the trigger. + public IList SourceTriggerEvents { get; } + + /// The current status of trigger. + public ContainerRegistryTaskTriggerStatus? Status { get; set; } + + /// The name of the trigger. + public string Name { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUpdateContent.Serialization.cs new file mode 100644 index 000000000000..4186e90ed8df --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUpdateContent.Serialization.cs @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating the source code repository. + public partial class SourceUpdateContent : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SourceUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSourceUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SourceUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(SourceUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SourceUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceUpdateContent)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(SourceControlType)) + { + writer.WritePropertyName("sourceControlType"u8); + writer.WriteStringValue(SourceControlType.Value.ToString()); + } + if (Optional.IsDefined(RepositoryUri)) + { + writer.WritePropertyName("repositoryUrl"u8); + writer.WriteStringValue(RepositoryUri); + } + if (Optional.IsDefined(Branch)) + { + writer.WritePropertyName("branch"u8); + writer.WriteStringValue(Branch); + } + if (Optional.IsDefined(SourceControlAuthProperties)) + { + writer.WritePropertyName("sourceControlAuthProperties"u8); + writer.WriteObjectValue(SourceControlAuthProperties, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SourceUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SourceUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSourceUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SourceUpdateContent DeserializeSourceUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SourceControlType? sourceControlType = default; + string repositoryUri = default; + string branch = default; + AuthInfoUpdateContent sourceControlAuthProperties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("sourceControlType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceControlType = new SourceControlType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("repositoryUrl"u8)) + { + repositoryUri = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("branch"u8)) + { + branch = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("sourceControlAuthProperties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceControlAuthProperties = AuthInfoUpdateContent.DeserializeAuthInfoUpdateContent(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SourceUpdateContent(sourceControlType, repositoryUri, branch, sourceControlAuthProperties, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUpdateContent.cs new file mode 100644 index 000000000000..9219632a0cb6 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUpdateContent.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating the source code repository. + public partial class SourceUpdateContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SourceUpdateContent() + { + } + + /// Initializes a new instance of . + /// The type of source control service. + /// The full URL to the source code repository. + /// The branch name of the source code. + /// + /// The authorization properties for accessing the source code repository and to set up + /// webhooks for notifications. + /// + /// Keeps track of any properties unknown to the library. + internal SourceUpdateContent(SourceControlType? sourceControlType, string repositoryUri, string branch, AuthInfoUpdateContent sourceControlAuthProperties, IDictionary additionalBinaryDataProperties) + { + SourceControlType = sourceControlType; + RepositoryUri = repositoryUri; + Branch = branch; + SourceControlAuthProperties = sourceControlAuthProperties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of source control service. + public SourceControlType? SourceControlType { get; set; } + + /// The full URL to the source code repository. + public string RepositoryUri { get; set; } + + /// The branch name of the source code. + public string Branch { get; set; } + + /// + /// The authorization properties for accessing the source code repository and to set up + /// webhooks for notifications. + /// + public AuthInfoUpdateContent SourceControlAuthProperties { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUploadResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUploadResult.Serialization.cs new file mode 100644 index 000000000000..40d1fd0cae73 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUploadResult.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a response to source upload request. + public partial class SourceUploadResult : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SourceUploadResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSourceUploadResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SourceUploadResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(SourceUploadResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SourceUploadResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static SourceUploadResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSourceUploadResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceUploadResult)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(UploadUri)) + { + writer.WritePropertyName("uploadUrl"u8); + writer.WriteStringValue(UploadUri); + } + if (Optional.IsDefined(RelativePath)) + { + writer.WritePropertyName("relativePath"u8); + writer.WriteStringValue(RelativePath); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SourceUploadResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SourceUploadResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceUploadResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSourceUploadResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SourceUploadResult DeserializeSourceUploadResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string uploadUri = default; + string relativePath = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("uploadUrl"u8)) + { + uploadUri = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("relativePath"u8)) + { + relativePath = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SourceUploadResult(uploadUri, relativePath, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUploadResult.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUploadResult.cs new file mode 100644 index 000000000000..8c5e57b11c17 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/SourceUploadResult.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a response to source upload request. + public partial class SourceUploadResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal SourceUploadResult() + { + } + + /// Initializes a new instance of . + /// The URL where the client can upload the source. + /// The relative path to the source. This is used to submit the subsequent queue build request. + /// Keeps track of any properties unknown to the library. + internal SourceUploadResult(string uploadUri, string relativePath, IDictionary additionalBinaryDataProperties) + { + UploadUri = uploadUri; + RelativePath = relativePath; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The URL where the client can upload the source. + public string UploadUri { get; } + + /// The relative path to the source. This is used to submit the subsequent queue build request. + public string RelativePath { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/StepType.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/StepType.cs new file mode 100644 index 000000000000..f7962887869c --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/StepType.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The type of the step. + internal readonly partial struct StepType : IEquatable + { + private readonly string _value; + private const string DockerValue = "Docker"; + private const string FileTaskValue = "FileTask"; + private const string EncodedTaskValue = "EncodedTask"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public StepType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Docker. + public static StepType Docker { get; } = new StepType(DockerValue); + + /// Gets the FileTask. + public static StepType FileTask { get; } = new StepType(FileTaskValue); + + /// Gets the EncodedTask. + public static StepType EncodedTask { get; } = new StepType(EncodedTaskValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(StepType left, StepType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(StepType left, StepType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator StepType(string value) => new StepType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator StepType?(string value) => value == null ? null : new StepType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StepType other && Equals(other); + + /// + public bool Equals(StepType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskListResult.Serialization.cs new file mode 100644 index 000000000000..bf32844def18 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskListResult.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The collection of tasks. + internal partial class TaskListResult : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaskListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static TaskListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTaskListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskListResult)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (TaskData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaskListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskListResult DeserializeTaskListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + string nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TaskData.DeserializeTaskData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + nextLink = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskListResult(value ?? new ChangeTrackingList(), nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskListResult.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskListResult.cs new file mode 100644 index 000000000000..2cd5df2a1d90 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The collection of tasks. + internal partial class TaskListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal TaskListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The collection value. + /// The URI that can be used to request the next set of paged results. + /// Keeps track of any properties unknown to the library. + internal TaskListResult(IList value, string nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The collection value. + public IList Value { get; } + + /// The URI that can be used to request the next set of paged results. + public string NextLink { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPatch.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPatch.Serialization.cs new file mode 100644 index 000000000000..72ba01e57cbc --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPatch.Serialization.cs @@ -0,0 +1,211 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for updating a task. + public partial class TaskPatch : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaskPatch PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskPatch)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskPatch)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TaskPatch taskPatch) + { + if (taskPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(taskPatch, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskPatch)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + writer.WriteObjectValue(Identity, options); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaskPatch JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskPatch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskPatch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskPatch DeserializeTaskPatch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IdentityProperties identity = default; + TaskPropertiesUpdateParameters properties = default; + IDictionary tags = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("identity"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = IdentityProperties.DeserializeIdentityProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = TaskPropertiesUpdateParameters.DeserializeTaskPropertiesUpdateParameters(prop.Value, options); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskPatch(identity, properties, tags ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPatch.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPatch.cs new file mode 100644 index 000000000000..e0c59b4d5c27 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPatch.cs @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for updating a task. + public partial class TaskPatch + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TaskPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Identity for the resource. + /// The properties for updating a task. + /// The ARM resource tags. + /// Keeps track of any properties unknown to the library. + internal TaskPatch(IdentityProperties identity, TaskPropertiesUpdateParameters properties, IDictionary tags, IDictionary additionalBinaryDataProperties) + { + Identity = identity; + Properties = properties; + Tags = tags; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Identity for the resource. + public IdentityProperties Identity { get; set; } + + /// The properties for updating a task. + internal TaskPropertiesUpdateParameters Properties { get; set; } + + /// The ARM resource tags. + public IDictionary Tags { get; } + + /// The current status of task. + public ContainerRegistryTaskStatus? Status + { + get + { + return Properties is null ? default : Properties.Status; + } + set + { + if (Properties is null) + { + Properties = new TaskPropertiesUpdateParameters(); + } + Properties.Status = value.Value; + } + } + + /// The platform properties against which the run has to happen. + public PlatformUpdateContent Platform + { + get + { + return Properties is null ? default : Properties.Platform; + } + set + { + if (Properties is null) + { + Properties = new TaskPropertiesUpdateParameters(); + } + Properties.Platform = value; + } + } + + /// The dedicated agent pool for the task. + public string AgentPoolName + { + get + { + return Properties is null ? default : Properties.AgentPoolName; + } + set + { + if (Properties is null) + { + Properties = new TaskPropertiesUpdateParameters(); + } + Properties.AgentPoolName = value; + } + } + + /// Run timeout in seconds. + public int? TimeoutInSeconds + { + get + { + return Properties is null ? default : Properties.TimeoutInSeconds; + } + set + { + if (Properties is null) + { + Properties = new TaskPropertiesUpdateParameters(); + } + Properties.TimeoutInSeconds = value.Value; + } + } + + /// The properties for updating a task step. + public TaskStepUpdateContent Step + { + get + { + return Properties is null ? default : Properties.Step; + } + set + { + if (Properties is null) + { + Properties = new TaskPropertiesUpdateParameters(); + } + Properties.Step = value; + } + } + + /// The properties for updating trigger properties. + public TriggerUpdateContent Trigger + { + get + { + return Properties is null ? default : Properties.Trigger; + } + set + { + if (Properties is null) + { + Properties = new TaskPropertiesUpdateParameters(); + } + Properties.Trigger = value; + } + } + + /// The parameters that describes a set of credentials that will be used when this run is invoked. + public ContainerRegistryTaskCredentials Credentials + { + get + { + return Properties is null ? default : Properties.Credentials; + } + set + { + if (Properties is null) + { + Properties = new TaskPropertiesUpdateParameters(); + } + Properties.Credentials = value; + } + } + + /// The template that describes the repository and tag information for run log artifact. + public string LogTemplate + { + get + { + return Properties is null ? default : Properties.LogTemplate; + } + set + { + if (Properties is null) + { + Properties = new TaskPropertiesUpdateParameters(); + } + Properties.LogTemplate = value; + } + } + + /// The CPU configuration in terms of number of cores required for the run. + public int? AgentCpu + { + get + { + return Properties is null ? default : Properties.AgentCpu; + } + set + { + if (Properties is null) + { + Properties = new TaskPropertiesUpdateParameters(); + } + Properties.AgentCpu = value.Value; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskProperties.Serialization.cs new file mode 100644 index 000000000000..89a79a0915ff --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskProperties.Serialization.cs @@ -0,0 +1,315 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a task. + internal partial class TaskProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaskProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("creationDate"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (Optional.IsDefined(Platform)) + { + writer.WritePropertyName("platform"u8); + writer.WriteObjectValue(Platform, options); + } + if (Optional.IsDefined(AgentConfiguration)) + { + writer.WritePropertyName("agentConfiguration"u8); + writer.WriteObjectValue(AgentConfiguration, options); + } + if (Optional.IsDefined(AgentPoolName)) + { + writer.WritePropertyName("agentPoolName"u8); + writer.WriteStringValue(AgentPoolName); + } + if (Optional.IsDefined(TimeoutInSeconds)) + { + writer.WritePropertyName("timeout"u8); + writer.WriteNumberValue(TimeoutInSeconds.Value); + } + if (Optional.IsDefined(Step)) + { + writer.WritePropertyName("step"u8); + writer.WriteObjectValue(Step, options); + } + if (Optional.IsDefined(Trigger)) + { + writer.WritePropertyName("trigger"u8); + writer.WriteObjectValue(Trigger, options); + } + if (Optional.IsDefined(Credentials)) + { + writer.WritePropertyName("credentials"u8); + writer.WriteObjectValue(Credentials, options); + } + if (Optional.IsDefined(LogTemplate)) + { + writer.WritePropertyName("logTemplate"u8); + writer.WriteStringValue(LogTemplate); + } + if (Optional.IsDefined(IsSystemTask)) + { + writer.WritePropertyName("isSystemTask"u8); + writer.WriteBooleanValue(IsSystemTask.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaskProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskProperties DeserializeTaskProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ContainerRegistryTaskProvisioningState? provisioningState = default; + DateTimeOffset? createdOn = default; + ContainerRegistryTaskStatus? status = default; + PlatformProperties platform = default; + AgentProperties agentConfiguration = default; + string agentPoolName = default; + int? timeoutInSeconds = default; + TaskStepProperties step = default; + TriggerProperties trigger = default; + ContainerRegistryTaskCredentials credentials = default; + string logTemplate = default; + bool? isSystemTask = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ContainerRegistryTaskProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("creationDate"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ContainerRegistryTaskStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("platform"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + platform = PlatformProperties.DeserializePlatformProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("agentConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentConfiguration = AgentProperties.DeserializeAgentProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("agentPoolName"u8)) + { + agentPoolName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("timeout"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeoutInSeconds = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("step"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + step = TaskStepProperties.DeserializeTaskStepProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("trigger"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + trigger = TriggerProperties.DeserializeTriggerProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("credentials"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + credentials = ContainerRegistryTaskCredentials.DeserializeContainerRegistryTaskCredentials(prop.Value, options); + continue; + } + if (prop.NameEquals("logTemplate"u8)) + { + logTemplate = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("isSystemTask"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isSystemTask = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskProperties( + provisioningState, + createdOn, + status, + platform, + agentConfiguration, + agentPoolName, + timeoutInSeconds, + step, + trigger, + credentials, + logTemplate, + isSystemTask, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskProperties.cs new file mode 100644 index 000000000000..11f8bbaf7642 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskProperties.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a task. + internal partial class TaskProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TaskProperties() + { + } + + /// Initializes a new instance of . + /// The provisioning state of the task. + /// The creation date of task. + /// The current status of task. + /// The platform properties against which the run has to happen. + /// The machine configuration of the run agent. + /// The dedicated agent pool for the task. + /// Run timeout in seconds. + /// The properties of a task step. + /// The properties that describe all triggers for the task. + /// The properties that describes a set of credentials that will be used when this run is invoked. + /// The template that describes the repository and tag information for run log artifact. + /// The value of this property indicates whether the task resource is system task or not. + /// Keeps track of any properties unknown to the library. + internal TaskProperties(ContainerRegistryTaskProvisioningState? provisioningState, DateTimeOffset? createdOn, ContainerRegistryTaskStatus? status, PlatformProperties platform, AgentProperties agentConfiguration, string agentPoolName, int? timeoutInSeconds, TaskStepProperties step, TriggerProperties trigger, ContainerRegistryTaskCredentials credentials, string logTemplate, bool? isSystemTask, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + CreatedOn = createdOn; + Status = status; + Platform = platform; + AgentConfiguration = agentConfiguration; + AgentPoolName = agentPoolName; + TimeoutInSeconds = timeoutInSeconds; + Step = step; + Trigger = trigger; + Credentials = credentials; + LogTemplate = logTemplate; + IsSystemTask = isSystemTask; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The provisioning state of the task. + public ContainerRegistryTaskProvisioningState? ProvisioningState { get; } + + /// The creation date of task. + public DateTimeOffset? CreatedOn { get; } + + /// The current status of task. + public ContainerRegistryTaskStatus? Status { get; set; } + + /// The platform properties against which the run has to happen. + public PlatformProperties Platform { get; set; } + + /// The machine configuration of the run agent. + internal AgentProperties AgentConfiguration { get; set; } + + /// The dedicated agent pool for the task. + public string AgentPoolName { get; set; } + + /// Run timeout in seconds. + public int? TimeoutInSeconds { get; set; } + + /// The properties of a task step. + public TaskStepProperties Step { get; set; } + + /// The properties that describe all triggers for the task. + public TriggerProperties Trigger { get; set; } + + /// The properties that describes a set of credentials that will be used when this run is invoked. + public ContainerRegistryTaskCredentials Credentials { get; set; } + + /// The template that describes the repository and tag information for run log artifact. + public string LogTemplate { get; set; } + + /// The value of this property indicates whether the task resource is system task or not. + public bool? IsSystemTask { get; set; } + + /// The CPU configuration in terms of number of cores required for the run. + public int? AgentCpu + { + get + { + return AgentConfiguration is null ? default : AgentConfiguration.Cpu; + } + set + { + if (AgentConfiguration is null) + { + AgentConfiguration = new AgentProperties(); + } + AgentConfiguration.Cpu = value; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPropertiesUpdateParameters.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPropertiesUpdateParameters.Serialization.cs new file mode 100644 index 000000000000..9baed380aec4 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPropertiesUpdateParameters.Serialization.cs @@ -0,0 +1,267 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating a task. + internal partial class TaskPropertiesUpdateParameters : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaskPropertiesUpdateParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskPropertiesUpdateParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskPropertiesUpdateParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskPropertiesUpdateParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskPropertiesUpdateParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskPropertiesUpdateParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (Optional.IsDefined(Platform)) + { + writer.WritePropertyName("platform"u8); + writer.WriteObjectValue(Platform, options); + } + if (Optional.IsDefined(AgentConfiguration)) + { + writer.WritePropertyName("agentConfiguration"u8); + writer.WriteObjectValue(AgentConfiguration, options); + } + if (Optional.IsDefined(AgentPoolName)) + { + writer.WritePropertyName("agentPoolName"u8); + writer.WriteStringValue(AgentPoolName); + } + if (Optional.IsDefined(TimeoutInSeconds)) + { + writer.WritePropertyName("timeout"u8); + writer.WriteNumberValue(TimeoutInSeconds.Value); + } + if (Optional.IsDefined(Step)) + { + writer.WritePropertyName("step"u8); + writer.WriteObjectValue(Step, options); + } + if (Optional.IsDefined(Trigger)) + { + writer.WritePropertyName("trigger"u8); + writer.WriteObjectValue(Trigger, options); + } + if (Optional.IsDefined(Credentials)) + { + writer.WritePropertyName("credentials"u8); + writer.WriteObjectValue(Credentials, options); + } + if (Optional.IsDefined(LogTemplate)) + { + writer.WritePropertyName("logTemplate"u8); + writer.WriteStringValue(LogTemplate); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskPropertiesUpdateParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaskPropertiesUpdateParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskPropertiesUpdateParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskPropertiesUpdateParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskPropertiesUpdateParameters DeserializeTaskPropertiesUpdateParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ContainerRegistryTaskStatus? status = default; + PlatformUpdateContent platform = default; + AgentProperties agentConfiguration = default; + string agentPoolName = default; + int? timeoutInSeconds = default; + TaskStepUpdateContent step = default; + TriggerUpdateContent trigger = default; + ContainerRegistryTaskCredentials credentials = default; + string logTemplate = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ContainerRegistryTaskStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("platform"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + platform = PlatformUpdateContent.DeserializePlatformUpdateContent(prop.Value, options); + continue; + } + if (prop.NameEquals("agentConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentConfiguration = AgentProperties.DeserializeAgentProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("agentPoolName"u8)) + { + agentPoolName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("timeout"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeoutInSeconds = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("step"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + step = TaskStepUpdateContent.DeserializeTaskStepUpdateContent(prop.Value, options); + continue; + } + if (prop.NameEquals("trigger"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + trigger = TriggerUpdateContent.DeserializeTriggerUpdateContent(prop.Value, options); + continue; + } + if (prop.NameEquals("credentials"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + credentials = ContainerRegistryTaskCredentials.DeserializeContainerRegistryTaskCredentials(prop.Value, options); + continue; + } + if (prop.NameEquals("logTemplate"u8)) + { + logTemplate = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskPropertiesUpdateParameters( + status, + platform, + agentConfiguration, + agentPoolName, + timeoutInSeconds, + step, + trigger, + credentials, + logTemplate, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPropertiesUpdateParameters.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPropertiesUpdateParameters.cs new file mode 100644 index 000000000000..c60005bb70c1 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskPropertiesUpdateParameters.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating a task. + internal partial class TaskPropertiesUpdateParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TaskPropertiesUpdateParameters() + { + } + + /// Initializes a new instance of . + /// The current status of task. + /// The platform properties against which the run has to happen. + /// The machine configuration of the run agent. + /// The dedicated agent pool for the task. + /// Run timeout in seconds. + /// The properties for updating a task step. + /// The properties for updating trigger properties. + /// The parameters that describes a set of credentials that will be used when this run is invoked. + /// The template that describes the repository and tag information for run log artifact. + /// Keeps track of any properties unknown to the library. + internal TaskPropertiesUpdateParameters(ContainerRegistryTaskStatus? status, PlatformUpdateContent platform, AgentProperties agentConfiguration, string agentPoolName, int? timeoutInSeconds, TaskStepUpdateContent step, TriggerUpdateContent trigger, ContainerRegistryTaskCredentials credentials, string logTemplate, IDictionary additionalBinaryDataProperties) + { + Status = status; + Platform = platform; + AgentConfiguration = agentConfiguration; + AgentPoolName = agentPoolName; + TimeoutInSeconds = timeoutInSeconds; + Step = step; + Trigger = trigger; + Credentials = credentials; + LogTemplate = logTemplate; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The current status of task. + public ContainerRegistryTaskStatus? Status { get; set; } + + /// The platform properties against which the run has to happen. + public PlatformUpdateContent Platform { get; set; } + + /// The machine configuration of the run agent. + internal AgentProperties AgentConfiguration { get; set; } + + /// The dedicated agent pool for the task. + public string AgentPoolName { get; set; } + + /// Run timeout in seconds. + public int? TimeoutInSeconds { get; set; } + + /// The properties for updating a task step. + public TaskStepUpdateContent Step { get; set; } + + /// The properties for updating trigger properties. + public TriggerUpdateContent Trigger { get; set; } + + /// The parameters that describes a set of credentials that will be used when this run is invoked. + public ContainerRegistryTaskCredentials Credentials { get; set; } + + /// The template that describes the repository and tag information for run log artifact. + public string LogTemplate { get; set; } + + /// The CPU configuration in terms of number of cores required for the run. + public int? AgentCpu + { + get + { + return AgentConfiguration is null ? default : AgentConfiguration.Cpu; + } + set + { + if (AgentConfiguration is null) + { + AgentConfiguration = new AgentProperties(); + } + AgentConfiguration.Cpu = value; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunContent.Serialization.cs new file mode 100644 index 000000000000..87f04f91010c --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunContent.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for a task run request. + public partial class TaskRunContent : RunContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TaskRunContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override RunContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskRunContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskRunContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskRunContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskRunContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TaskRunContent)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("taskId"u8); + writer.WriteStringValue(TaskId); + if (Optional.IsDefined(OverrideTaskStepProperties)) + { + writer.WritePropertyName("overrideTaskStepProperties"u8); + writer.WriteObjectValue(OverrideTaskStepProperties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskRunContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TaskRunContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override RunContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskRunContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskRunContent DeserializeTaskRunContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "TaskRunRequest"; + bool? isArchiveEnabled = default; + string agentPoolName = default; + string logTemplate = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string taskId = default; + OverrideTaskStepProperties overrideTaskStepProperties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("isArchiveEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isArchiveEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("agentPoolName"u8)) + { + agentPoolName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logTemplate"u8)) + { + logTemplate = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("taskId"u8)) + { + taskId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("overrideTaskStepProperties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + overrideTaskStepProperties = OverrideTaskStepProperties.DeserializeOverrideTaskStepProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskRunContent( + @type, + isArchiveEnabled, + agentPoolName, + logTemplate, + additionalBinaryDataProperties, + taskId, + overrideTaskStepProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunContent.cs new file mode 100644 index 000000000000..a848e27363fa --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunContent.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for a task run request. + public partial class TaskRunContent : RunContent + { + /// Initializes a new instance of . + /// The resource ID of task against which run has to be queued. + /// is null. + public TaskRunContent(string taskId) : base("TaskRunRequest") + { + Argument.AssertNotNull(taskId, nameof(taskId)); + + TaskId = taskId; + } + + /// Initializes a new instance of . + /// The type of the run request. + /// The value that indicates whether archiving is enabled for the run or not. + /// The dedicated agent pool for the run. + /// The template that describes the repository and tag information for run log artifact. + /// Keeps track of any properties unknown to the library. + /// The resource ID of task against which run has to be queued. + /// Set of overridable parameters that can be passed when running a Task. + internal TaskRunContent(string @type, bool? isArchiveEnabled, string agentPoolName, string logTemplate, IDictionary additionalBinaryDataProperties, string taskId, OverrideTaskStepProperties overrideTaskStepProperties) : base(@type, isArchiveEnabled, agentPoolName, logTemplate, additionalBinaryDataProperties) + { + TaskId = taskId; + OverrideTaskStepProperties = overrideTaskStepProperties; + } + + /// The resource ID of task against which run has to be queued. + public string TaskId { get; set; } + + /// Set of overridable parameters that can be passed when running a Task. + public OverrideTaskStepProperties OverrideTaskStepProperties { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunListResult.Serialization.cs new file mode 100644 index 000000000000..45e6ffb44ef0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunListResult.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The collection of task runs. + internal partial class TaskRunListResult : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaskRunListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskRunListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskRunListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskRunListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskRunListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static TaskRunListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTaskRunListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunListResult)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (TaskRunData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskRunListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaskRunListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskRunListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskRunListResult DeserializeTaskRunListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + string nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TaskRunData.DeserializeTaskRunData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + nextLink = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskRunListResult(value ?? new ChangeTrackingList(), nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunListResult.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunListResult.cs new file mode 100644 index 000000000000..f6389ddf9136 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The collection of task runs. + internal partial class TaskRunListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal TaskRunListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The collection value. + /// The URI that can be used to request the next set of paged results. + /// Keeps track of any properties unknown to the library. + internal TaskRunListResult(IList value, string nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The collection value. + public IList Value { get; } + + /// The URI that can be used to request the next set of paged results. + public string NextLink { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPatch.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPatch.Serialization.cs new file mode 100644 index 000000000000..e1704f7c0bb3 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPatch.Serialization.cs @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for updating a task run. + public partial class TaskRunPatch : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaskRunPatch PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskRunPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskRunPatch)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskRunPatch)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskRunPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TaskRunPatch taskRunPatch) + { + if (taskRunPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(taskRunPatch, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunPatch)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + writer.WriteObjectValue(Identity, options); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskRunPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaskRunPatch JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunPatch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskRunPatch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskRunPatch DeserializeTaskRunPatch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IdentityProperties identity = default; + TaskRunPropertiesUpdateParameters properties = default; + string location = default; + IDictionary tags = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("identity"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = IdentityProperties.DeserializeIdentityProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = TaskRunPropertiesUpdateParameters.DeserializeTaskRunPropertiesUpdateParameters(prop.Value, options); + continue; + } + if (prop.NameEquals("location"u8)) + { + location = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskRunPatch(identity, properties, location, tags ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPatch.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPatch.cs new file mode 100644 index 000000000000..3e6cc25cf530 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPatch.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The parameters for updating a task run. + public partial class TaskRunPatch + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TaskRunPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Identity for the resource. + /// The properties for updating a task run. + /// The location of the resource. + /// The ARM resource tags. + /// Keeps track of any properties unknown to the library. + internal TaskRunPatch(IdentityProperties identity, TaskRunPropertiesUpdateParameters properties, string location, IDictionary tags, IDictionary additionalBinaryDataProperties) + { + Identity = identity; + Properties = properties; + Location = location; + Tags = tags; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Identity for the resource. + public IdentityProperties Identity { get; set; } + + /// The properties for updating a task run. + internal TaskRunPropertiesUpdateParameters Properties { get; set; } + + /// The location of the resource. + public string Location { get; set; } + + /// The ARM resource tags. + public IDictionary Tags { get; } + + /// The request (parameters) for the new run. + public RunContent RunRequest + { + get + { + return Properties is null ? default : Properties.RunRequest; + } + set + { + if (Properties is null) + { + Properties = new TaskRunPropertiesUpdateParameters(); + } + Properties.RunRequest = value; + } + } + + /// How the run should be forced to rerun even if the run request configuration has not changed. + public string ForceUpdateTag + { + get + { + return Properties is null ? default : Properties.ForceUpdateTag; + } + set + { + if (Properties is null) + { + Properties = new TaskRunPropertiesUpdateParameters(); + } + Properties.ForceUpdateTag = value; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunProperties.Serialization.cs new file mode 100644 index 000000000000..3ce6b5886db4 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunProperties.Serialization.cs @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of task run. + internal partial class TaskRunProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaskRunProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskRunProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskRunProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskRunProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskRunProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(RunRequest)) + { + writer.WritePropertyName("runRequest"u8); + writer.WriteObjectValue(RunRequest, options); + } + if (options.Format != "W" && Optional.IsDefined(RunResult)) + { + writer.WritePropertyName("runResult"u8); + writer.WriteObjectValue(RunResult, options); + } + if (Optional.IsDefined(ForceUpdateTag)) + { + writer.WritePropertyName("forceUpdateTag"u8); + writer.WriteStringValue(ForceUpdateTag); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskRunProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaskRunProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskRunProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskRunProperties DeserializeTaskRunProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ContainerRegistryTaskProvisioningState? provisioningState = default; + RunContent runRequest = default; + RunData runResult = default; + string forceUpdateTag = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ContainerRegistryTaskProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("runRequest"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + runRequest = RunContent.DeserializeRunContent(prop.Value, options); + continue; + } + if (prop.NameEquals("runResult"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + runResult = RunData.DeserializeRunData(prop.Value, options); + continue; + } + if (prop.NameEquals("forceUpdateTag"u8)) + { + forceUpdateTag = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskRunProperties(provisioningState, runRequest, runResult, forceUpdateTag, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunProperties.cs new file mode 100644 index 000000000000..596119d0627c --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunProperties.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of task run. + internal partial class TaskRunProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TaskRunProperties() + { + } + + /// Initializes a new instance of . + /// The provisioning state of this task run. + /// The request (parameters) for the run. + /// The result of this task run. + /// How the run should be forced to rerun even if the run request configuration has not changed. + /// Keeps track of any properties unknown to the library. + internal TaskRunProperties(ContainerRegistryTaskProvisioningState? provisioningState, RunContent runRequest, RunData runResult, string forceUpdateTag, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + RunRequest = runRequest; + RunResult = runResult; + ForceUpdateTag = forceUpdateTag; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The provisioning state of this task run. + public ContainerRegistryTaskProvisioningState? ProvisioningState { get; } + + /// The request (parameters) for the run. + public RunContent RunRequest { get; set; } + + /// The result of this task run. + public RunData RunResult { get; } + + /// How the run should be forced to rerun even if the run request configuration has not changed. + public string ForceUpdateTag { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPropertiesUpdateParameters.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPropertiesUpdateParameters.Serialization.cs new file mode 100644 index 000000000000..5746b0c45d02 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPropertiesUpdateParameters.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a task run update parameters. + internal partial class TaskRunPropertiesUpdateParameters : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaskRunPropertiesUpdateParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskRunPropertiesUpdateParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskRunPropertiesUpdateParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskRunPropertiesUpdateParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskRunPropertiesUpdateParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunPropertiesUpdateParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(RunRequest)) + { + writer.WritePropertyName("runRequest"u8); + writer.WriteObjectValue(RunRequest, options); + } + if (Optional.IsDefined(ForceUpdateTag)) + { + writer.WritePropertyName("forceUpdateTag"u8); + writer.WriteStringValue(ForceUpdateTag); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskRunPropertiesUpdateParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaskRunPropertiesUpdateParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunPropertiesUpdateParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskRunPropertiesUpdateParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskRunPropertiesUpdateParameters DeserializeTaskRunPropertiesUpdateParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunContent runRequest = default; + string forceUpdateTag = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("runRequest"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + runRequest = RunContent.DeserializeRunContent(prop.Value, options); + continue; + } + if (prop.NameEquals("forceUpdateTag"u8)) + { + forceUpdateTag = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskRunPropertiesUpdateParameters(runRequest, forceUpdateTag, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPropertiesUpdateParameters.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPropertiesUpdateParameters.cs new file mode 100644 index 000000000000..41c24a69958e --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskRunPropertiesUpdateParameters.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a task run update parameters. + internal partial class TaskRunPropertiesUpdateParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TaskRunPropertiesUpdateParameters() + { + } + + /// Initializes a new instance of . + /// The request (parameters) for the new run. + /// How the run should be forced to rerun even if the run request configuration has not changed. + /// Keeps track of any properties unknown to the library. + internal TaskRunPropertiesUpdateParameters(RunContent runRequest, string forceUpdateTag, IDictionary additionalBinaryDataProperties) + { + RunRequest = runRequest; + ForceUpdateTag = forceUpdateTag; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The request (parameters) for the new run. + public RunContent RunRequest { get; set; } + + /// How the run should be forced to rerun even if the run request configuration has not changed. + public string ForceUpdateTag { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepProperties.Serialization.cs new file mode 100644 index 000000000000..437191df6956 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepProperties.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// + /// Base properties for any task step. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + [PersistableModelProxy(typeof(UnknownTaskStepProperties))] + public abstract partial class TaskStepProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TaskStepProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaskStepProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskStepProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskStepProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskStepProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskStepProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskStepProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && Optional.IsCollectionDefined(BaseImageDependencies)) + { + writer.WritePropertyName("baseImageDependencies"u8); + writer.WriteStartArray(); + foreach (BaseImageDependency item in BaseImageDependencies) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ContextPath)) + { + writer.WritePropertyName("contextPath"u8); + writer.WriteStringValue(ContextPath); + } + if (Optional.IsDefined(ContextAccessToken)) + { + writer.WritePropertyName("contextAccessToken"u8); + writer.WriteStringValue(ContextAccessToken); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskStepProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaskStepProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskStepProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskStepProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskStepProperties DeserializeTaskStepProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Docker": + return DockerBuildStep.DeserializeDockerBuildStep(element, options); + case "FileTask": + return FileTaskStep.DeserializeFileTaskStep(element, options); + case "EncodedTask": + return EncodedTaskStep.DeserializeEncodedTaskStep(element, options); + } + } + return UnknownTaskStepProperties.DeserializeUnknownTaskStepProperties(element, options); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepProperties.cs new file mode 100644 index 000000000000..c855724c4aad --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepProperties.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// + /// Base properties for any task step. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + public abstract partial class TaskStepProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of the step. + private protected TaskStepProperties(StepType @type) + { + Type = @type; + BaseImageDependencies = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The type of the step. + /// List of base image dependencies for a step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Keeps track of any properties unknown to the library. + internal TaskStepProperties(StepType @type, IReadOnlyList baseImageDependencies, string contextPath, string contextAccessToken, IDictionary additionalBinaryDataProperties) + { + Type = @type; + BaseImageDependencies = baseImageDependencies; + ContextPath = contextPath; + ContextAccessToken = contextAccessToken; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of the step. + internal StepType Type { get; set; } + + /// List of base image dependencies for a step. + public IReadOnlyList BaseImageDependencies { get; } + + /// The URL(absolute or relative) of the source context for the task step. + public string ContextPath { get; set; } + + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + public string ContextAccessToken { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepUpdateContent.Serialization.cs new file mode 100644 index 000000000000..8b7761e0cb5a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepUpdateContent.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// + /// Base properties for updating any task step. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + [PersistableModelProxy(typeof(UnknownTaskStepUpdateContent))] + public abstract partial class TaskStepUpdateContent : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TaskStepUpdateContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaskStepUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskStepUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskStepUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskStepUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskStepUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskStepUpdateContent)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsDefined(ContextPath)) + { + writer.WritePropertyName("contextPath"u8); + writer.WriteStringValue(ContextPath); + } + if (Optional.IsDefined(ContextAccessToken)) + { + writer.WritePropertyName("contextAccessToken"u8); + writer.WriteStringValue(ContextAccessToken); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskStepUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaskStepUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskStepUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskStepUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskStepUpdateContent DeserializeTaskStepUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Docker": + return DockerBuildStepUpdateContent.DeserializeDockerBuildStepUpdateContent(element, options); + case "FileTask": + return FileTaskStepUpdateContent.DeserializeFileTaskStepUpdateContent(element, options); + case "EncodedTask": + return EncodedTaskStepUpdateContent.DeserializeEncodedTaskStepUpdateContent(element, options); + } + } + return UnknownTaskStepUpdateContent.DeserializeUnknownTaskStepUpdateContent(element, options); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepUpdateContent.cs new file mode 100644 index 000000000000..b17da21defef --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TaskStepUpdateContent.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// + /// Base properties for updating any task step. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + public abstract partial class TaskStepUpdateContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of the step. + private protected TaskStepUpdateContent(StepType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// The type of the step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Keeps track of any properties unknown to the library. + internal TaskStepUpdateContent(StepType @type, string contextPath, string contextAccessToken, IDictionary additionalBinaryDataProperties) + { + Type = @type; + ContextPath = contextPath; + ContextAccessToken = contextAccessToken; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of the step. + internal StepType Type { get; set; } + + /// The URL(absolute or relative) of the source context for the task step. + public string ContextPath { get; set; } + + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + public string ContextAccessToken { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTrigger.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTrigger.Serialization.cs new file mode 100644 index 000000000000..16db3b41db97 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTrigger.Serialization.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a timer trigger. + public partial class TimerTrigger : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TimerTrigger() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TimerTrigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTimerTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TimerTrigger)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TimerTrigger)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TimerTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimerTrigger)} does not support writing '{format}' format."); + } + writer.WritePropertyName("schedule"u8); + writer.WriteStringValue(Schedule); + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TimerTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TimerTrigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimerTrigger)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTimerTrigger(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TimerTrigger DeserializeTimerTrigger(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string schedule = default; + ContainerRegistryTaskTriggerStatus? status = default; + string name = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("schedule"u8)) + { + schedule = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ContainerRegistryTaskTriggerStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TimerTrigger(schedule, status, name, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTrigger.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTrigger.cs new file mode 100644 index 000000000000..2536f3cc6a5a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTrigger.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a timer trigger. + public partial class TimerTrigger + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The CRON expression for the task schedule. + /// The name of the trigger. + /// or is null. + public TimerTrigger(string schedule, string name) + { + Argument.AssertNotNull(schedule, nameof(schedule)); + Argument.AssertNotNull(name, nameof(name)); + + Schedule = schedule; + Name = name; + } + + /// Initializes a new instance of . + /// The CRON expression for the task schedule. + /// The current status of trigger. + /// The name of the trigger. + /// Keeps track of any properties unknown to the library. + internal TimerTrigger(string schedule, ContainerRegistryTaskTriggerStatus? status, string name, IDictionary additionalBinaryDataProperties) + { + Schedule = schedule; + Status = status; + Name = name; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The CRON expression for the task schedule. + public string Schedule { get; set; } + + /// The current status of trigger. + public ContainerRegistryTaskTriggerStatus? Status { get; set; } + + /// The name of the trigger. + public string Name { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerDescriptor.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerDescriptor.Serialization.cs new file mode 100644 index 000000000000..cc4b17645584 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerDescriptor.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The TimerTriggerDescriptor. + public partial class TimerTriggerDescriptor : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TimerTriggerDescriptor PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTimerTriggerDescriptor(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TimerTriggerDescriptor)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TimerTriggerDescriptor)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TimerTriggerDescriptor IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimerTriggerDescriptor)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(TimerTriggerName)) + { + writer.WritePropertyName("timerTriggerName"u8); + writer.WriteStringValue(TimerTriggerName); + } + if (Optional.IsDefined(ScheduleOccurrence)) + { + writer.WritePropertyName("scheduleOccurrence"u8); + writer.WriteStringValue(ScheduleOccurrence); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TimerTriggerDescriptor IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TimerTriggerDescriptor JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimerTriggerDescriptor)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTimerTriggerDescriptor(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TimerTriggerDescriptor DeserializeTimerTriggerDescriptor(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string timerTriggerName = default; + string scheduleOccurrence = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("timerTriggerName"u8)) + { + timerTriggerName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("scheduleOccurrence"u8)) + { + scheduleOccurrence = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TimerTriggerDescriptor(timerTriggerName, scheduleOccurrence, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerDescriptor.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerDescriptor.cs new file mode 100644 index 000000000000..81ef364d545e --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerDescriptor.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The TimerTriggerDescriptor. + public partial class TimerTriggerDescriptor + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal TimerTriggerDescriptor() + { + } + + /// Initializes a new instance of . + /// The timer trigger name that caused the run. + /// The occurrence that triggered the run. + /// Keeps track of any properties unknown to the library. + internal TimerTriggerDescriptor(string timerTriggerName, string scheduleOccurrence, IDictionary additionalBinaryDataProperties) + { + TimerTriggerName = timerTriggerName; + ScheduleOccurrence = scheduleOccurrence; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The timer trigger name that caused the run. + public string TimerTriggerName { get; } + + /// The occurrence that triggered the run. + public string ScheduleOccurrence { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerUpdateContent.Serialization.cs new file mode 100644 index 000000000000..9e2f1bb4a354 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerUpdateContent.Serialization.cs @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating a timer trigger. + public partial class TimerTriggerUpdateContent : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TimerTriggerUpdateContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TimerTriggerUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTimerTriggerUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TimerTriggerUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TimerTriggerUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TimerTriggerUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimerTriggerUpdateContent)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Schedule)) + { + writer.WritePropertyName("schedule"u8); + writer.WriteStringValue(Schedule); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TimerTriggerUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TimerTriggerUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimerTriggerUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTimerTriggerUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TimerTriggerUpdateContent DeserializeTimerTriggerUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string schedule = default; + ContainerRegistryTaskTriggerStatus? status = default; + string name = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("schedule"u8)) + { + schedule = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ContainerRegistryTaskTriggerStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TimerTriggerUpdateContent(schedule, status, name, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerUpdateContent.cs new file mode 100644 index 000000000000..6dc1bd1bb566 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TimerTriggerUpdateContent.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating a timer trigger. + public partial class TimerTriggerUpdateContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the trigger. + /// is null. + public TimerTriggerUpdateContent(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + /// Initializes a new instance of . + /// The CRON expression for the task schedule. + /// The current status of trigger. + /// The name of the trigger. + /// Keeps track of any properties unknown to the library. + internal TimerTriggerUpdateContent(string schedule, ContainerRegistryTaskTriggerStatus? status, string name, IDictionary additionalBinaryDataProperties) + { + Schedule = schedule; + Status = status; + Name = name; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The CRON expression for the task schedule. + public string Schedule { get; set; } + + /// The current status of trigger. + public ContainerRegistryTaskTriggerStatus? Status { get; set; } + + /// The name of the trigger. + public string Name { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerProperties.Serialization.cs new file mode 100644 index 000000000000..bdfa715b94ba --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerProperties.Serialization.cs @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a trigger. + public partial class TriggerProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TriggerProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTriggerProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TriggerProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TriggerProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TriggerProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TriggerProperties)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(TimerTriggers)) + { + writer.WritePropertyName("timerTriggers"u8); + writer.WriteStartArray(); + foreach (TimerTrigger item in TimerTriggers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(SourceTriggers)) + { + writer.WritePropertyName("sourceTriggers"u8); + writer.WriteStartArray(); + foreach (SourceTrigger item in SourceTriggers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(BaseImageTrigger)) + { + writer.WritePropertyName("baseImageTrigger"u8); + writer.WriteObjectValue(BaseImageTrigger, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TriggerProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TriggerProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TriggerProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTriggerProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TriggerProperties DeserializeTriggerProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList timerTriggers = default; + IList sourceTriggers = default; + BaseImageTrigger baseImageTrigger = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("timerTriggers"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TimerTrigger.DeserializeTimerTrigger(item, options)); + } + timerTriggers = array; + continue; + } + if (prop.NameEquals("sourceTriggers"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(SourceTrigger.DeserializeSourceTrigger(item, options)); + } + sourceTriggers = array; + continue; + } + if (prop.NameEquals("baseImageTrigger"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + baseImageTrigger = BaseImageTrigger.DeserializeBaseImageTrigger(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TriggerProperties(timerTriggers ?? new ChangeTrackingList(), sourceTriggers ?? new ChangeTrackingList(), baseImageTrigger, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerProperties.cs new file mode 100644 index 000000000000..3ecd5d59b153 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerProperties.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties of a trigger. + public partial class TriggerProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TriggerProperties() + { + TimerTriggers = new ChangeTrackingList(); + SourceTriggers = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The collection of timer triggers. + /// The collection of triggers based on source code repository. + /// The trigger based on base image dependencies. + /// Keeps track of any properties unknown to the library. + internal TriggerProperties(IList timerTriggers, IList sourceTriggers, BaseImageTrigger baseImageTrigger, IDictionary additionalBinaryDataProperties) + { + TimerTriggers = timerTriggers; + SourceTriggers = sourceTriggers; + BaseImageTrigger = baseImageTrigger; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The collection of timer triggers. + public IList TimerTriggers { get; } + + /// The collection of triggers based on source code repository. + public IList SourceTriggers { get; } + + /// The trigger based on base image dependencies. + public BaseImageTrigger BaseImageTrigger { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerUpdateContent.Serialization.cs new file mode 100644 index 000000000000..2d133e924b03 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerUpdateContent.Serialization.cs @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating triggers. + public partial class TriggerUpdateContent : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TriggerUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTriggerUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TriggerUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TriggerUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TriggerUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TriggerUpdateContent)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(TimerTriggers)) + { + writer.WritePropertyName("timerTriggers"u8); + writer.WriteStartArray(); + foreach (TimerTriggerUpdateContent item in TimerTriggers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(SourceTriggers)) + { + writer.WritePropertyName("sourceTriggers"u8); + writer.WriteStartArray(); + foreach (SourceTriggerUpdateContent item in SourceTriggers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(BaseImageTrigger)) + { + writer.WritePropertyName("baseImageTrigger"u8); + writer.WriteObjectValue(BaseImageTrigger, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TriggerUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TriggerUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TriggerUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTriggerUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TriggerUpdateContent DeserializeTriggerUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList timerTriggers = default; + IList sourceTriggers = default; + BaseImageTriggerUpdateContent baseImageTrigger = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("timerTriggers"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TimerTriggerUpdateContent.DeserializeTimerTriggerUpdateContent(item, options)); + } + timerTriggers = array; + continue; + } + if (prop.NameEquals("sourceTriggers"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(SourceTriggerUpdateContent.DeserializeSourceTriggerUpdateContent(item, options)); + } + sourceTriggers = array; + continue; + } + if (prop.NameEquals("baseImageTrigger"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + baseImageTrigger = BaseImageTriggerUpdateContent.DeserializeBaseImageTriggerUpdateContent(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TriggerUpdateContent(timerTriggers ?? new ChangeTrackingList(), sourceTriggers ?? new ChangeTrackingList(), baseImageTrigger, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerUpdateContent.cs new file mode 100644 index 000000000000..4aff95c3cb20 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/TriggerUpdateContent.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The properties for updating triggers. + public partial class TriggerUpdateContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TriggerUpdateContent() + { + TimerTriggers = new ChangeTrackingList(); + SourceTriggers = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The collection of timer triggers. + /// The collection of triggers based on source code repository. + /// The trigger based on base image dependencies. + /// Keeps track of any properties unknown to the library. + internal TriggerUpdateContent(IList timerTriggers, IList sourceTriggers, BaseImageTriggerUpdateContent baseImageTrigger, IDictionary additionalBinaryDataProperties) + { + TimerTriggers = timerTriggers; + SourceTriggers = sourceTriggers; + BaseImageTrigger = baseImageTrigger; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The collection of timer triggers. + public IList TimerTriggers { get; } + + /// The collection of triggers based on source code repository. + public IList SourceTriggers { get; } + + /// The trigger based on base image dependencies. + public BaseImageTriggerUpdateContent BaseImageTrigger { get; set; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownRunContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownRunContent.Serialization.cs new file mode 100644 index 000000000000..26165e30dbd7 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownRunContent.Serialization.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + internal partial class UnknownRunContent : RunContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownRunContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override RunContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRunContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(RunContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RunContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + RunContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override RunContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownRunContent DeserializeUnknownRunContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "unknown"; + bool? isArchiveEnabled = default; + string agentPoolName = default; + string logTemplate = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("isArchiveEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isArchiveEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("agentPoolName"u8)) + { + agentPoolName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logTemplate"u8)) + { + logTemplate = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownRunContent(@type, isArchiveEnabled, agentPoolName, logTemplate, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownRunContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownRunContent.cs new file mode 100644 index 000000000000..acfda9d4cb19 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownRunContent.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + internal partial class UnknownRunContent : RunContent + { + /// Initializes a new instance of . + /// The type of the run request. + /// The value that indicates whether archiving is enabled for the run or not. + /// The dedicated agent pool for the run. + /// The template that describes the repository and tag information for run log artifact. + /// Keeps track of any properties unknown to the library. + internal UnknownRunContent(string @type, bool? isArchiveEnabled, string agentPoolName, string logTemplate, IDictionary additionalBinaryDataProperties) : base(@type ?? "unknown", isArchiveEnabled, agentPoolName, logTemplate, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepProperties.Serialization.cs new file mode 100644 index 000000000000..068907d7321f --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepProperties.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + internal partial class UnknownTaskStepProperties : TaskStepProperties, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownTaskStepProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override TaskStepProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskStepProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskStepProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskStepProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskStepProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskStepProperties)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskStepProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TaskStepProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskStepProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskStepProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownTaskStepProperties DeserializeUnknownTaskStepProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StepType @type = default; + IReadOnlyList baseImageDependencies = default; + string contextPath = default; + string contextAccessToken = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new StepType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("baseImageDependencies"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(BaseImageDependency.DeserializeBaseImageDependency(item, options)); + } + baseImageDependencies = array; + continue; + } + if (prop.NameEquals("contextPath"u8)) + { + contextPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("contextAccessToken"u8)) + { + contextAccessToken = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownTaskStepProperties(@type, baseImageDependencies ?? new ChangeTrackingList(), contextPath, contextAccessToken, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepProperties.cs new file mode 100644 index 000000000000..f16ebedfdbe8 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepProperties.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + internal partial class UnknownTaskStepProperties : TaskStepProperties + { + /// Initializes a new instance of . + /// The type of the step. + /// List of base image dependencies for a step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Keeps track of any properties unknown to the library. + internal UnknownTaskStepProperties(StepType @type, IReadOnlyList baseImageDependencies, string contextPath, string contextAccessToken, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", baseImageDependencies, contextPath, contextAccessToken, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepUpdateContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepUpdateContent.Serialization.cs new file mode 100644 index 000000000000..eebcafa3d351 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepUpdateContent.Serialization.cs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + internal partial class UnknownTaskStepUpdateContent : TaskStepUpdateContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownTaskStepUpdateContent() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override TaskStepUpdateContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskStepUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskStepUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskStepUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskStepUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskStepUpdateContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskStepUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TaskStepUpdateContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskStepUpdateContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskStepUpdateContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownTaskStepUpdateContent DeserializeUnknownTaskStepUpdateContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StepType @type = default; + string contextPath = default; + string contextAccessToken = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new StepType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("contextPath"u8)) + { + contextPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("contextAccessToken"u8)) + { + contextAccessToken = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownTaskStepUpdateContent(@type, contextPath, contextAccessToken, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepUpdateContent.cs new file mode 100644 index 000000000000..1c336188275c --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UnknownTaskStepUpdateContent.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + internal partial class UnknownTaskStepUpdateContent : TaskStepUpdateContent + { + /// Initializes a new instance of . + /// The type of the step. + /// The URL(absolute or relative) of the source context for the task step. + /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + /// Keeps track of any properties unknown to the library. + internal UnknownTaskStepUpdateContent(StepType @type, string contextPath, string contextAccessToken, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", contextPath, contextAccessToken, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UpdateTriggerPayloadType.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UpdateTriggerPayloadType.cs new file mode 100644 index 000000000000..4d87be5f54a3 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UpdateTriggerPayloadType.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// Type of Payload body for Base image update triggers. + public readonly partial struct UpdateTriggerPayloadType : IEquatable + { + private readonly string _value; + private const string DefaultValue = "Default"; + private const string TokenValue = "Token"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public UpdateTriggerPayloadType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Default. + public static UpdateTriggerPayloadType Default { get; } = new UpdateTriggerPayloadType(DefaultValue); + + /// Gets the Token. + public static UpdateTriggerPayloadType Token { get; } = new UpdateTriggerPayloadType(TokenValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(UpdateTriggerPayloadType left, UpdateTriggerPayloadType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(UpdateTriggerPayloadType left, UpdateTriggerPayloadType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator UpdateTriggerPayloadType(string value) => new UpdateTriggerPayloadType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator UpdateTriggerPayloadType?(string value) => value == null ? null : new UpdateTriggerPayloadType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is UpdateTriggerPayloadType other && Equals(other); + + /// + public bool Equals(UpdateTriggerPayloadType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UserIdentityProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UserIdentityProperties.Serialization.cs new file mode 100644 index 000000000000..7d8f93af2624 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UserIdentityProperties.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.ContainerRegistryTasks; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The UserIdentityProperties. + public partial class UserIdentityProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UserIdentityProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeUserIdentityProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserIdentityProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(UserIdentityProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + UserIdentityProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserIdentityProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(PrincipalId)) + { + writer.WritePropertyName("principalId"u8); + writer.WriteStringValue(PrincipalId); + } + if (options.Format != "W" && Optional.IsDefined(ClientId)) + { + writer.WritePropertyName("clientId"u8); + writer.WriteStringValue(ClientId); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + UserIdentityProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UserIdentityProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserIdentityProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserIdentityProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UserIdentityProperties DeserializeUserIdentityProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string principalId = default; + string clientId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("principalId"u8)) + { + principalId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("clientId"u8)) + { + clientId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UserIdentityProperties(principalId, clientId, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UserIdentityProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UserIdentityProperties.cs new file mode 100644 index 000000000000..f9a2269b9b34 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/Models/UserIdentityProperties.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Models +{ + /// The UserIdentityProperties. + public partial class UserIdentityProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public UserIdentityProperties() + { + } + + /// Initializes a new instance of . + /// The principal id of user assigned identity. + /// The client id of user assigned identity. + /// Keeps track of any properties unknown to the library. + internal UserIdentityProperties(string principalId, string clientId, IDictionary additionalBinaryDataProperties) + { + PrincipalId = principalId; + ClientId = clientId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The principal id of user assigned identity. + public string PrincipalId { get; } + + /// The client id of user assigned identity. + public string ClientId { get; } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/ProviderConstants.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..82f18bcced53 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/ProviderConstants.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal static partial class ProviderConstants + { + /// Gets the DefaultProviderNamespace. + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/AgentPoolsRestOperations.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/AgentPoolsRestOperations.cs new file mode 100644 index 000000000000..43f4db52b019 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/AgentPoolsRestOperations.cs @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class AgentPools + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AgentPools for mocking. + protected AgentPools() + { + } + + /// Initializes a new instance of AgentPools. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal AgentPools(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string registryName, string agentPoolName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/agentPools/", false); + uri.AppendPath(agentPoolName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateRequest(Guid subscriptionId, string resourceGroupName, string registryName, string agentPoolName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/agentPools/", false); + uri.AppendPath(agentPoolName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string registryName, string agentPoolName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/agentPools/", false); + uri.AppendPath(agentPoolName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string registryName, string agentPoolName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/agentPools/", false); + uri.AppendPath(agentPoolName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetAllRequest(Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/agentPools", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetQueueStatusRequest(Guid subscriptionId, string resourceGroupName, string registryName, string agentPoolName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/agentPools/", false); + uri.AppendPath(agentPoolName, true); + uri.AppendPath("/listQueueStatus", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/RegistriesRestOperations.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/RegistriesRestOperations.cs new file mode 100644 index 000000000000..4b3a21412d66 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/RegistriesRestOperations.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class Registries + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Registries for mocking. + protected Registries() + { + } + + /// Initializes a new instance of Registries. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Registries(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateScheduleRunRequest(Guid subscriptionId, string resourceGroupName, string registryName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/scheduleRun", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetBuildSourceUploadUrlRequest(Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/listBuildSourceUploadUrl", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/RunsRestOperations.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/RunsRestOperations.cs new file mode 100644 index 000000000000..7260ded44f85 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/RunsRestOperations.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class Runs + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Runs for mocking. + protected Runs() + { + } + + /// Initializes a new instance of Runs. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Runs(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string registryName, string runId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string registryName, string runId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAllRequest(Guid subscriptionId, string resourceGroupName, string registryName, string filter, int? top, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/runs", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (top != null) + { + uri.AppendQuery("$top", TypeFormatters.ConvertToString(top), true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string registryName, string filter, int? top, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetLogSasUrlRequest(Guid subscriptionId, string resourceGroupName, string registryName, string runId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/listLogSasUrl", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCancelRequest(Guid subscriptionId, string resourceGroupName, string registryName, string runId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/cancel", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + return message; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/TaskRunsRestOperations.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/TaskRunsRestOperations.cs new file mode 100644 index 000000000000..a2309a07cbfd --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/TaskRunsRestOperations.cs @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class TaskRuns + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of TaskRuns for mocking. + protected TaskRuns() + { + } + + /// Initializes a new instance of TaskRuns. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal TaskRuns(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string registryName, string taskRunName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/taskRuns/", false); + uri.AppendPath(taskRunName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateRequest(Guid subscriptionId, string resourceGroupName, string registryName, string taskRunName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/taskRuns/", false); + uri.AppendPath(taskRunName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string registryName, string taskRunName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/taskRuns/", false); + uri.AppendPath(taskRunName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string registryName, string taskRunName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/taskRuns/", false); + uri.AppendPath(taskRunName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetAllRequest(Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/taskRuns", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetDetailsRequest(Guid subscriptionId, string resourceGroupName, string registryName, string taskRunName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/taskRuns/", false); + uri.AppendPath(taskRunName, true); + uri.AppendPath("/listDetails", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/TasksRestOperations.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/TasksRestOperations.cs new file mode 100644 index 000000000000..09a4cf498a30 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RestOperations/TasksRestOperations.cs @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + internal partial class Tasks + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Tasks for mocking. + protected Tasks() + { + } + + /// Initializes a new instance of Tasks. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Tasks(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string registryName, string taskName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/tasks/", false); + uri.AppendPath(taskName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateRequest(Guid subscriptionId, string resourceGroupName, string registryName, string taskName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/tasks/", false); + uri.AppendPath(taskName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string registryName, string taskName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/tasks/", false); + uri.AppendPath(taskName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string registryName, string taskName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/tasks/", false); + uri.AppendPath(taskName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetAllRequest(Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/tasks", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string registryName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetDetailsRequest(Guid subscriptionId, string resourceGroupName, string registryName, string taskName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ContainerRegistry/registries/", false); + uri.AppendPath(registryName, true); + uri.AppendPath("/tasks/", false); + uri.AppendPath(taskName, true); + uri.AppendPath("/listDetails", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunCollection.cs new file mode 100644 index 000000000000..0bac0e59c870 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunCollection.cs @@ -0,0 +1,486 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetRuns method from an instance of . + /// + public partial class RunCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _runsClientDiagnostics; + private readonly Runs _runsRestClient; + /// The registryName. + private readonly string _registryName; + + /// Initializes a new instance of RunCollection for mocking. + protected RunCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + /// The registryName for the resource. + internal RunCollection(ArmClient client, ResourceIdentifier id, string registryName) : base(client, id) + { + TryGetApiVersion(RunResource.ResourceType, out string runApiVersion); + _registryName = registryName; + _runsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerRegistryTasks", RunResource.ResourceType.Namespace, Diagnostics); + _runsRestClient = new Runs(_runsClientDiagnostics, Pipeline, Endpoint, runApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } + } + + /// + /// Gets the detailed information for a given run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The run ID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, runId, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(RunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new RunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the detailed information for a given run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The run ID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, runId, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(RunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new RunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets all the runs for a registry. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs. + /// + /// + /// Operation Id. + /// Runs_List. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except 'Not', 'Has', 'All' are allowed. + /// $top is supported for get list of runs, which limits the maximum number of runs to return. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(string filter = default, int? top = default, CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new RunsGetAllAsyncCollectionResultOfT( + _runsRestClient, + Guid.Parse(Id.SubscriptionId), + Id.ResourceGroupName, + _registryName, + filter, + top, + context), data => new RunResource(Client, data)); + } + + /// + /// Gets all the runs for a registry. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs. + /// + /// + /// Operation Id. + /// Runs_List. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except 'Not', 'Has', 'All' are allowed. + /// $top is supported for get list of runs, which limits the maximum number of runs to return. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(string filter = default, int? top = default, CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new RunsGetAllCollectionResultOfT( + _runsRestClient, + Guid.Parse(Id.SubscriptionId), + Id.ResourceGroupName, + _registryName, + filter, + top, + context), data => new RunResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The run ID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, runId, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(RunData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((RunData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The run ID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, runId, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(RunData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((RunData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The run ID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, runId, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(RunData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((RunData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new RunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The run ID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, runId, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(RunData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((RunData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new RunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + /// The cancellation token to use. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunData.Serialization.cs new file mode 100644 index 000000000000..a6c74fc3eba9 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunData.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// Run resource properties. + public partial class RunData : ResourceData, IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRunData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(RunData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RunData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (RunData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static RunData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RunData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (RunData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RunData DeserializeRunData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + RunProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerContainerRegistryTasksContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = RunProperties.DeserializeRunProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RunData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunData.cs new file mode 100644 index 000000000000..fb3abb118a5c --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunData.cs @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// Run resource properties. + public partial class RunData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal RunData() + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// The properties of a run. + internal RunData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, RunProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The properties of a run. + internal RunProperties Properties { get; } + + /// The unique identifier for the run. + public string RunId + { + get + { + return Properties.RunId; + } + } + + /// The current status of the run. + public ContainerRegistryTaskRunStatus? Status + { + get + { + return Properties.Status; + } + } + + /// The last updated time for the run. + public DateTimeOffset? LastUpdatedOn + { + get + { + return Properties.LastUpdatedOn; + } + } + + /// The type of run. + public ContainerRegistryTaskRunType? RunType + { + get + { + return Properties.RunType; + } + } + + /// The dedicated agent pool for the run. + public string AgentPoolName + { + get + { + return Properties.AgentPoolName; + } + } + + /// The time the run was scheduled. + public DateTimeOffset? CreatedOn + { + get + { + return Properties.CreatedOn; + } + } + + /// The time the run started. + public DateTimeOffset? StartOn + { + get + { + return Properties.StartOn; + } + } + + /// The time the run finished. + public DateTimeOffset? FinishOn + { + get + { + return Properties.FinishOn; + } + } + + /// The list of all images that were generated from the run. This is applicable if the run generates base image dependencies. + public IList OutputImages + { + get + { + return Properties.OutputImages; + } + } + + /// The task against which run was scheduled. + public string Task + { + get + { + return Properties.Task; + } + } + + /// The image update trigger that caused the run. This is applicable if the task has base image trigger configured. + public ImageUpdateTrigger ImageUpdateTrigger + { + get + { + return Properties.ImageUpdateTrigger; + } + } + + /// The source trigger that caused the run. + public SourceTriggerDescriptor SourceTrigger + { + get + { + return Properties.SourceTrigger; + } + } + + /// The timer trigger that caused the run. + public TimerTriggerDescriptor TimerTrigger + { + get + { + return Properties.TimerTrigger; + } + } + + /// The platform properties against which the run will happen. + public PlatformProperties Platform + { + get + { + return Properties.Platform; + } + } + + /// The scope of the credentials that were used to login to the source registry during this run. + public string SourceRegistryAuth + { + get + { + return Properties.SourceRegistryAuth; + } + } + + /// The list of custom registries that were logged in during this run. + public IList CustomRegistries + { + get + { + return Properties.CustomRegistries; + } + } + + /// The error message received from backend systems after the run is scheduled. + public string RunErrorMessage + { + get + { + return Properties.RunErrorMessage; + } + } + + /// The update trigger token passed for the Run. + public string UpdateTriggerToken + { + get + { + return Properties.UpdateTriggerToken; + } + } + + /// The image description for the log artifact. + public ImageDescriptor LogArtifact + { + get + { + return Properties.LogArtifact; + } + } + + /// The provisioning state of a run. + public ContainerRegistryTaskProvisioningState? ProvisioningState + { + get + { + return Properties.ProvisioningState; + } + } + + /// The value that indicates whether archiving is enabled or not. + public bool? IsArchiveEnabled + { + get + { + return Properties.IsArchiveEnabled; + } + } + + /// The CPU configuration in terms of number of cores required for the run. + public int? AgentCpu + { + get + { + return Properties.AgentCpu; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunResource.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunResource.Serialization.cs new file mode 100644 index 000000000000..579d07f9e290 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + public partial class RunResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new RunData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + RunData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerContainerRegistryTasksContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + RunData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerContainerRegistryTasksContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunResource.cs new file mode 100644 index 000000000000..a346f43eae08 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/RunResource.cs @@ -0,0 +1,478 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// A class representing a Run along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetRuns method. + /// + public partial class RunResource : ArmResource + { + private readonly ClientDiagnostics _runsClientDiagnostics; + private readonly Runs _runsRestClient; + private readonly RunData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.ContainerRegistry/registries/runs"; + + /// Initializes a new instance of RunResource for mocking. + protected RunResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal RunResource(ArmClient client, RunData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal RunResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string runApiVersion); + _runsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerRegistryTasks", ResourceType.Namespace, Diagnostics); + _runsRestClient = new Runs(_runsClientDiagnostics, Pipeline, Endpoint, runApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual RunData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The registryName. + /// The runId. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string registryName, string runId) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Gets the detailed information for a given run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(RunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new RunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the detailed information for a given run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(RunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new RunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Patch the run properties. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Update. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The run update properties. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(RunPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, RunPatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(RunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new RunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Patch the run properties. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}. + /// + /// + /// Operation Id. + /// Runs_Update. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The run update properties. + /// The cancellation token to use. + /// is null. + public virtual Response Update(RunPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, RunPatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(RunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new RunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Cancel an existing run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel. + /// + /// + /// Operation Id. + /// Runs_Cancel. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task CancelAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunResource.Cancel"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateCancelRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Cancel an existing run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel. + /// + /// + /// Operation Id. + /// Runs_Cancel. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Cancel(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunResource.Cancel"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateCancelRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets a link to download the run logs. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl. + /// + /// + /// Operation Id. + /// Runs_GetLogSasUrl. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetLogSasUrlAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunResource.GetLogSasUrl"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateGetLogSasUrlRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(RunGetLogResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets a link to download the run logs. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl. + /// + /// + /// Operation Id. + /// Runs_GetLogSasUrl. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response GetLogSasUrl(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _runsClientDiagnostics.CreateScope("RunResource.GetLogSasUrl"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _runsRestClient.CreateGetLogSasUrlRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(RunGetLogResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskCollection.cs new file mode 100644 index 000000000000..015dd8e0fe72 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskCollection.cs @@ -0,0 +1,578 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetTasks method from an instance of . + /// + public partial class TaskCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _tasksClientDiagnostics; + private readonly Tasks _tasksRestClient; + /// The registryName. + private readonly string _registryName; + + /// Initializes a new instance of TaskCollection for mocking. + protected TaskCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + /// The registryName for the resource. + internal TaskCollection(ArmClient client, ResourceIdentifier id, string registryName) : base(client, id) + { + TryGetApiVersion(TaskResource.ResourceType, out string taskApiVersion); + _registryName = registryName; + _tasksClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerRegistryTasks", TaskResource.ResourceType.Namespace, Diagnostics); + _tasksRestClient = new Tasks(_tasksClientDiagnostics, Pipeline, Endpoint, taskApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } + } + + /// + /// Creates a task for a container registry with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Create. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the container registry task. + /// The parameters for creating a task. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string taskName, TaskData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskName, nameof(taskName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskName, TaskData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation(Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates a task for a container registry with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Create. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the container registry task. + /// The parameters for creating a task. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string taskName, TaskData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskName, nameof(taskName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskName, TaskData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation(Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the properties of a specified task. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the container registry task. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string taskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskName, nameof(taskName)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the properties of a specified task. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the container registry task. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string taskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskName, nameof(taskName)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all the tasks for a specified container registry. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks. + /// + /// + /// Operation Id. + /// Tasks_List. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new TasksGetAllAsyncCollectionResultOfT(_tasksRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, context), data => new TaskResource(Client, data)); + } + + /// + /// Lists all the tasks for a specified container registry. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks. + /// + /// + /// Operation Id. + /// Tasks_List. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new TasksGetAllCollectionResultOfT(_tasksRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, context), data => new TaskResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the container registry task. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string taskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskName, nameof(taskName)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TaskData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TaskData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the container registry task. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string taskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskName, nameof(taskName)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TaskData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TaskData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the container registry task. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string taskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskName, nameof(taskName)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TaskData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TaskData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the container registry task. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string taskName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskName, nameof(taskName)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TaskData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TaskData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + /// The cancellation token to use. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskData.Serialization.cs new file mode 100644 index 000000000000..4f7a4c0ae23b --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskData.Serialization.cs @@ -0,0 +1,250 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// The task that has the ARM resource and task properties. + /// The task will have all information to schedule a run against it. + /// + public partial class TaskData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TaskData() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TaskData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TaskData taskData) + { + if (taskData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(taskData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static TaskData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTaskData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + writer.WriteObjectValue(Identity, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TaskData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskData DeserializeTaskData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + TaskProperties properties = default; + IdentityProperties identity = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerContainerRegistryTasksContext.Default); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = TaskProperties.DeserializeTaskProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("identity"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = IdentityProperties.DeserializeIdentityProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + identity); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskData.cs new file mode 100644 index 000000000000..378871ac8eeb --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskData.cs @@ -0,0 +1,242 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// The task that has the ARM resource and task properties. + /// The task will have all information to schedule a run against it. + /// + public partial class TaskData : TrackedResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The geo-location where the resource lives. + public TaskData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The properties of a task. + /// Identity for the resource. + internal TaskData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, TaskProperties properties, IdentityProperties identity) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + Identity = identity; + } + + /// The properties of a task. + internal TaskProperties Properties { get; set; } + + /// Identity for the resource. + public IdentityProperties Identity { get; set; } + + /// The provisioning state of the task. + public ContainerRegistryTaskProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + + /// The creation date of task. + public DateTimeOffset? CreatedOn + { + get + { + return Properties is null ? default : Properties.CreatedOn; + } + } + + /// The current status of task. + public ContainerRegistryTaskStatus? Status + { + get + { + return Properties is null ? default : Properties.Status; + } + set + { + if (Properties is null) + { + Properties = new TaskProperties(); + } + Properties.Status = value.Value; + } + } + + /// The platform properties against which the run has to happen. + public PlatformProperties Platform + { + get + { + return Properties is null ? default : Properties.Platform; + } + set + { + if (Properties is null) + { + Properties = new TaskProperties(); + } + Properties.Platform = value; + } + } + + /// The dedicated agent pool for the task. + public string AgentPoolName + { + get + { + return Properties is null ? default : Properties.AgentPoolName; + } + set + { + if (Properties is null) + { + Properties = new TaskProperties(); + } + Properties.AgentPoolName = value; + } + } + + /// Run timeout in seconds. + public int? TimeoutInSeconds + { + get + { + return Properties is null ? default : Properties.TimeoutInSeconds; + } + set + { + if (Properties is null) + { + Properties = new TaskProperties(); + } + Properties.TimeoutInSeconds = value.Value; + } + } + + /// The properties of a task step. + public TaskStepProperties Step + { + get + { + return Properties is null ? default : Properties.Step; + } + set + { + if (Properties is null) + { + Properties = new TaskProperties(); + } + Properties.Step = value; + } + } + + /// The properties that describe all triggers for the task. + public TriggerProperties Trigger + { + get + { + return Properties is null ? default : Properties.Trigger; + } + set + { + if (Properties is null) + { + Properties = new TaskProperties(); + } + Properties.Trigger = value; + } + } + + /// The properties that describes a set of credentials that will be used when this run is invoked. + public ContainerRegistryTaskCredentials Credentials + { + get + { + return Properties is null ? default : Properties.Credentials; + } + set + { + if (Properties is null) + { + Properties = new TaskProperties(); + } + Properties.Credentials = value; + } + } + + /// The template that describes the repository and tag information for run log artifact. + public string LogTemplate + { + get + { + return Properties is null ? default : Properties.LogTemplate; + } + set + { + if (Properties is null) + { + Properties = new TaskProperties(); + } + Properties.LogTemplate = value; + } + } + + /// The value of this property indicates whether the task resource is system task or not. + public bool? IsSystemTask + { + get + { + return Properties is null ? default : Properties.IsSystemTask; + } + set + { + if (Properties is null) + { + Properties = new TaskProperties(); + } + Properties.IsSystemTask = value.Value; + } + } + + /// The CPU configuration in terms of number of cores required for the run. + public int? AgentCpu + { + get + { + return Properties is null ? default : Properties.AgentCpu; + } + set + { + if (Properties is null) + { + Properties = new TaskProperties(); + } + Properties.AgentCpu = value.Value; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskResource.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskResource.Serialization.cs new file mode 100644 index 000000000000..7579e33d682f --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + public partial class TaskResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TaskData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + TaskData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerContainerRegistryTasksContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + TaskData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerContainerRegistryTasksContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskResource.cs new file mode 100644 index 000000000000..71224ac53c1a --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskResource.cs @@ -0,0 +1,769 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// A class representing a Task along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetTasks method. + /// + public partial class TaskResource : ArmResource + { + private readonly ClientDiagnostics _tasksClientDiagnostics; + private readonly Tasks _tasksRestClient; + private readonly TaskData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.ContainerRegistry/registries/tasks"; + + /// Initializes a new instance of TaskResource for mocking. + protected TaskResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal TaskResource(ArmClient client, TaskData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal TaskResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string taskApiVersion); + _tasksClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerRegistryTasks", ResourceType.Namespace, Diagnostics); + _tasksRestClient = new Tasks(_tasksClientDiagnostics, Pipeline, Endpoint, taskApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual TaskData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The registryName. + /// The taskName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string registryName, string taskName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Get the properties of a specified task. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the properties of a specified task. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates a task with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Update. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The parameters for updating a task. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(TaskPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, TaskPatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates a task with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Update. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The parameters for updating a task. + /// The cancellation token to use. + /// is null. + public virtual Response Update(TaskPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, TaskPatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a specified task. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Delete. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a specified task. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}. + /// + /// + /// Operation Id. + /// Tasks_Delete. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns a task with extended information that includes all secrets. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails. + /// + /// + /// Operation Id. + /// Tasks_GetDetails. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetDetailsAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.GetDetails"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetDetailsRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns a task with extended information that includes all secrets. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails. + /// + /// + /// Operation Id. + /// Tasks_GetDetails. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response GetDetails(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.GetDetails"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetDetailsRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TaskData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TaskPatch patch = new TaskPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TaskData current = Get(cancellationToken: cancellationToken).Value.Data; + TaskPatch patch = new TaskPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TaskData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TaskPatch patch = new TaskPatch(); + patch.Tags.ReplaceWith(tags); + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TaskData current = Get(cancellationToken: cancellationToken).Value.Data; + TaskPatch patch = new TaskPatch(); + patch.Tags.ReplaceWith(tags); + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TaskData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TaskPatch patch = new TaskPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _tasksClientDiagnostics.CreateScope("TaskResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _tasksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskData.FromResponse(result), result); + return Response.FromValue(new TaskResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TaskData current = Get(cancellationToken: cancellationToken).Value.Data; + TaskPatch patch = new TaskPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunCollection.cs new file mode 100644 index 000000000000..c9cd82ccaa64 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunCollection.cs @@ -0,0 +1,584 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetTaskRuns method from an instance of . + /// + public partial class TaskRunCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _taskRunsClientDiagnostics; + private readonly TaskRuns _taskRunsRestClient; + /// The registryName. + private readonly string _registryName; + + /// Initializes a new instance of TaskRunCollection for mocking. + protected TaskRunCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + /// The registryName for the resource. + internal TaskRunCollection(ArmClient client, ResourceIdentifier id, string registryName) : base(client, id) + { + TryGetApiVersion(TaskRunResource.ResourceType, out string taskRunApiVersion); + _registryName = registryName; + _taskRunsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerRegistryTasks", TaskRunResource.ResourceType.Namespace, Diagnostics); + _taskRunsRestClient = new TaskRuns(_taskRunsClientDiagnostics, Pipeline, Endpoint, taskRunApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } + } + + /// + /// Creates a task run for a container registry with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Create. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the task run. + /// The parameters of a run that needs to scheduled. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string taskRunName, TaskRunData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskRunName, nameof(taskRunName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskRunName, TaskRunData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation( + new TaskRunOperationSource(Client), + _taskRunsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates a task run for a container registry with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Create. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the task run. + /// The parameters of a run that needs to scheduled. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string taskRunName, TaskRunData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskRunName, nameof(taskRunName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskRunName, TaskRunData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation( + new TaskRunOperationSource(Client), + _taskRunsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the detailed information for a given task run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the task run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string taskRunName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskRunName, nameof(taskRunName)); + + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskRunName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskRunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskRunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the detailed information for a given task run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the task run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string taskRunName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskRunName, nameof(taskRunName)); + + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskRunName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskRunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskRunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all the task runs for a specified container registry. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns. + /// + /// + /// Operation Id. + /// TaskRuns_List. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new TaskRunsGetAllAsyncCollectionResultOfT(_taskRunsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, context), data => new TaskRunResource(Client, data)); + } + + /// + /// Lists all the task runs for a specified container registry. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns. + /// + /// + /// Operation Id. + /// TaskRuns_List. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new TaskRunsGetAllCollectionResultOfT(_taskRunsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, context), data => new TaskRunResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the task run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string taskRunName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskRunName, nameof(taskRunName)); + + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskRunName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TaskRunData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TaskRunData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the task run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string taskRunName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskRunName, nameof(taskRunName)); + + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskRunName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TaskRunData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TaskRunData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the task run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string taskRunName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskRunName, nameof(taskRunName)); + + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskRunName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TaskRunData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TaskRunData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new TaskRunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// + /// The name of the task run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string taskRunName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(taskRunName, nameof(taskRunName)); + + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, _registryName, taskRunName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TaskRunData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TaskRunData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new TaskRunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + /// The cancellation token to use. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunData.Serialization.cs new file mode 100644 index 000000000000..bae6098cab23 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunData.Serialization.cs @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// The task run that has the ARM resource and properties. + /// The task run will have the information of request and result of a run. + /// + public partial class TaskRunData : ResourceData, IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaskRunData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaskRunData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerContainerRegistryTasksContext.Default); + default: + throw new FormatException($"The model {nameof(TaskRunData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TaskRunData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TaskRunData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TaskRunData taskRunData) + { + if (taskRunData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(taskRunData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static TaskRunData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTaskRunData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + writer.WriteObjectValue(Identity, options); + } + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location.Value); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaskRunData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TaskRunData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaskRunData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaskRunData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaskRunData DeserializeTaskRunData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + TaskRunProperties properties = default; + IdentityProperties identity = default; + AzureLocation? location = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerContainerRegistryTasksContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = TaskRunProperties.DeserializeTaskRunProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("identity"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = IdentityProperties.DeserializeIdentityProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("location"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaskRunData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties, + identity, + location); + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunData.cs new file mode 100644 index 000000000000..83716b3d71e0 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunData.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// The task run that has the ARM resource and properties. + /// The task run will have the information of request and result of a run. + /// + public partial class TaskRunData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TaskRunData() + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// The properties associated with the task run, i.e., request and result of the run. + /// Identity for the resource. + /// The location of the resource. + internal TaskRunData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, TaskRunProperties properties, IdentityProperties identity, AzureLocation? location) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + Identity = identity; + Location = location; + } + + /// The properties associated with the task run, i.e., request and result of the run. + internal TaskRunProperties Properties { get; set; } + + /// Identity for the resource. + public IdentityProperties Identity { get; set; } + + /// The location of the resource. + public AzureLocation? Location { get; set; } + + /// The provisioning state of this task run. + public ContainerRegistryTaskProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + + /// The request (parameters) for the run. + public RunContent RunRequest + { + get + { + return Properties is null ? default : Properties.RunRequest; + } + set + { + if (Properties is null) + { + Properties = new TaskRunProperties(); + } + Properties.RunRequest = value; + } + } + + /// The result of this task run. + public RunData RunResult + { + get + { + return Properties is null ? default : Properties.RunResult; + } + } + + /// How the run should be forced to rerun even if the run request configuration has not changed. + public string ForceUpdateTag + { + get + { + return Properties is null ? default : Properties.ForceUpdateTag; + } + set + { + if (Properties is null) + { + Properties = new TaskRunProperties(); + } + Properties.ForceUpdateTag = value; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunResource.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunResource.Serialization.cs new file mode 100644 index 000000000000..96c15542e5ca --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + public partial class TaskRunResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TaskRunData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + TaskRunData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerContainerRegistryTasksContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + TaskRunData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerContainerRegistryTasksContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunResource.cs new file mode 100644 index 000000000000..c305370c2c26 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/src/Generated/TaskRunResource.cs @@ -0,0 +1,508 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.ContainerRegistryTasks.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ContainerRegistryTasks +{ + /// + /// A class representing a TaskRun along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetTaskRuns method. + /// + public partial class TaskRunResource : ArmResource + { + private readonly ClientDiagnostics _taskRunsClientDiagnostics; + private readonly TaskRuns _taskRunsRestClient; + private readonly TaskRunData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.ContainerRegistry/registries/taskRuns"; + + /// Initializes a new instance of TaskRunResource for mocking. + protected TaskRunResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal TaskRunResource(ArmClient client, TaskRunData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal TaskRunResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string taskRunApiVersion); + _taskRunsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerRegistryTasks", ResourceType.Namespace, Diagnostics); + _taskRunsRestClient = new TaskRuns(_taskRunsClientDiagnostics, Pipeline, Endpoint, taskRunApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual TaskRunData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The registryName. + /// The taskRunName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string registryName, string taskRunName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Gets the detailed information for a given task run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskRunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskRunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the detailed information for a given task run. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Get. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskRunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskRunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates a task run with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Update. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The parameters for updating a task run. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, TaskRunPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, TaskRunPatch.ToRequestContent(patch), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation( + new TaskRunOperationSource(Client), + _taskRunsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates a task run with the specified parameters. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Update. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The parameters for updating a task run. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, TaskRunPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, TaskRunPatch.ToRequestContent(patch), context); + Response response = Pipeline.ProcessMessage(message, context); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation( + new TaskRunOperationSource(Client), + _taskRunsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a specified task run resource. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Delete. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a specified task run resource. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}. + /// + /// + /// Operation Id. + /// TaskRuns_Delete. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ContainerRegistryTasksArmOperation operation = new ContainerRegistryTasksArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the detailed information for a given task run that includes all secrets. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}/listDetails. + /// + /// + /// Operation Id. + /// TaskRuns_GetDetails. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetDetailsAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunResource.GetDetails"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateGetDetailsRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TaskRunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskRunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the detailed information for a given task run that includes all secrets. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}/listDetails. + /// + /// + /// Operation Id. + /// TaskRuns_GetDetails. + /// + /// + /// Default Api Version. + /// 2025-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response GetDetails(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _taskRunsClientDiagnostics.CreateScope("TaskRunResource.GetDetails"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _taskRunsRestClient.CreateGetDetailsRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TaskRunData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TaskRunResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tests/Azure.ResourceManager.ContainerRegistryTasks.Tests.csproj b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tests/Azure.ResourceManager.ContainerRegistryTasks.Tests.csproj new file mode 100644 index 000000000000..13cc8fdacb0d --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tests/Azure.ResourceManager.ContainerRegistryTasks.Tests.csproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tests/ContainerRegistryTasksManagementTestBase.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tests/ContainerRegistryTasksManagementTestBase.cs new file mode 100644 index 000000000000..5779900696c4 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tests/ContainerRegistryTasksManagementTestBase.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Tests +{ + public class ContainerRegistryTasksManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected ContainerRegistryTasksManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected ContainerRegistryTasksManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tests/ContainerRegistryTasksManagementTestEnvironment.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tests/ContainerRegistryTasksManagementTestEnvironment.cs new file mode 100644 index 000000000000..94988c13e42d --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tests/ContainerRegistryTasksManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.ContainerRegistryTasks.Tests +{ + public class ContainerRegistryTasksManagementTestEnvironment : TestEnvironment + { + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tsp-location.yaml b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tsp-location.yaml new file mode 100644 index 000000000000..cb28f3e0b083 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistryTasks/tsp-location.yaml @@ -0,0 +1,6 @@ +directory: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/RegistryTasks +commit: ce854420f7 +repo: Azure/azure-rest-api-specs +additionalDirectories: + +emitterPackageJsonPath: eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json \ No newline at end of file diff --git a/sdk/containerregistry/ci.mgmt.yml b/sdk/containerregistry/ci.mgmt.yml index 9e8ff8803e62..123ab38b3a50 100644 --- a/sdk/containerregistry/ci.mgmt.yml +++ b/sdk/containerregistry/ci.mgmt.yml @@ -10,3 +10,5 @@ extends: Artifacts: - name: Azure.ResourceManager.ContainerRegistry safeName: AzureResourceManagerContainerRegistry + - name: Azure.ResourceManager.ContainerRegistryTasks + safeName: AzureResourceManagerContainerRegistryTasks