diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ContainerRegistryManagementClient.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ContainerRegistryManagementClient.cs index b8f5a8bb5e92..5d219608e376 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ContainerRegistryManagementClient.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ContainerRegistryManagementClient.cs @@ -91,11 +91,26 @@ public partial class ContainerRegistryManagementClient : ServiceClient public virtual IRunsOperations Runs { get; private set; } + /// + /// Gets the ITaskRunsOperations. + /// + public virtual ITaskRunsOperations TaskRuns { get; private set; } + /// /// Gets the ITasksOperations. /// public virtual ITasksOperations Tasks { get; private set; } + /// + /// Gets the IScopeMapsOperations. + /// + public virtual IScopeMapsOperations ScopeMaps { get; private set; } + + /// + /// Gets the ITokensOperations. + /// + public virtual ITokensOperations Tokens { get; private set; } + /// /// Initializes a new instance of the ContainerRegistryManagementClient class. /// @@ -342,7 +357,10 @@ private void Initialize() Replications = new ReplicationsOperations(this); Webhooks = new WebhooksOperations(this); Runs = new RunsOperations(this); + TaskRuns = new TaskRunsOperations(this); Tasks = new TasksOperations(this); + ScopeMaps = new ScopeMapsOperations(this); + Tokens = new TokensOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IContainerRegistryManagementClient.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IContainerRegistryManagementClient.cs index e245c6061829..1dcad331257e 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IContainerRegistryManagementClient.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IContainerRegistryManagementClient.cs @@ -88,10 +88,25 @@ public partial interface IContainerRegistryManagementClient : System.IDisposable /// IRunsOperations Runs { get; } + /// + /// Gets the ITaskRunsOperations. + /// + ITaskRunsOperations TaskRuns { get; } + /// /// Gets the ITasksOperations. /// ITasksOperations Tasks { get; } + /// + /// Gets the IScopeMapsOperations. + /// + IScopeMapsOperations ScopeMaps { get; } + + /// + /// Gets the ITokensOperations. + /// + ITokensOperations Tokens { get; } + } } diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IRegistriesOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IRegistriesOperations.cs index 4c90452f8283..9ea18547ab1e 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IRegistriesOperations.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IRegistriesOperations.cs @@ -329,7 +329,7 @@ public partial interface IRegistriesOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -356,7 +356,7 @@ public partial interface IRegistriesOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -367,6 +367,35 @@ public partial interface IRegistriesOperations /// System.Threading.Tasks.Task> GetBuildSourceUploadUrlWithHttpMessagesAsync(string resourceGroupName, string registryName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Generate keys for a token of a specified container registry. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The parameters for generating credentials. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> GenerateCredentialsWithHttpMessagesAsync(string resourceGroupName, string registryName, GenerateCredentialsParameters generateCredentialsParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Copies an image to this container registry from the specified /// container registry. /// @@ -495,7 +524,7 @@ public partial interface IRegistriesOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -506,6 +535,35 @@ public partial interface IRegistriesOperations /// System.Threading.Tasks.Task> BeginScheduleRunWithHttpMessagesAsync(string resourceGroupName, string registryName, RunRequest runRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Generate keys for a token of a specified container registry. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The parameters for generating credentials. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> BeginGenerateCredentialsWithHttpMessagesAsync(string resourceGroupName, string registryName, GenerateCredentialsParameters generateCredentialsParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Lists all the container registries under the specified resource /// group. /// diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IRunsOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IRunsOperations.cs index b3e05481a630..4caec984aefd 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IRunsOperations.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IRunsOperations.cs @@ -42,7 +42,7 @@ public partial interface IRunsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -71,7 +71,7 @@ public partial interface IRunsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -103,7 +103,7 @@ public partial interface IRunsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -132,7 +132,7 @@ public partial interface IRunsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -161,7 +161,7 @@ public partial interface IRunsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -190,7 +190,7 @@ public partial interface IRunsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -219,7 +219,7 @@ public partial interface IRunsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -238,7 +238,7 @@ public partial interface IRunsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IScopeMapsOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IScopeMapsOperations.cs new file mode 100644 index 000000000000..66c6295a2d43 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/IScopeMapsOperations.cs @@ -0,0 +1,305 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + + /// + /// ScopeMapsOperations operations. + /// + public partial interface IScopeMapsOperations + { + /// + /// Gets the properties of the specified scope map. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> GetWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a scope map for a container registry with the specified + /// parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The list of scoped permissions for registry artifacts. + /// E.g. repositories/repository-name/content/read, + /// repositories/repository-name/metadata/write + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> CreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, IList actions, string description = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a scope map from a container registry. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task DeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a scope map with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The list of scope permissions for registry artifacts. + /// E.g. repositories/repository-name/pull, + /// repositories/repository-name/delete + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, string description = default(string), IList actions = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the scope maps for the specified container registry. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task>> ListWithHttpMessagesAsync(string resourceGroupName, string registryName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a scope map for a container registry with the specified + /// parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The list of scoped permissions for registry artifacts. + /// E.g. repositories/repository-name/content/read, + /// repositories/repository-name/metadata/write + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, IList actions, string description = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a scope map from a container registry. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a scope map with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The list of scope permissions for registry artifacts. + /// E.g. repositories/repository-name/pull, + /// repositories/repository-name/delete + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, string description = default(string), IList actions = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the scope maps for the specified container registry. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ITaskRunsOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ITaskRunsOperations.cs new file mode 100644 index 000000000000..40c597f6ecb7 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ITaskRunsOperations.cs @@ -0,0 +1,285 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + + /// + /// TaskRunsOperations operations. + /// + public partial interface ITaskRunsOperations + { + /// + /// Gets the detailed information for a given task run. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The run request name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> GetWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a task run for a container registry with the specified + /// parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of task run. + /// + /// + /// The parameters of a run that needs to scheduled. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> CreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, TaskRun taskRun, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a specified task run resource. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task DeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a task run with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The parameters for updating a task run. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, TaskRunUpdateParameters updateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the task runs for a specified container registry. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task>> ListWithHttpMessagesAsync(string resourceGroupName, string registryName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a task run for a container registry with the specified + /// parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of task run. + /// + /// + /// The parameters of a run that needs to scheduled. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, TaskRun taskRun, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a specified task run resource. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a task run with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The parameters for updating a task run. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, TaskRunUpdateParameters updateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the task runs for a specified container registry. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ITasksOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ITasksOperations.cs index 02c631b70494..e87a1657f622 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ITasksOperations.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ITasksOperations.cs @@ -38,7 +38,7 @@ public partial interface ITasksOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -67,7 +67,7 @@ public partial interface ITasksOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -100,7 +100,7 @@ public partial interface ITasksOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -129,7 +129,7 @@ public partial interface ITasksOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -158,7 +158,7 @@ public partial interface ITasksOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -187,7 +187,7 @@ public partial interface ITasksOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -220,7 +220,7 @@ public partial interface ITasksOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -249,7 +249,7 @@ public partial interface ITasksOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -278,7 +278,7 @@ public partial interface ITasksOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -300,7 +300,7 @@ public partial interface ITasksOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ITokensOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ITokensOperations.cs new file mode 100644 index 000000000000..54ea4e6b411e --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ITokensOperations.cs @@ -0,0 +1,285 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + + /// + /// TokensOperations operations. + /// + public partial interface ITokensOperations + { + /// + /// Gets the properties of the specified token. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> GetWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a token for a container registry with the specified + /// parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for creating a token. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> CreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, Token tokenCreateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a token from a container registry. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task DeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a token with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for updating a token. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, TokenUpdateParameters tokenUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the tokens for the specified container registry. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task>> ListWithHttpMessagesAsync(string resourceGroupName, string registryName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a token for a container registry with the specified + /// parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for creating a token. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, Token tokenCreateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a token from a container registry. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a token with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry + /// belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for updating a token. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, TokenUpdateParameters tokenUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the tokens for the specified container registry. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + System.Threading.Tasks.Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/Error.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/Error.cs new file mode 100644 index 000000000000..d8a831115c61 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/Error.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// An error response from the Azure Container Registry service. + /// + public partial class Error + { + /// + /// Initializes a new instance of the Error class. + /// + public Error() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Error class. + /// + /// error code. + /// error message. + public Error(string code, string message) + { + Code = code; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets error message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Code == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Code"); + } + if (Message == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Message"); + } + } + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ErrorSchema.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ErrorSchema.cs new file mode 100644 index 000000000000..372144bd88f1 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ErrorSchema.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// An error response from the Azure Container Registry service. + /// + public partial class ErrorSchema + { + /// + /// Initializes a new instance of the ErrorSchema class. + /// + public ErrorSchema() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorSchema class. + /// + /// Azure container registry build API error + /// body. + public ErrorSchema(Error error = default(Error)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets azure container registry build API error body. + /// + [JsonProperty(PropertyName = "error")] + public Error Error { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Error != null) + { + Error.Validate(); + } + } + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ErrorSchemaException.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ErrorSchemaException.cs new file mode 100644 index 000000000000..f10eedc8fde5 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ErrorSchemaException.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorSchema information. + /// + public partial class ErrorSchemaException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ErrorSchema Body { get; set; } + + /// + /// Initializes a new instance of the ErrorSchemaException class. + /// + public ErrorSchemaException() + { + } + + /// + /// Initializes a new instance of the ErrorSchemaException class. + /// + /// The exception message. + public ErrorSchemaException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorSchemaException class. + /// + /// The exception message. + /// Inner exception. + public ErrorSchemaException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/GenerateCredentialsParameters.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/GenerateCredentialsParameters.cs new file mode 100644 index 000000000000..7df868657e6d --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/GenerateCredentialsParameters.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The parameters used to generate credentials for a specified token or + /// user of a container registry. + /// + public partial class GenerateCredentialsParameters + { + /// + /// Initializes a new instance of the GenerateCredentialsParameters + /// class. + /// + public GenerateCredentialsParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GenerateCredentialsParameters + /// class. + /// + /// The resource ID of the token for which + /// credentials have to be generated. + /// The expiry date of the generated credentials + /// after which the credentials become invalid. + /// Specifies name of the password which should be + /// regenerated if any -- password1 or password2. Possible values + /// include: 'password1', 'password2' + public GenerateCredentialsParameters(string tokenId = default(string), System.DateTime? expiry = default(System.DateTime?), string name = default(string)) + { + TokenId = tokenId; + Expiry = expiry; + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource ID of the token for which credentials + /// have to be generated. + /// + [JsonProperty(PropertyName = "tokenId")] + public string TokenId { get; set; } + + /// + /// Gets or sets the expiry date of the generated credentials after + /// which the credentials become invalid. + /// + [JsonProperty(PropertyName = "expiry")] + public System.DateTime? Expiry { get; set; } + + /// + /// Gets or sets specifies name of the password which should be + /// regenerated if any -- password1 or password2. Possible values + /// include: 'password1', 'password2' + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/GenerateCredentialsResult.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/GenerateCredentialsResult.cs new file mode 100644 index 000000000000..054a3ea3eabd --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/GenerateCredentialsResult.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The response from the GenerateCredentials operation. + /// + public partial class GenerateCredentialsResult + { + /// + /// Initializes a new instance of the GenerateCredentialsResult class. + /// + public GenerateCredentialsResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GenerateCredentialsResult class. + /// + /// The username for a container + /// registry. + /// The list of passwords for a container + /// registry. + public GenerateCredentialsResult(string username = default(string), IList passwords = default(IList)) + { + Username = username; + Passwords = passwords; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the username for a container registry. + /// + [JsonProperty(PropertyName = "username")] + public string Username { get; set; } + + /// + /// Gets or sets the list of passwords for a container registry. + /// + [JsonProperty(PropertyName = "passwords")] + public IList Passwords { get; set; } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/OperationServiceSpecificationDefinition.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/OperationServiceSpecificationDefinition.cs index fd6a6d21b2cd..b38c70091a26 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/OperationServiceSpecificationDefinition.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/OperationServiceSpecificationDefinition.cs @@ -16,7 +16,7 @@ namespace Microsoft.Azure.Management.ContainerRegistry.Models using System.Linq; /// - /// The definition of Azure Monitoring metrics list. + /// The definition of Azure Monitoring list. /// public partial class OperationServiceSpecificationDefinition { diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/RetentionPolicy.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/RetentionPolicy.cs index 3d10bdffaa32..5e3f5459d802 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/RetentionPolicy.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/RetentionPolicy.cs @@ -29,8 +29,8 @@ public RetentionPolicy() /// /// Initializes a new instance of the RetentionPolicy class. /// - /// The number of days to retain manifest before it - /// expires. + /// The number of days to retain an untagged + /// manifest after which it gets purged. /// The timestamp when the policy was /// last updated. /// The value that indicates whether the policy is @@ -50,8 +50,8 @@ public RetentionPolicy() partial void CustomInit(); /// - /// Gets or sets the number of days to retain manifest before it - /// expires. + /// Gets or sets the number of days to retain an untagged manifest + /// after which it gets purged. /// [JsonProperty(PropertyName = "days")] public int? Days { get; set; } diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ScopeMap.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ScopeMap.cs new file mode 100644 index 000000000000..1e361dca433d --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ScopeMap.cs @@ -0,0 +1,116 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An object that represents a scope map for a container registry. + /// + [Rest.Serialization.JsonTransformation] + public partial class ScopeMap : ProxyResource + { + /// + /// Initializes a new instance of the ScopeMap class. + /// + public ScopeMap() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScopeMap class. + /// + /// The list of scoped permissions for registry + /// artifacts. + /// E.g. repositories/repository-name/content/read, + /// repositories/repository-name/metadata/write + /// The resource ID. + /// The name of the resource. + /// The type of the resource. + /// The user friendly description of the + /// scope map. + /// The type of the scope map. E.g. BuildIn + /// scope map. + /// The creation date of scope map. + /// Provisioning state of the resource. + /// Possible values include: 'Creating', 'Updating', 'Deleting', + /// 'Succeeded', 'Failed', 'Canceled' + public ScopeMap(IList actions, string id = default(string), string name = default(string), string type = default(string), string description = default(string), string scopeMapType = default(string), System.DateTime? creationDate = default(System.DateTime?), string provisioningState = default(string)) + : base(id, name, type) + { + Description = description; + ScopeMapType = scopeMapType; + CreationDate = creationDate; + ProvisioningState = provisioningState; + Actions = actions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the user friendly description of the scope map. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets the type of the scope map. E.g. BuildIn scope map. + /// + [JsonProperty(PropertyName = "properties.type")] + public string ScopeMapType { get; private set; } + + /// + /// Gets the creation date of scope map. + /// + [JsonProperty(PropertyName = "properties.creationDate")] + public System.DateTime? CreationDate { get; private set; } + + /// + /// Gets provisioning state of the resource. Possible values include: + /// 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', + /// 'Canceled' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the list of scoped permissions for registry artifacts. + /// E.g. repositories/repository-name/content/read, + /// repositories/repository-name/metadata/write + /// + [JsonProperty(PropertyName = "properties.actions")] + public IList Actions { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Actions == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Actions"); + } + } + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ScopeMapUpdateParameters.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ScopeMapUpdateParameters.cs new file mode 100644 index 000000000000..da1b18ca66b1 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/ScopeMapUpdateParameters.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The properties for updating the scope map. + /// + [Rest.Serialization.JsonTransformation] + public partial class ScopeMapUpdateParameters + { + /// + /// Initializes a new instance of the ScopeMapUpdateParameters class. + /// + public ScopeMapUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScopeMapUpdateParameters class. + /// + /// The user friendly description of the + /// scope map. + /// The list of scope permissions for registry + /// artifacts. + /// E.g. repositories/repository-name/pull, + /// repositories/repository-name/delete + public ScopeMapUpdateParameters(string description = default(string), IList actions = default(IList)) + { + Description = description; + Actions = actions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the user friendly description of the scope map. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the list of scope permissions for registry artifacts. + /// E.g. repositories/repository-name/pull, + /// repositories/repository-name/delete + /// + [JsonProperty(PropertyName = "properties.actions")] + public IList Actions { get; set; } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TaskRun.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TaskRun.cs new file mode 100644 index 000000000000..8a5fc76b53e8 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TaskRun.cs @@ -0,0 +1,117 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The task run that has the ARM resource and properties. + /// The task run will have the information of request and result of a run. + /// + [Rest.Serialization.JsonTransformation] + public partial class TaskRun : Resource + { + /// + /// Initializes a new instance of the TaskRun class. + /// + public TaskRun() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TaskRun class. + /// + /// The location of the resource. This cannot be + /// changed after the resource is created. + /// The resource ID. + /// The name of the resource. + /// The type of the resource. + /// The tags of the resource. + /// Identity for the resource. + /// The provisioning state of this task + /// run. Possible values include: 'Creating', 'Updating', 'Deleting', + /// 'Succeeded', 'Failed', 'Canceled' + /// 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 + public TaskRun(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IdentityProperties identity = default(IdentityProperties), string provisioningState = default(string), RunRequest runRequest = default(RunRequest), Run runResult = default(Run), string forceUpdateTag = default(string)) + : base(location, id, name, type, tags) + { + Identity = identity; + ProvisioningState = provisioningState; + RunRequest = runRequest; + RunResult = runResult; + ForceUpdateTag = forceUpdateTag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets identity for the resource. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityProperties Identity { get; set; } + + /// + /// Gets the provisioning state of this task run. Possible values + /// include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', + /// 'Canceled' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the request (parameters) for the run + /// + [JsonProperty(PropertyName = "properties.runRequest")] + public RunRequest RunRequest { get; set; } + + /// + /// Gets the result of this task run + /// + [JsonProperty(PropertyName = "properties.runResult")] + public Run RunResult { get; private set; } + + /// + /// Gets or sets how the run should be forced to rerun even if the run + /// request configuration has not changed + /// + [JsonProperty(PropertyName = "properties.forceUpdateTag")] + public string ForceUpdateTag { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (RunResult != null) + { + RunResult.Validate(); + } + } + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TaskRunUpdateParameters.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TaskRunUpdateParameters.cs new file mode 100644 index 000000000000..82dc85f41db3 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TaskRunUpdateParameters.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The parameters for updating a task run. + /// + [Rest.Serialization.JsonTransformation] + public partial class TaskRunUpdateParameters + { + /// + /// Initializes a new instance of the TaskRunUpdateParameters class. + /// + public TaskRunUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TaskRunUpdateParameters class. + /// + /// 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 ARM resource tags. + public TaskRunUpdateParameters(IdentityProperties identity = default(IdentityProperties), RunRequest runRequest = default(RunRequest), string forceUpdateTag = default(string), IDictionary tags = default(IDictionary)) + { + Identity = identity; + RunRequest = runRequest; + ForceUpdateTag = forceUpdateTag; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets identity for the resource. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityProperties Identity { get; set; } + + /// + /// Gets or sets the request (parameters) for the new run + /// + [JsonProperty(PropertyName = "properties.runRequest")] + public RunRequest RunRequest { get; set; } + + /// + /// Gets or sets how the run should be forced to rerun even if the run + /// request configuration has not changed + /// + [JsonProperty(PropertyName = "properties.forceUpdateTag")] + public string ForceUpdateTag { get; set; } + + /// + /// Gets or sets the ARM resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/Token.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/Token.cs new file mode 100644 index 000000000000..941327d5cc1e --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/Token.cs @@ -0,0 +1,110 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// An object that represents a token for a container registry. + /// + [Rest.Serialization.JsonTransformation] + public partial class Token : ProxyResource + { + /// + /// Initializes a new instance of the Token class. + /// + public Token() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Token class. + /// + /// The resource ID. + /// The name of the resource. + /// The type of the resource. + /// The creation date of scope map. + /// Provisioning state of the resource. + /// Possible values include: 'Creating', 'Updating', 'Deleting', + /// 'Succeeded', 'Failed', 'Canceled' + /// The resource ID of the scope map to which + /// the token will be associated with. + /// The user/group/application object ID for + /// which the token has to be created. + /// The credentials that can be used for + /// authenticating the token. + /// The status of the token example enabled or + /// disabled. Possible values include: 'enabled', 'disabled' + public Token(string id = default(string), string name = default(string), string type = default(string), System.DateTime? creationDate = default(System.DateTime?), string provisioningState = default(string), string scopeMapId = default(string), string objectId = default(string), TokenCredentialsProperties credentials = default(TokenCredentialsProperties), string status = default(string)) + : base(id, name, type) + { + CreationDate = creationDate; + ProvisioningState = provisioningState; + ScopeMapId = scopeMapId; + ObjectId = objectId; + Credentials = credentials; + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the creation date of scope map. + /// + [JsonProperty(PropertyName = "properties.creationDate")] + public System.DateTime? CreationDate { get; private set; } + + /// + /// Gets provisioning state of the resource. Possible values include: + /// 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', + /// 'Canceled' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the resource ID of the scope map to which the token + /// will be associated with. + /// + [JsonProperty(PropertyName = "properties.scopeMapId")] + public string ScopeMapId { get; set; } + + /// + /// Gets or sets the user/group/application object ID for which the + /// token has to be created. + /// + [JsonProperty(PropertyName = "properties.objectId")] + public string ObjectId { get; set; } + + /// + /// Gets or sets the credentials that can be used for authenticating + /// the token. + /// + [JsonProperty(PropertyName = "properties.credentials")] + public TokenCredentialsProperties Credentials { get; set; } + + /// + /// Gets or sets the status of the token example enabled or disabled. + /// Possible values include: 'enabled', 'disabled' + /// + [JsonProperty(PropertyName = "properties.status")] + public string Status { get; set; } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenCertificate.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenCertificate.cs new file mode 100644 index 000000000000..58d68a397323 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenCertificate.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of a certificate used for authenticating a token. + /// + public partial class TokenCertificate + { + /// + /// Initializes a new instance of the TokenCertificate class. + /// + public TokenCertificate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TokenCertificate class. + /// + /// Possible values include: 'certificate1', + /// 'certificate2' + /// The expiry datetime of the + /// certificate. + /// The thumbprint of the certificate. + /// Base 64 encoded string of the + /// public certificate1 in PEM format that will be used for + /// authenticating the token. + public TokenCertificate(string name = default(string), System.DateTime? expiry = default(System.DateTime?), string thumbprint = default(string), string encodedPemCertificate = default(string)) + { + Name = name; + Expiry = expiry; + Thumbprint = thumbprint; + EncodedPemCertificate = encodedPemCertificate; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets possible values include: 'certificate1', + /// 'certificate2' + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the expiry datetime of the certificate. + /// + [JsonProperty(PropertyName = "expiry")] + public System.DateTime? Expiry { get; set; } + + /// + /// Gets or sets the thumbprint of the certificate. + /// + [JsonProperty(PropertyName = "thumbprint")] + public string Thumbprint { get; set; } + + /// + /// Gets or sets base 64 encoded string of the public certificate1 in + /// PEM format that will be used for authenticating the token. + /// + [JsonProperty(PropertyName = "encodedPemCertificate")] + public string EncodedPemCertificate { get; set; } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenCertificateName.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenCertificateName.cs new file mode 100644 index 000000000000..a975121ef70d --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenCertificateName.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + + /// + /// Defines values for TokenCertificateName. + /// + public static class TokenCertificateName + { + public const string Certificate1 = "certificate1"; + public const string Certificate2 = "certificate2"; + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenCredentialsProperties.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenCredentialsProperties.cs new file mode 100644 index 000000000000..c87fbb8cb1e8 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenCredentialsProperties.cs @@ -0,0 +1,58 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The properties of the credentials that can be used for authenticating + /// the token. + /// + public partial class TokenCredentialsProperties + { + /// + /// Initializes a new instance of the TokenCredentialsProperties class. + /// + public TokenCredentialsProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TokenCredentialsProperties class. + /// + public TokenCredentialsProperties(IList certificates = default(IList), IList passwords = default(IList)) + { + Certificates = certificates; + Passwords = passwords; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "certificates")] + public IList Certificates { get; set; } + + /// + /// + [JsonProperty(PropertyName = "passwords")] + public IList Passwords { get; set; } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenPassword.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenPassword.cs new file mode 100644 index 000000000000..55d2d276f1f8 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenPassword.cs @@ -0,0 +1,79 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The password that will be used for authenticating the token of a + /// container registry. + /// + public partial class TokenPassword + { + /// + /// Initializes a new instance of the TokenPassword class. + /// + public TokenPassword() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TokenPassword class. + /// + /// The creation datetime of the + /// password. + /// The expiry datetime of the password. + /// The password name "password1" or "password2". + /// Possible values include: 'password1', 'password2' + /// The password value. + public TokenPassword(System.DateTime? creationTime = default(System.DateTime?), System.DateTime? expiry = default(System.DateTime?), string name = default(string), string value = default(string)) + { + CreationTime = creationTime; + Expiry = expiry; + Name = name; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the creation datetime of the password. + /// + [JsonProperty(PropertyName = "creationTime")] + public System.DateTime? CreationTime { get; set; } + + /// + /// Gets or sets the expiry datetime of the password. + /// + [JsonProperty(PropertyName = "expiry")] + public System.DateTime? Expiry { get; set; } + + /// + /// Gets or sets the password name "password1" or "password2". Possible + /// values include: 'password1', 'password2' + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets the password value. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; private set; } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenPasswordName.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenPasswordName.cs new file mode 100644 index 000000000000..78d44e77dc4d --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenPasswordName.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + + /// + /// Defines values for TokenPasswordName. + /// + public static class TokenPasswordName + { + public const string Password1 = "password1"; + public const string Password2 = "password2"; + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenStatus.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenStatus.cs new file mode 100644 index 000000000000..66e28887889e --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenStatus.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + + /// + /// Defines values for TokenStatus. + /// + public static class TokenStatus + { + public const string Enabled = "enabled"; + public const string Disabled = "disabled"; + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenUpdateParameters.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenUpdateParameters.cs new file mode 100644 index 000000000000..d79f50445396 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/Models/TokenUpdateParameters.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The parameters for updating a token. + /// + [Rest.Serialization.JsonTransformation] + public partial class TokenUpdateParameters + { + /// + /// Initializes a new instance of the TokenUpdateParameters class. + /// + public TokenUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TokenUpdateParameters class. + /// + /// The resource ID of the scope map to which + /// the token will be associated with. + /// The status of the token example enabled or + /// disabled. Possible values include: 'enabled', 'disabled' + /// The credentials that can be used for + /// authenticating the token. + public TokenUpdateParameters(string scopeMapId = default(string), string status = default(string), TokenCredentialsProperties credentials = default(TokenCredentialsProperties)) + { + ScopeMapId = scopeMapId; + Status = status; + Credentials = credentials; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource ID of the scope map to which the token + /// will be associated with. + /// + [JsonProperty(PropertyName = "properties.scopeMapId")] + public string ScopeMapId { get; set; } + + /// + /// Gets or sets the status of the token example enabled or disabled. + /// Possible values include: 'enabled', 'disabled' + /// + [JsonProperty(PropertyName = "properties.status")] + public string Status { get; set; } + + /// + /// Gets or sets the credentials that can be used for authenticating + /// the token. + /// + [JsonProperty(PropertyName = "properties.credentials")] + public TokenCredentialsProperties Credentials { get; set; } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RegistriesOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RegistriesOperations.cs index c0a558dd88c0..3bbd5d365c22 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RegistriesOperations.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RegistriesOperations.cs @@ -1647,7 +1647,7 @@ internal RegistriesOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -1783,14 +1783,13 @@ internal RegistriesOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -1800,10 +1799,6 @@ internal RegistriesOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -1848,6 +1843,31 @@ internal RegistriesOperations(ContainerRegistryManagementClient client) return _result; } + /// + /// Generate keys for a token of a specified container registry. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The parameters for generating credentials. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> GenerateCredentialsWithHttpMessagesAsync(string resourceGroupName, string registryName, GenerateCredentialsParameters generateCredentialsParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginGenerateCredentialsWithHttpMessagesAsync(resourceGroupName, registryName, generateCredentialsParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + /// /// Copies an image to this container registry from the specified container /// registry. @@ -2777,7 +2797,7 @@ internal RegistriesOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -2923,6 +2943,231 @@ internal RegistriesOperations(ContainerRegistryManagementClient client) cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Generate keys for a token of a specified container registry. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The parameters for generating credentials. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginGenerateCredentialsWithHttpMessagesAsync(string resourceGroupName, string registryName, GenerateCredentialsParameters generateCredentialsParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (generateCredentialsParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "generateCredentialsParameters"); + } + string apiVersion = "2019-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("generateCredentialsParameters", generateCredentialsParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginGenerateCredentials", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(generateCredentialsParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(generateCredentialsParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -2957,7 +3202,7 @@ internal RegistriesOperations(ContainerRegistryManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -2970,7 +3215,7 @@ internal RegistriesOperations(ContainerRegistryManagementClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RegistriesOperationsExtensions.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RegistriesOperationsExtensions.cs index f9e010d7e7fe..0ccdac3dfc8b 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RegistriesOperationsExtensions.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RegistriesOperationsExtensions.cs @@ -554,6 +554,52 @@ public static SourceUploadDefinition GetBuildSourceUploadUrl(this IRegistriesOpe } } + /// + /// Generate keys for a token of a specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The parameters for generating credentials. + /// + public static GenerateCredentialsResult GenerateCredentials(this IRegistriesOperations operations, string resourceGroupName, string registryName, GenerateCredentialsParameters generateCredentialsParameters) + { + return operations.GenerateCredentialsAsync(resourceGroupName, registryName, generateCredentialsParameters).GetAwaiter().GetResult(); + } + + /// + /// Generate keys for a token of a specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The parameters for generating credentials. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task GenerateCredentialsAsync(this IRegistriesOperations operations, string resourceGroupName, string registryName, GenerateCredentialsParameters generateCredentialsParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GenerateCredentialsWithHttpMessagesAsync(resourceGroupName, registryName, generateCredentialsParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Copies an image to this container registry from the specified container /// registry. @@ -778,6 +824,52 @@ public static Run BeginScheduleRun(this IRegistriesOperations operations, string } } + /// + /// Generate keys for a token of a specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The parameters for generating credentials. + /// + public static GenerateCredentialsResult BeginGenerateCredentials(this IRegistriesOperations operations, string resourceGroupName, string registryName, GenerateCredentialsParameters generateCredentialsParameters) + { + return operations.BeginGenerateCredentialsAsync(resourceGroupName, registryName, generateCredentialsParameters).GetAwaiter().GetResult(); + } + + /// + /// Generate keys for a token of a specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The parameters for generating credentials. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginGenerateCredentialsAsync(this IRegistriesOperations operations, string resourceGroupName, string registryName, GenerateCredentialsParameters generateCredentialsParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginGenerateCredentialsWithHttpMessagesAsync(resourceGroupName, registryName, generateCredentialsParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Lists all the container registries under the specified resource group. /// diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RunsOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RunsOperations.cs index dcdfea6ef500..5b5601abc736 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RunsOperations.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/RunsOperations.cs @@ -68,7 +68,7 @@ internal RunsOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -213,14 +213,13 @@ internal RunsOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -230,10 +229,6 @@ internal RunsOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -296,7 +291,7 @@ internal RunsOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -438,14 +433,13 @@ internal RunsOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -455,10 +449,6 @@ internal RunsOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -549,7 +539,7 @@ internal RunsOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -691,14 +681,13 @@ internal RunsOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -708,10 +697,6 @@ internal RunsOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -802,7 +787,7 @@ internal RunsOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -956,14 +941,13 @@ internal RunsOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 201) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -973,10 +957,6 @@ internal RunsOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -1057,7 +1037,7 @@ internal RunsOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -1196,14 +1176,13 @@ internal RunsOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 202) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -1213,10 +1192,6 @@ internal RunsOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -1255,7 +1230,7 @@ internal RunsOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -1351,14 +1326,13 @@ internal RunsOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -1368,10 +1342,6 @@ internal RunsOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ScopeMapsOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ScopeMapsOperations.cs new file mode 100644 index 000000000000..485b38ebd645 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ScopeMapsOperations.cs @@ -0,0 +1,1554 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + + /// + /// ScopeMapsOperations operations. + /// + internal partial class ScopeMapsOperations : IServiceOperations, IScopeMapsOperations + { + /// + /// Initializes a new instance of the ScopeMapsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ScopeMapsOperations(ContainerRegistryManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ContainerRegistryManagementClient + /// + public ContainerRegistryManagementClient Client { get; private set; } + + /// + /// Gets the properties of the specified scope map. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> GetWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (scopeMapName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeMapName"); + } + if (scopeMapName != null) + { + if (scopeMapName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "scopeMapName", 50); + } + if (scopeMapName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "scopeMapName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(scopeMapName, "^[a-zA-Z0-9-_]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "scopeMapName", "^[a-zA-Z0-9-_]*$"); + } + } + string apiVersion = "2019-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("scopeMapName", scopeMapName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{scopeMapName}", System.Uri.EscapeDataString(scopeMapName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a scope map for a container registry with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The list of scoped permissions for registry artifacts. + /// E.g. repositories/repository-name/content/read, + /// repositories/repository-name/metadata/write + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> CreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, IList actions, string description = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, registryName, scopeMapName, actions, description, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a scope map from a container registry. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task DeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, registryName, scopeMapName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates a scope map with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The list of scope permissions for registry artifacts. + /// E.g. repositories/repository-name/pull, + /// repositories/repository-name/delete + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, string description = default(string), IList actions = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, registryName, scopeMapName, description, actions, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists all the scope maps for the specified container registry. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListWithHttpMessagesAsync(string resourceGroupName, string registryName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + string apiVersion = "2019-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a scope map for a container registry with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The list of scoped permissions for registry artifacts. + /// E.g. repositories/repository-name/content/read, + /// repositories/repository-name/metadata/write + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, IList actions, string description = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (scopeMapName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeMapName"); + } + if (scopeMapName != null) + { + if (scopeMapName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "scopeMapName", 50); + } + if (scopeMapName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "scopeMapName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(scopeMapName, "^[a-zA-Z0-9-_]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "scopeMapName", "^[a-zA-Z0-9-_]*$"); + } + } + if (actions == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "actions"); + } + string apiVersion = "2019-05-01-preview"; + ScopeMap scopeMapCreateParameters = new ScopeMap(); + if (description != null || actions != null) + { + scopeMapCreateParameters.Description = description; + scopeMapCreateParameters.Actions = actions; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("scopeMapName", scopeMapName); + tracingParameters.Add("scopeMapCreateParameters", scopeMapCreateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{scopeMapName}", System.Uri.EscapeDataString(scopeMapName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(scopeMapCreateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(scopeMapCreateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a scope map from a container registry. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (scopeMapName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeMapName"); + } + if (scopeMapName != null) + { + if (scopeMapName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "scopeMapName", 50); + } + if (scopeMapName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "scopeMapName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(scopeMapName, "^[a-zA-Z0-9-_]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "scopeMapName", "^[a-zA-Z0-9-_]*$"); + } + } + string apiVersion = "2019-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("scopeMapName", scopeMapName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{scopeMapName}", System.Uri.EscapeDataString(scopeMapName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a scope map with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The list of scope permissions for registry artifacts. + /// E.g. repositories/repository-name/pull, + /// repositories/repository-name/delete + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string scopeMapName, string description = default(string), IList actions = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (scopeMapName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeMapName"); + } + if (scopeMapName != null) + { + if (scopeMapName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "scopeMapName", 50); + } + if (scopeMapName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "scopeMapName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(scopeMapName, "^[a-zA-Z0-9-_]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "scopeMapName", "^[a-zA-Z0-9-_]*$"); + } + } + string apiVersion = "2019-05-01-preview"; + ScopeMapUpdateParameters scopeMapUpdateParameters = new ScopeMapUpdateParameters(); + if (description != null || actions != null) + { + scopeMapUpdateParameters.Description = description; + scopeMapUpdateParameters.Actions = actions; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("scopeMapName", scopeMapName); + tracingParameters.Add("scopeMapUpdateParameters", scopeMapUpdateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{scopeMapName}", System.Uri.EscapeDataString(scopeMapName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(scopeMapUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(scopeMapUpdateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all the scope maps for the specified container registry. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ScopeMapsOperationsExtensions.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ScopeMapsOperationsExtensions.cs new file mode 100644 index 000000000000..2879f1ce1bc7 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/ScopeMapsOperationsExtensions.cs @@ -0,0 +1,480 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + + /// + /// Extension methods for ScopeMapsOperations. + /// + public static partial class ScopeMapsOperationsExtensions + { + /// + /// Gets the properties of the specified scope map. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + public static ScopeMap Get(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName) + { + return operations.GetAsync(resourceGroupName, registryName, scopeMapName).GetAwaiter().GetResult(); + } + + /// + /// Gets the properties of the specified scope map. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task GetAsync(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, registryName, scopeMapName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a scope map for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The list of scoped permissions for registry artifacts. + /// E.g. repositories/repository-name/content/read, + /// repositories/repository-name/metadata/write + /// + /// + /// The user friendly description of the scope map. + /// + public static ScopeMap Create(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, IList actions, string description = default(string)) + { + return operations.CreateAsync(resourceGroupName, registryName, scopeMapName, actions, description).GetAwaiter().GetResult(); + } + + /// + /// Creates a scope map for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The list of scoped permissions for registry artifacts. + /// E.g. repositories/repository-name/content/read, + /// repositories/repository-name/metadata/write + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task CreateAsync(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, IList actions, string description = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, registryName, scopeMapName, actions, description, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a scope map from a container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + public static void Delete(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName) + { + operations.DeleteAsync(resourceGroupName, registryName, scopeMapName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a scope map from a container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task DeleteAsync(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, registryName, scopeMapName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates a scope map with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The list of scope permissions for registry artifacts. + /// E.g. repositories/repository-name/pull, + /// repositories/repository-name/delete + /// + public static ScopeMap Update(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, string description = default(string), IList actions = default(IList)) + { + return operations.UpdateAsync(resourceGroupName, registryName, scopeMapName, description, actions).GetAwaiter().GetResult(); + } + + /// + /// Updates a scope map with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The list of scope permissions for registry artifacts. + /// E.g. repositories/repository-name/pull, + /// repositories/repository-name/delete + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task UpdateAsync(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, string description = default(string), IList actions = default(IList), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, registryName, scopeMapName, description, actions, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the scope maps for the specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + public static IPage List(this IScopeMapsOperations operations, string resourceGroupName, string registryName) + { + return operations.ListAsync(resourceGroupName, registryName).GetAwaiter().GetResult(); + } + + /// + /// Lists all the scope maps for the specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListAsync(this IScopeMapsOperations operations, string resourceGroupName, string registryName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, registryName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a scope map for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The list of scoped permissions for registry artifacts. + /// E.g. repositories/repository-name/content/read, + /// repositories/repository-name/metadata/write + /// + /// + /// The user friendly description of the scope map. + /// + public static ScopeMap BeginCreate(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, IList actions, string description = default(string)) + { + return operations.BeginCreateAsync(resourceGroupName, registryName, scopeMapName, actions, description).GetAwaiter().GetResult(); + } + + /// + /// Creates a scope map for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The list of scoped permissions for registry artifacts. + /// E.g. repositories/repository-name/content/read, + /// repositories/repository-name/metadata/write + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginCreateAsync(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, IList actions, string description = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, registryName, scopeMapName, actions, description, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a scope map from a container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + public static void BeginDelete(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName) + { + operations.BeginDeleteAsync(resourceGroupName, registryName, scopeMapName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a scope map from a container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginDeleteAsync(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, registryName, scopeMapName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates a scope map with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The list of scope permissions for registry artifacts. + /// E.g. repositories/repository-name/pull, + /// repositories/repository-name/delete + /// + public static ScopeMap BeginUpdate(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, string description = default(string), IList actions = default(IList)) + { + return operations.BeginUpdateAsync(resourceGroupName, registryName, scopeMapName, description, actions).GetAwaiter().GetResult(); + } + + /// + /// Updates a scope map with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the scope map. + /// + /// + /// The user friendly description of the scope map. + /// + /// + /// The list of scope permissions for registry artifacts. + /// E.g. repositories/repository-name/pull, + /// repositories/repository-name/delete + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginUpdateAsync(this IScopeMapsOperations operations, string resourceGroupName, string registryName, string scopeMapName, string description = default(string), IList actions = default(IList), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, registryName, scopeMapName, description, actions, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the scope maps for the specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IScopeMapsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all the scope maps for the specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListNextAsync(this IScopeMapsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/SdkInfo_ContainerRegistryManagementClient.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/SdkInfo_ContainerRegistryManagementClient.cs index 3d8804e0c1f3..b1811aace5cb 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/SdkInfo_ContainerRegistryManagementClient.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/SdkInfo_ContainerRegistryManagementClient.cs @@ -21,10 +21,14 @@ public static IEnumerable> ApiInfo_ContainerRegist { new Tuple("ContainerRegistry", "Operations", "2019-05-01"), new Tuple("ContainerRegistry", "Registries", "2019-05-01"), + new Tuple("ContainerRegistry", "Registries", "2019-05-01-preview"), new Tuple("ContainerRegistry", "Registries", "2019-06-01-preview"), new Tuple("ContainerRegistry", "Replications", "2019-05-01"), new Tuple("ContainerRegistry", "Runs", "2019-06-01-preview"), + new Tuple("ContainerRegistry", "ScopeMaps", "2019-05-01-preview"), + new Tuple("ContainerRegistry", "TaskRuns", "2019-06-01-preview"), new Tuple("ContainerRegistry", "Tasks", "2019-06-01-preview"), + new Tuple("ContainerRegistry", "Tokens", "2019-05-01-preview"), new Tuple("ContainerRegistry", "Webhooks", "2019-05-01"), }.AsEnumerable(); } diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TaskRunsOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TaskRunsOperations.cs new file mode 100644 index 000000000000..4111d7d83ff6 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TaskRunsOperations.cs @@ -0,0 +1,1440 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + + /// + /// TaskRunsOperations operations. + /// + internal partial class TaskRunsOperations : IServiceOperations, ITaskRunsOperations + { + /// + /// Initializes a new instance of the TaskRunsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TaskRunsOperations(ContainerRegistryManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ContainerRegistryManagementClient + /// + public ContainerRegistryManagementClient Client { get; private set; } + + /// + /// Gets the detailed information for a given task run. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The run request name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> GetWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (taskRunName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "taskRunName"); + } + string apiVersion = "2019-06-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("taskRunName", taskRunName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{taskRunName}", System.Uri.EscapeDataString(taskRunName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a task run for a container registry with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of task run. + /// + /// + /// The parameters of a run that needs to scheduled. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> CreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, TaskRun taskRun, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, registryName, taskRunName, taskRun, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a specified task run resource. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task DeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, registryName, taskRunName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates a task run with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The parameters for updating a task run. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, TaskRunUpdateParameters updateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, registryName, taskRunName, updateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists all the task runs for a specified container registry. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListWithHttpMessagesAsync(string resourceGroupName, string registryName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + string apiVersion = "2019-06-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a task run for a container registry with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of task run. + /// + /// + /// The parameters of a run that needs to scheduled. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, TaskRun taskRun, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (taskRunName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "taskRunName"); + } + if (taskRun == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "taskRun"); + } + if (taskRun != null) + { + taskRun.Validate(); + } + string apiVersion = "2019-06-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("taskRunName", taskRunName); + tracingParameters.Add("taskRun", taskRun); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{taskRunName}", System.Uri.EscapeDataString(taskRunName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(taskRun != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(taskRun, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a specified task run resource. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (taskRunName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "taskRunName"); + } + string apiVersion = "2019-06-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("taskRunName", taskRunName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{taskRunName}", System.Uri.EscapeDataString(taskRunName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a task run with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The parameters for updating a task run. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string taskRunName, TaskRunUpdateParameters updateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (taskRunName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "taskRunName"); + } + if (updateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateParameters"); + } + string apiVersion = "2019-06-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("taskRunName", taskRunName); + tracingParameters.Add("updateParameters", updateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{taskRunName}", System.Uri.EscapeDataString(taskRunName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all the task runs for a specified container registry. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TaskRunsOperationsExtensions.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TaskRunsOperationsExtensions.cs new file mode 100644 index 000000000000..cc25593df7f1 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TaskRunsOperationsExtensions.cs @@ -0,0 +1,438 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + + /// + /// Extension methods for TaskRunsOperations. + /// + public static partial class TaskRunsOperationsExtensions + { + /// + /// Gets the detailed information for a given task run. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The run request name. + /// + public static TaskRun Get(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName) + { + return operations.GetAsync(resourceGroupName, registryName, taskRunName).GetAwaiter().GetResult(); + } + + /// + /// Gets the detailed information for a given task run. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The run request name. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task GetAsync(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, registryName, taskRunName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a task run for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of task run. + /// + /// + /// The parameters of a run that needs to scheduled. + /// + public static TaskRun Create(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, TaskRun taskRun) + { + return operations.CreateAsync(resourceGroupName, registryName, taskRunName, taskRun).GetAwaiter().GetResult(); + } + + /// + /// Creates a task run for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of task run. + /// + /// + /// The parameters of a run that needs to scheduled. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task CreateAsync(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, TaskRun taskRun, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, registryName, taskRunName, taskRun, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a specified task run resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + public static void Delete(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName) + { + operations.DeleteAsync(resourceGroupName, registryName, taskRunName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a specified task run resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task DeleteAsync(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, registryName, taskRunName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates a task run with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The parameters for updating a task run. + /// + public static TaskRun Update(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, TaskRunUpdateParameters updateParameters) + { + return operations.UpdateAsync(resourceGroupName, registryName, taskRunName, updateParameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a task run with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The parameters for updating a task run. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task UpdateAsync(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, TaskRunUpdateParameters updateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, registryName, taskRunName, updateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the task runs for a specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + public static IPage List(this ITaskRunsOperations operations, string resourceGroupName, string registryName) + { + return operations.ListAsync(resourceGroupName, registryName).GetAwaiter().GetResult(); + } + + /// + /// Lists all the task runs for a specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListAsync(this ITaskRunsOperations operations, string resourceGroupName, string registryName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, registryName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a task run for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of task run. + /// + /// + /// The parameters of a run that needs to scheduled. + /// + public static TaskRun BeginCreate(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, TaskRun taskRun) + { + return operations.BeginCreateAsync(resourceGroupName, registryName, taskRunName, taskRun).GetAwaiter().GetResult(); + } + + /// + /// Creates a task run for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of task run. + /// + /// + /// The parameters of a run that needs to scheduled. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginCreateAsync(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, TaskRun taskRun, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, registryName, taskRunName, taskRun, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a specified task run resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + public static void BeginDelete(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName) + { + operations.BeginDeleteAsync(resourceGroupName, registryName, taskRunName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a specified task run resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginDeleteAsync(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, registryName, taskRunName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates a task run with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The parameters for updating a task run. + /// + public static TaskRun BeginUpdate(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, TaskRunUpdateParameters updateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, registryName, taskRunName, updateParameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a task run with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The task run name. + /// + /// + /// The parameters for updating a task run. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginUpdateAsync(this ITaskRunsOperations operations, string resourceGroupName, string registryName, string taskRunName, TaskRunUpdateParameters updateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, registryName, taskRunName, updateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the task runs for a specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ITaskRunsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all the task runs for a specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListNextAsync(this ITaskRunsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TasksOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TasksOperations.cs index bbf284e9bf6e..3b81eaeb503e 100644 --- a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TasksOperations.cs +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TasksOperations.cs @@ -64,7 +64,7 @@ internal TasksOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -200,14 +200,13 @@ internal TasksOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -217,10 +216,6 @@ internal TasksOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -283,7 +278,7 @@ internal TasksOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -440,14 +435,13 @@ internal TasksOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -457,10 +451,6 @@ internal TasksOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -604,7 +594,7 @@ internal TasksOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -761,14 +751,13 @@ internal TasksOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -778,10 +767,6 @@ internal TasksOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -847,7 +832,7 @@ internal TasksOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -1019,14 +1004,13 @@ internal TasksOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 201) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -1036,10 +1020,6 @@ internal TasksOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -1120,7 +1100,7 @@ internal TasksOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -1274,14 +1254,13 @@ internal TasksOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -1291,10 +1270,6 @@ internal TasksOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -1342,7 +1317,7 @@ internal TasksOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -1510,14 +1485,13 @@ internal TasksOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 201) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -1527,10 +1501,6 @@ internal TasksOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); @@ -1605,7 +1575,7 @@ internal TasksOperations(ContainerRegistryManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -1701,14 +1671,13 @@ internal TasksOperations(ContainerRegistryManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorSchemaException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorSchema _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -1718,10 +1687,6 @@ internal TasksOperations(ContainerRegistryManagementClient client) } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TokensOperations.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TokensOperations.cs new file mode 100644 index 000000000000..02b13a6f7ee1 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TokensOperations.cs @@ -0,0 +1,1526 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + + /// + /// TokensOperations operations. + /// + internal partial class TokensOperations : IServiceOperations, ITokensOperations + { + /// + /// Initializes a new instance of the TokensOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TokensOperations(ContainerRegistryManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ContainerRegistryManagementClient + /// + public ContainerRegistryManagementClient Client { get; private set; } + + /// + /// Gets the properties of the specified token. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> GetWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (tokenName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tokenName"); + } + if (tokenName != null) + { + if (tokenName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "tokenName", 50); + } + if (tokenName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "tokenName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(tokenName, "^[a-zA-Z0-9-]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "tokenName", "^[a-zA-Z0-9-]*$"); + } + } + string apiVersion = "2019-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("tokenName", tokenName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{tokenName}", System.Uri.EscapeDataString(tokenName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a token for a container registry with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for creating a token. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> CreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, Token tokenCreateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, registryName, tokenName, tokenCreateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a token from a container registry. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task DeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, registryName, tokenName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates a token with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for updating a token. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, TokenUpdateParameters tokenUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, registryName, tokenName, tokenUpdateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists all the tokens for the specified container registry. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListWithHttpMessagesAsync(string resourceGroupName, string registryName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + string apiVersion = "2019-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a token for a container registry with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for creating a token. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, Token tokenCreateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (tokenName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tokenName"); + } + if (tokenName != null) + { + if (tokenName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "tokenName", 50); + } + if (tokenName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "tokenName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(tokenName, "^[a-zA-Z0-9-]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "tokenName", "^[a-zA-Z0-9-]*$"); + } + } + if (tokenCreateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tokenCreateParameters"); + } + string apiVersion = "2019-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("tokenName", tokenName); + tracingParameters.Add("tokenCreateParameters", tokenCreateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{tokenName}", System.Uri.EscapeDataString(tokenName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(tokenCreateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(tokenCreateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a token from a container registry. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (tokenName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tokenName"); + } + if (tokenName != null) + { + if (tokenName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "tokenName", 50); + } + if (tokenName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "tokenName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(tokenName, "^[a-zA-Z0-9-]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "tokenName", "^[a-zA-Z0-9-]*$"); + } + } + string apiVersion = "2019-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("tokenName", tokenName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{tokenName}", System.Uri.EscapeDataString(tokenName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a token with the specified parameters. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for updating a token. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string registryName, string tokenName, TokenUpdateParameters tokenUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (registryName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registryName"); + } + if (registryName != null) + { + if (registryName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "registryName", 50); + } + if (registryName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "registryName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(registryName, "^[a-zA-Z0-9]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "registryName", "^[a-zA-Z0-9]*$"); + } + } + if (tokenName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tokenName"); + } + if (tokenName != null) + { + if (tokenName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "tokenName", 50); + } + if (tokenName.Length < 5) + { + throw new ValidationException(ValidationRules.MinLength, "tokenName", 5); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(tokenName, "^[a-zA-Z0-9-]*$")) + { + throw new ValidationException(ValidationRules.Pattern, "tokenName", "^[a-zA-Z0-9-]*$"); + } + } + if (tokenUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tokenUpdateParameters"); + } + string apiVersion = "2019-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("registryName", registryName); + tracingParameters.Add("tokenName", tokenName); + tracingParameters.Add("tokenUpdateParameters", tokenUpdateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{registryName}", System.Uri.EscapeDataString(registryName)); + _url = _url.Replace("{tokenName}", System.Uri.EscapeDataString(tokenName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(tokenUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(tokenUpdateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all the tokens for the specified container registry. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TokensOperationsExtensions.cs b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TokensOperationsExtensions.cs new file mode 100644 index 000000000000..1624952dc581 --- /dev/null +++ b/sdk/containerregistry/Microsoft.Azure.Management.ContainerRegistry/src/Generated/TokensOperationsExtensions.cs @@ -0,0 +1,438 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ContainerRegistry +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + + /// + /// Extension methods for TokensOperations. + /// + public static partial class TokensOperationsExtensions + { + /// + /// Gets the properties of the specified token. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + public static Token Get(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName) + { + return operations.GetAsync(resourceGroupName, registryName, tokenName).GetAwaiter().GetResult(); + } + + /// + /// Gets the properties of the specified token. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task GetAsync(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, registryName, tokenName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a token for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for creating a token. + /// + public static Token Create(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, Token tokenCreateParameters) + { + return operations.CreateAsync(resourceGroupName, registryName, tokenName, tokenCreateParameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a token for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for creating a token. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task CreateAsync(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, Token tokenCreateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, registryName, tokenName, tokenCreateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a token from a container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + public static void Delete(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName) + { + operations.DeleteAsync(resourceGroupName, registryName, tokenName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a token from a container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task DeleteAsync(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, registryName, tokenName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates a token with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for updating a token. + /// + public static Token Update(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, TokenUpdateParameters tokenUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, registryName, tokenName, tokenUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a token with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for updating a token. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task UpdateAsync(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, TokenUpdateParameters tokenUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, registryName, tokenName, tokenUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the tokens for the specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + public static IPage List(this ITokensOperations operations, string resourceGroupName, string registryName) + { + return operations.ListAsync(resourceGroupName, registryName).GetAwaiter().GetResult(); + } + + /// + /// Lists all the tokens for the specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListAsync(this ITokensOperations operations, string resourceGroupName, string registryName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, registryName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a token for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for creating a token. + /// + public static Token BeginCreate(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, Token tokenCreateParameters) + { + return operations.BeginCreateAsync(resourceGroupName, registryName, tokenName, tokenCreateParameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a token for a container registry with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for creating a token. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginCreateAsync(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, Token tokenCreateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, registryName, tokenName, tokenCreateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a token from a container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + public static void BeginDelete(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName) + { + operations.BeginDeleteAsync(resourceGroupName, registryName, tokenName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a token from a container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginDeleteAsync(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, registryName, tokenName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates a token with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for updating a token. + /// + public static Token BeginUpdate(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, TokenUpdateParameters tokenUpdateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, registryName, tokenName, tokenUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a token with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to which the container registry belongs. + /// + /// + /// The name of the container registry. + /// + /// + /// The name of the token. + /// + /// + /// The parameters for updating a token. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginUpdateAsync(this ITokensOperations operations, string resourceGroupName, string registryName, string tokenName, TokenUpdateParameters tokenUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, registryName, tokenName, tokenUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the tokens for the specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ITokensOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all the tokens for the specified container registry. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListNextAsync(this ITokensOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}