diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/CHANGELOG.md b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/CHANGELOG.md
deleted file mode 100644
index 2f15efc6a848..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/CHANGELOG.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# Release History
-
-## 1.0.0-preview.2 (2021-02-01)
-- Fix issue #17084: Unable to create OCI manifest in Azure Container Registry
-- Fix issue #16511: Incorrect scopes passed when calling Write APIs
-
-## 1.0.0-preview.1 (2020-04-06)
-
-- Update package version to follow standard Azure-SDK-for-Net versioning guidelines
-- Require `System.IdentityModel.Tokens.Jwt >= 5.1.2` instead of `System.IdentityModel.Tokens.Jwt == 5.1.2`.
-
-## 0.10.0-preview
-
-- Support operations on Container Registry repositories, tags, manifests, blobs, access tokens and refresh tokens.
-- Autogenerate operations and models from [2019-08-15 containerregistry.json swagger spec](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/containerregistry/data-plane/Microsoft.ContainerRegistry/preview/2019-08-15/containerregistry.json).
-- Support different manifest types to allow for operations on [OCI](https://www.opencontainers.org) images.
-- Oauth2 Support.
-- Supports V2 container runtime operations. See [Docker Registry HTTP API V2 specs](https://docs.docker.com/registry/spec/api/) for more information.
-- Add customized classes (e.g. ContainerRegistryCredentials) to simplify authentication.
-
-## 0.9.0-preview.1.20190603.2
-
-- Preview release for Azure Container Registry Data plane operations
-- Support for basic container runtime operations, such as get, delete and update of manifest, repository, tags and their attributes.
-- Autogenerate operations and models from [2018-08-10 containerregistry.json swagger spec](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/containerregistry/data-plane/Microsoft.ContainerRegistry/preview/2018-08-10/containerregistry.json).
-
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/Microsoft.Azure.ContainerRegistry.sln b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/Microsoft.Azure.ContainerRegistry.sln
deleted file mode 100644
index 151b9e824af0..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/Microsoft.Azure.ContainerRegistry.sln
+++ /dev/null
@@ -1,43 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.29326.143
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.ContainerRegistry.Tests", "tests\Microsoft.Azure.ContainerRegistry.Tests.csproj", "{5D867A48-4861-43CB-BE00-65F54BE82C4E}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.ContainerRegistry", "src\Microsoft.Azure.ContainerRegistry.csproj", "{E704234A-F8FC-4648-8C2D-A1CB1BE6CCE3}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Rest.ClientRuntime.Azure.TestFramework", "..\..\mgmtcommon\TestFramework\ClientRuntime.Azure.TestFramework\Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj", "{5CCD6586-1F21-4FE3-A303-5A7080F9A11F}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Azure.Test.HttpRecorder", "..\..\mgmtcommon\TestFramework\Microsoft.Azure.Test.HttpRecorder\Microsoft.Azure.Test.HttpRecorder.csproj", "{E1B19866-98AF-49FC-B2D5-0E96F9ED378C}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {5D867A48-4861-43CB-BE00-65F54BE82C4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5D867A48-4861-43CB-BE00-65F54BE82C4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5D867A48-4861-43CB-BE00-65F54BE82C4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5D867A48-4861-43CB-BE00-65F54BE82C4E}.Release|Any CPU.Build.0 = Release|Any CPU
- {E704234A-F8FC-4648-8C2D-A1CB1BE6CCE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E704234A-F8FC-4648-8C2D-A1CB1BE6CCE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E704234A-F8FC-4648-8C2D-A1CB1BE6CCE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E704234A-F8FC-4648-8C2D-A1CB1BE6CCE3}.Release|Any CPU.Build.0 = Release|Any CPU
- {5CCD6586-1F21-4FE3-A303-5A7080F9A11F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5CCD6586-1F21-4FE3-A303-5A7080F9A11F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5CCD6586-1F21-4FE3-A303-5A7080F9A11F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5CCD6586-1F21-4FE3-A303-5A7080F9A11F}.Release|Any CPU.Build.0 = Release|Any CPU
- {E1B19866-98AF-49FC-B2D5-0E96F9ED378C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E1B19866-98AF-49FC-B2D5-0E96F9ED378C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E1B19866-98AF-49FC-B2D5-0E96F9ED378C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E1B19866-98AF-49FC-B2D5-0E96F9ED378C}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {67040A5E-5444-44DC-A7B9-7E000E6B3D92}
- EndGlobalSection
-EndGlobal
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/AuthToken.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/AuthToken.cs
deleted file mode 100644
index 393a546bf8f1..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/AuthToken.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-using Microsoft.Rest;
-using System;
-using System.IdentityModel.Tokens.Jwt;
-using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Microsoft.Azure.ContainerRegistry
-{
- ///
- /// Simple authentication credentials class for use by local clients within Token classes.
- /// i.e and
- ///
- internal class TokenCredentials : ServiceClientCredentials
- {
- private string _authHeader { get; set; }
-
- /*To be used for General Login Scheme*/
- public TokenCredentials(string username, string password)
- {
- _authHeader = Helpers.EncodeTo64($"{username}:{password}");
- }
-
- /*To be used for exchanging AAD Tokens for ACR Tokens*/
- public TokenCredentials()
- {
- _authHeader = null;
- }
-
- public override async Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
- {
- if (request == null)
- {
- throw new ArgumentNullException(nameof(request));
- }
- if (_authHeader != null)
- {
- request.Headers.Authorization = new AuthenticationHeaderValue("Basic", _authHeader);
- }
- await base.ProcessHttpRequestAsync(request, cancellationToken);
- }
- }
-
- ///
- /// AuthToken class for chaining token refreshes. It abstracts checking and refresh logic and allows for chained token refreshing.
- /// See subclasses and for more information
- ///
- public class AuthToken
- {
- public delegate string AcquireCallback();
- protected static readonly JwtSecurityTokenHandler JwtSecurityClient = new JwtSecurityTokenHandler();
-
- // Constant to refresh tokens slightly before they are to expire guarding against possible latency related crashes
- private readonly TimeSpan LatencySafety = TimeSpan.FromMinutes(2);
-
- public string Value { get; set; }
- public DateTime Expiration { get; set; }
- protected AcquireCallback RefreshFunction;
-
- public AuthToken(string token)
- {
- Value = token;
- Expiration = JwtSecurityClient.ReadToken(Value).ValidTo;
- }
-
- public AuthToken(string token, AcquireCallback refreshFunction) : this(token)
- {
- RefreshFunction = refreshFunction;
- }
-
- //Extensibility purposes
- protected AuthToken() { }
-
-
- /* Returns true if refresh was successful. */
- public bool Refresh()
- {
- if (RefreshFunction == null)
- {
- return false;
- }
- Value = RefreshFunction();
- Expiration = JwtSecurityClient.ReadToken(Value).ValidTo;
-
- return true;
- }
-
- public bool NeedsRefresh()
- {
- return Expiration < DateTime.UtcNow.Add(LatencySafety);
- }
-
- // Returns true if token is ready for use or false if token was expired and unable to refresh
- public bool CheckAndRefresh()
- {
- if (NeedsRefresh())
- return Refresh();
- return true;
- }
-
- protected void InitializeToken(AcquireCallback refreshFunction)
- {
- Value = refreshFunction();
- Expiration = JwtSecurityClient.ReadToken(Value).ValidTo;
- RefreshFunction = refreshFunction;
- }
- }
-
- ///
- /// An ACR refresh token that refreshes from an AAD access token. Provides built in token exchange functionality.
- ///
- public class ContainerRegistryRefreshToken : AuthToken
- {
- private AzureContainerRegistryClient authClient;
- public ContainerRegistryRefreshToken(AuthToken aadToken, string loginUrl)
- {
- // setup refresh function to retrieve acrtoken with aadtoken
- authClient = new AzureContainerRegistryClient(new TokenCredentials())
- {
- LoginUri = $"https://{loginUrl}"
- };
-
- string tempRefreshFunction()
- {
- // Note: should be using real new access token
- aadToken.CheckAndRefresh();
- return authClient.RefreshTokens.GetFromExchangeAsync("access_token", loginUrl, "", null, aadToken.Value).GetAwaiter().GetResult().RefreshTokenProperty;
- }
-
- // initialize token and refresh function
- InitializeToken(tempRefreshFunction);
- }
- }
-
- ///
- /// An ACR access token that refreshes from an ACR refresh token or username and password.
- ///
- public class ContainerRegistryAccessToken : AuthToken
- {
- private AzureContainerRegistryClient authClient;
- public string Scope { get; set; }
- ///
- /// Construct an ACR access token that refreshes from an ACR refresh token.
- ///
- ///
- ///
- ///
- public ContainerRegistryAccessToken(ContainerRegistryRefreshToken refreshToken, string scope, string loginUrl)
- {
- Scope = scope;
- authClient = new AzureContainerRegistryClient(new TokenCredentials())
- {
- LoginUri = $"https://{loginUrl}"
- };
- string tempRefreshFunction()
- {
- refreshToken.CheckAndRefresh();
- return authClient.AccessTokens.GetAsync(loginUrl, scope, refreshToken.Value).GetAwaiter().GetResult().AccessTokenProperty;
- };
-
- // initialize token and refresh function
- InitializeToken(tempRefreshFunction);
- }
-
- ///
- /// Construct an ACR access token that refreshes from an ACR refresh token.
- ///
- ///
- ///
- ///
- ///
- public ContainerRegistryAccessToken(string username, string password, string scope, string loginUrl)
- {
- Scope = scope;
- authClient = new AzureContainerRegistryClient(new TokenCredentials(username, password))
- {
- LoginUri = $"https://{loginUrl}"
- };
- string tempRefreshFunction()
- {
- return authClient.AccessTokens.GetFromLoginAsync(loginUrl, scope).GetAwaiter().GetResult().AccessTokenProperty;
- };
-
- // initialize token and refresh function
- InitializeToken(tempRefreshFunction);
- }
- }
-}
-
-
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/AzureContainerRegistryClientExtended.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/AzureContainerRegistryClientExtended.cs
deleted file mode 100644
index 6a507d23cb98..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/AzureContainerRegistryClientExtended.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-using Microsoft.Rest;
-using Microsoft.Rest.Azure;
-using System.Net.Http;
-namespace Microsoft.Azure.ContainerRegistry
-{
- public partial class AzureContainerRegistryClient : ServiceClient, IAzureContainerRegistryClient, IAzureClient
- {
-
- // MANUALLY ADDED FOR INTERNAL TEST PURPOSES / FOR TESTING FRAMEWORK USE ONLY
- ///
- /// Initializes a new instance of the AzureContainerRegistryClient class.
- ///
- ///
- /// Optional. The base URI of the service.
- ///
- ///
- /// Required. Credentials needed for the client to connect to Azure.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
-
- internal AzureContainerRegistryClient(System.Uri loginUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
- {
- if (loginUri == null)
- {
- throw new System.ArgumentNullException(nameof(loginUri));
- }
-
- BaseUri = "{url}";
- Credentials = credentials ?? throw new System.ArgumentNullException(nameof(credentials));
- if (Credentials != null)
-
- {
- Credentials.InitializeServiceClient(this);
- }
-
- }
-
- ///
- /// Initializes a new instance of the AzureContainerRegistryClient class. Allows users to specify a loginUrl
- ///
- ///
- /// Required The base URl of the Azure Container Registry Service
- ///
- ///
- /// Required. Credentials needed for the client to connect to Azure.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- public AzureContainerRegistryClient(string loginUrl, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
- {
- if (credentials == null)
- {
- throw new System.ArgumentNullException("credentials");
- }
-
- // prevents issues if caller sets an incorrect '/' at the end
- if (loginUrl.EndsWith("/")) {
- loginUrl = loginUrl.Substring(0, loginUrl.Length - 1);
- }
-
- // prevents issues if caller does not prefix url with "http"
- if (!loginUrl.ToLower().StartsWith("http"))
- {
- loginUrl = $"https://{loginUrl}";
- }
-
- // set fields / properties
- LoginUri = loginUrl;
- Credentials = credentials;
- Credentials.InitializeServiceClient(this);
- }
- }
-
-}
-
-
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/ContainerRegistryCredentials.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/ContainerRegistryCredentials.cs
deleted file mode 100644
index 28a2856d08c7..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/ContainerRegistryCredentials.cs
+++ /dev/null
@@ -1,331 +0,0 @@
-using Microsoft.Rest;
-using System;
-using System.Collections.Generic;
-using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Text.RegularExpressions;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Microsoft.Azure.ContainerRegistry
-{
-
- ///
- /// Robust handling of Basic and OAUTH2 authentication flows for the Azure Container Registry Runtime .Net SDK.
- /// This class handles Basic Authentication as well as JWT token authentication using both username and password
- /// routes as well as through exchanging AAD tokens.
- ///
- public class ContainerRegistryCredentials : ServiceClientCredentials
- {
-
- #region Definitions
-
- ///
- /// Authentication type
- ///
- public enum LoginMode
- {
- /// Basic authentication
- Basic,
- /// Authentication using oauth2 with login and password
- TokenAuth,
- /// Authentication using an AAD access token.
- TokenAad
- }
-
- #endregion
-
- #region Instance Variables
- private string _authHeader { get; set; }
- private LoginMode _mode { get; set; }
- private string _loginServerUrl { get; set; } // does not contain scheme prefix (e.g. "https://")
- private string _username { get; set; }
- private string _password { get; set; }
- private CancellationToken _requestCancellationToken { get; set; }
-
- // Structure : Scope : Token
- // Key Scope retrieved from header from service which shouldn't change culture.
- private Dictionary _acrAccessTokens = new Dictionary(StringComparer.OrdinalIgnoreCase);
-
- // Structure : Method>Operation : Scope
- // Key contains operation url which could potentially change culture...
- private Dictionary _acrScopes = new Dictionary(StringComparer.OrdinalIgnoreCase);
-
- // Internal simplified client for Token Acquisition
- private ContainerRegistryRefreshToken _acrRefresh;
- private AuthToken _aadAccess;
- private const string pattern = "\".+:.+:.+\""; //Pattern to get the scope from headers
- private static readonly Regex scopeFromHeaderRegex = new Regex(pattern);
-
- #endregion
-
- #region Constructors
-
- ///
- /// Construct a ContainerRegistryCredentials object from user credentials. Users may specify basic authentication or the more secure oauth2 (token) based authentication.
- /// Throws an exception if LoginMode is set to TokenAad
- /// The credential acquisition mode, one of Basic, TokenAuth, or TokenAad
- /// The url of the registry to be used
- /// The username for the registry
- /// The password for the registry
- ///
- public ContainerRegistryCredentials(LoginMode mode, string loginUrl, string username, string password, CancellationToken cancellationToken = default)
- {
- if (mode == LoginMode.TokenAad)
- {
- throw new ArgumentException("This constructor does not permit AAD Authentication. Please use an appropriate constructor.");
- }
-
- _mode = mode;
- _loginServerUrl = ProcessLoginUrl(loginUrl);
- _username = username;
- _password = password;
- _requestCancellationToken = cancellationToken;
-
- if (_mode == LoginMode.Basic) // Basic Authentication
- {
- _authHeader = Helpers.EncodeTo64($"{_username}:{_password}");
- }
- }
-
- ///
- /// Construct a ContainerRegistryCredentials object from an AAD Token. A callback can be provided to renew the AAD token when it expires.
- /// The password for the registry
- /// The Azure active directory access token to be used
- /// The tenant of the aad access token (optional)
- /// Callback function to refresh the . Without this parameter, the AAD token cannot be refreshed.
- ///
- public ContainerRegistryCredentials(string aadAccessToken, string loginUrl, AuthToken.AcquireCallback acquireNewAad = null, CancellationToken cancellationToken = default)
- {
- _mode = LoginMode.TokenAad;
- _loginServerUrl = ProcessLoginUrl(loginUrl);
- _requestCancellationToken = cancellationToken;
- _aadAccess = new AuthToken(aadAccessToken, acquireNewAad);
- _acrRefresh = new ContainerRegistryRefreshToken(_aadAccess, _loginServerUrl);
- }
-
- #endregion
-
- #region Overrides
-
- ///
- /// Called on initialization of client. Sets the Client's LoginUri from the Credentials LoginUrl.
- ///
- public override void InitializeServiceClient(ServiceClient client)
- {
- if (client == null)
- {
- throw new ArgumentNullException(nameof(client));
- }
-
- // if this is an ACRClient, add the loginUri that this credential was created for
- if (client is AzureContainerRegistryClient acrClient)
- {
- if (string.IsNullOrEmpty(acrClient.LoginUri))
- {
- acrClient.LoginUri = $"https://{this._loginServerUrl}";
- }
- // if the login uris don't match
- else if (acrClient.LoginUri.ToLowerInvariant() != this._loginServerUrl.ToLowerInvariant())
- {
- throw new ValidationException($"\"{nameof(AzureContainerRegistryClient)}'s\" LoginUrl: '{acrClient.LoginUri}' does not match \"{nameof(ContainerRegistryCredentials)} LoginUrl: '{this._loginServerUrl}'");
- }
- }
- }
-
- ///
- /// Apply the credentials to the HTTP request.
- ///
- public override async Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
- {
- if (request == null)
- {
- throw new ArgumentNullException(nameof(request));
- }
-
- if (_mode == LoginMode.Basic)
- {
- request.Headers.Authorization = new AuthenticationHeaderValue("Basic", _authHeader);
- }
- else
- {
- string operation = $"https://{_loginServerUrl}{request.RequestUri.AbsolutePath}";
- string scope = await GetScope(operation, request.Method.Method, request.RequestUri.AbsolutePath);
-
- request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {GetAcrAccessToken(scope)}");
- }
-
- await base.ProcessHttpRequestAsync(request, cancellationToken);
- }
-
- #endregion
-
- #region Helpers
-
- private static string ProcessLoginUrl(string loginUrl)
- {
- // in case passed in loginurl includes https start. We also don't want 'http://' to be in the url.
- string[] schemes = new string[] { "https://", "http://" };
- foreach (var scheme in schemes)
- {
- if (loginUrl.ToLower().StartsWith(scheme))
- {
- loginUrl.Substring(scheme.Length);
- break; // strip at most once.
- }
- }
-
- if (loginUrl.EndsWith("/"))
- {
- loginUrl.Substring(0, loginUrl.Length - 1);
- }
-
- return loginUrl;
- }
-
- ///
- /// Acquires a new ACR access token if necessary. It can also acquire a cached access token in order to avoid extra requests to
- /// the oauth2 endpoint improving efficiency.
- /// The scope for the particuar operation. Can be obtained from the Www-Authenticate header.
- ///
- private string GetAcrAccessToken(string scope)
- {
- if (_mode == LoginMode.Basic)
- {
- throw new Exception("This Function cannot be invoked for requested Login Mode. Basic Authentication does not support JWT Tokens ");
- }
-
- // if token is stale, hit refresh
- if (_acrAccessTokens.TryGetValue(scope, out ContainerRegistryAccessToken token))
- {
- if (!token.CheckAndRefresh())
- {
- throw new Exception($"Access Token for scope {scope} expired and could not be refreshed");
- }
-
- return token.Value;
- }
-
- if (_mode == LoginMode.TokenAad)
- {
- _acrAccessTokens[scope] = new ContainerRegistryAccessToken(_acrRefresh, scope, _loginServerUrl);
- }
- else if (_mode == LoginMode.TokenAuth)
- {
- _acrAccessTokens[scope] = new ContainerRegistryAccessToken(_username, _password, scope, _loginServerUrl);
- }
-
- return _acrAccessTokens[scope].Value;
- }
-
- ///
- /// Acquires the required scope for a specific operation. This will be done by obtaining a challenge and parsing out the scope
- /// from the ww-Authenticate header. In the event of failure (Some endpoints do not seem to return the scope) it will attempt
- /// resolution through a local resolver .
- /// The scope for the particuar operation. Can be obtained from the Www-Authenticate header.
- ///
-
- private async Task GetScope(string operation, string method, string path)
- {
- string methodOperationKey = $"{method}>{operation}";
-
- if (_acrScopes.TryGetValue(methodOperationKey, out string result))
- {
- return result;
- }
-
- string scope;
- try
- {
- HttpClient runtimeClient = new HttpClient();
- HttpResponseMessage response = await runtimeClient.SendAsync(new HttpRequestMessage(new HttpMethod(method), operation));
- scope = GetScopeFromHeaders(response.Headers)?? ResolveScopeLocally(path);
- _acrScopes[methodOperationKey] = scope;
- }
- catch (Exception e)
- {
- throw new Exception($"Could not identify appropriate Token scope: {e.Message}");
- }
- return scope;
- }
-
- ///
- /// Local resolver for endpoints that will often return no scope.
- /// Operation for which a scope is necessary
- ///
- private string ResolveScopeLocally(string operation)
- {
- const string v1Operation = "/acr/v1/_catalog";
- const string v2Operation = "/v2/";
- switch (operation)
- {
- case v1Operation:
- case v2Operation:
- return "registry:catalog:*";
- default:
- throw new Exception("Could not determine appropriate scope for the specified operation");
- }
- }
-
- ///
- /// Parse value of scope key from the 'Www-Authenticate' challenge header. See RFC 7235 section 4.1 for more info on the
- /// Ex challenge header value:
- /// Bearer realm="https://test.azurecr.io/oauth2/token",service="test.azurecr.io",scope="repository:hello-txt:metadata_read"
- /// Return null if it is not present
- ///
- public string GetScopeFromHeaders(HttpHeaders headers)
- {
- if (headers == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, nameof(headers));
- }
-
- string challengeHeader = "Www-Authenticate".ToLower();
- string headerValue = "";
- foreach (var headerKVP in headers)
- {
- if (headerKVP.Key.ToLower() == challengeHeader)
- {
- headerValue = string.Join(",", headerKVP.Value);
-
- break;
- }
- }
-
- int position = headerValue.IndexOf("scope=");
- string scope = headerValue.Substring(position);
- string[] keyValues = scope.Split('=');
- int length = keyValues.Length;
-
- if (length < 2)
- {
- throw new Exception($"Could not find a scope in the {headerValue}");
- }
- else if(length > 2)
- {
- string scopeContainedIn = keyValues[1];
- return TrimDoubleQuotes(scopeFromHeaderRegex.Match(scopeContainedIn).Value);
- }
- else
- {
- return TrimDoubleQuotes(keyValues[1]);
- }
- }
-
- ///
- /// Removes trailing whitespace or " characters.
- ///
- private string TrimDoubleQuotes(string toTrim)
- {
- toTrim = toTrim.Trim();
- if (toTrim.StartsWith("\"")) toTrim = toTrim.Substring(1);
- if (toTrim.EndsWith("\"")) toTrim = toTrim.Substring(0, toTrim.Length - 1);
- return toTrim;
- }
-
- #endregion
- }
-}
-
-
-
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/Helpers.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/Helpers.cs
deleted file mode 100644
index c0bed5595d7d..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/Helpers.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.Text;
-
-namespace Microsoft.Azure.ContainerRegistry
-{
- ///
- /// Helper methods for the Microsoft.Azure.ContainerRegistry Package
- ///
- internal class Helpers
- {
- static public string EncodeTo64(string toEncode)
- {
- byte[] toEncodeAsBytes = Encoding.ASCII.GetBytes(toEncode);
- string returnValue = Convert.ToBase64String(toEncodeAsBytes);
- return returnValue;
- }
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/ManifestConvertions.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/ManifestConvertions.cs
deleted file mode 100644
index 6b6b9a93ba53..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Customizations/ManifestConvertions.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-
-namespace Microsoft.Azure.ContainerRegistry.Models
-{
- public partial class V2Manifest : Manifest
- {
- ///
- /// Provides a method to convert ManifestWrapper to V2Manifest
- ///
- public static explicit operator V2Manifest(ManifestWrapper v)
- {
- var manifest = new V2Manifest
- {
- Layers = v.Layers,
- SchemaVersion = v.SchemaVersion,
- Config = v.Config,
- MediaType = v.MediaType
- };
- return manifest;
- }
- }
-
- public partial class V1Manifest : Manifest
- {
- ///
- /// Provides a method to convert ManifestWrapper to V1Manifest
- ///
- public static explicit operator V1Manifest(ManifestWrapper v)
- {
- var manifest = new V1Manifest
- {
- Architecture = v.Architecture,
- FsLayers = v.FsLayers,
- History = v.History,
- Name = v.Name,
- Signatures = v.Signatures,
- Tag = v.Tag,
- SchemaVersion = v.SchemaVersion,
- MediaType=v.MediaType
- };
- return manifest;
- }
- }
-
- public partial class ManifestList : Manifest
- {
- ///
- /// Provides a method to convert ManifestWrapper to ManifestList
- ///
- public static explicit operator ManifestList(ManifestWrapper v)
- {
- var manifest = new ManifestList
- {
- Manifests = v.Manifests,
- SchemaVersion = v.SchemaVersion,
- MediaType = v.MediaType
- };
- return manifest;
- }
- }
-
- public partial class OCIIndex : Manifest
- {
- ///
- /// Provides a method to convert ManifestWrapper to OCIIndex
- ///
- public static explicit operator OCIIndex(ManifestWrapper v)
- {
- var manifest = new OCIIndex
- {
- Manifests = v.Manifests,
- SchemaVersion = v.SchemaVersion,
- Annotations = v.Annotations,
- MediaType=v.MediaType
- };
- return manifest;
- }
- }
-
- public partial class OCIManifest : Manifest
- {
- ///
- /// Provides a method to convert ManifestWrapper to OCIManifest
- ///
- public static explicit operator OCIManifest(ManifestWrapper v)
- {
- var manifest = new OCIManifest
- {
- Layers = v.Layers,
- SchemaVersion = v.SchemaVersion,
- Config = v.Config,
- Annotations = v.Annotations,
- MediaType=v.MediaType
- };
- return manifest;
- }
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperations.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperations.cs
deleted file mode 100644
index 3b0cc40b1527..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperations.cs
+++ /dev/null
@@ -1,457 +0,0 @@
-//
-// 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.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;
- using System.Threading.Tasks;
-
- ///
- /// AccessTokensOperations operations.
- ///
- internal partial class AccessTokensOperations : IServiceOperations, IAccessTokensOperations
- {
- ///
- /// Initializes a new instance of the AccessTokensOperations class.
- ///
- ///
- /// Reference to the service client.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- internal AccessTokensOperations(AzureContainerRegistryClient client)
- {
- if (client == null)
- {
- throw new System.ArgumentNullException("client");
- }
- Client = client;
- }
-
- ///
- /// Gets a reference to the AzureContainerRegistryClient
- ///
- public AzureContainerRegistryClient Client { get; private set; }
-
- ///
- /// Exchange ACR Refresh token for an ACR Access Token
- ///
- ///
- /// Indicates the name of your Azure container registry.
- ///
- ///
- /// Which is expected to be a valid scope, and can be specified more than once
- /// for multiple scope requests. You obtained this from the Www-Authenticate
- /// response header from the challenge.
- ///
- ///
- /// Must be a valid ACR refresh 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 Task> GetWithHttpMessagesAsync(string service, string scope, string refreshToken, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (service == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "service");
- }
- if (scope == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "scope");
- }
- if (refreshToken == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "refreshToken");
- }
- string grantType = "refresh_token";
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("grantType", grantType);
- tracingParameters.Add("service", service);
- tracingParameters.Add("scope", scope);
- tracingParameters.Add("refreshToken", refreshToken);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "oauth2/token";
- _url = _url.Replace("{url}", Client.LoginUri);
- 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("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;
- var values = new List>();
- if(grantType != null)
- {
- values.Add(new KeyValuePair("grant_type", grantType));
- }
- if(service != null)
- {
- values.Add(new KeyValuePair("service", service));
- }
- if(scope != null)
- {
- values.Add(new KeyValuePair("scope", scope));
- }
- if(refreshToken != null)
- {
- values.Add(new KeyValuePair("refresh_token", refreshToken));
- }
- var _formContent = new FormUrlEncodedContent(values);
- _httpRequest.Content = _formContent;
- // 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 AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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;
- }
-
- ///
- /// Exchange Username, Password and Scope an ACR Access Token
- ///
- ///
- /// Indicates the name of your Azure container registry.
- ///
- ///
- /// Expected to be a valid scope, and can be specified more than once for
- /// multiple scope requests. You can obtain this from the Www-Authenticate
- /// response header from the challenge.
- ///
- ///
- /// 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 Task> GetFromLoginWithHttpMessagesAsync(string service, string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (service == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "service");
- }
- if (scope == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "scope");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("service", service);
- tracingParameters.Add("scope", scope);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "GetFromLogin", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "oauth2/token";
- _url = _url.Replace("{url}", Client.LoginUri);
- List _queryParameters = new List();
- if (service != null)
- {
- _queryParameters.Add(string.Format("service={0}", System.Uri.EscapeDataString(service)));
- }
- if (scope != null)
- {
- _queryParameters.Add(string.Format("scope={0}", System.Uri.EscapeDataString(scope)));
- }
- 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 AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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.ContainerRegistry/src/Generated/AccessTokensOperationsExtensions.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperationsExtensions.cs
deleted file mode 100644
index 3420f387fd0b..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperationsExtensions.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// Extension methods for AccessTokensOperations.
- ///
- public static partial class AccessTokensOperationsExtensions
- {
- ///
- /// Exchange ACR Refresh token for an ACR Access Token
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Indicates the name of your Azure container registry.
- ///
- ///
- /// Which is expected to be a valid scope, and can be specified more than once
- /// for multiple scope requests. You obtained this from the Www-Authenticate
- /// response header from the challenge.
- ///
- ///
- /// Must be a valid ACR refresh token
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task GetAsync(this IAccessTokensOperations operations, string service, string scope, string refreshToken, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.GetWithHttpMessagesAsync(service, scope, refreshToken, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Exchange Username, Password and Scope an ACR Access Token
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Indicates the name of your Azure container registry.
- ///
- ///
- /// Expected to be a valid scope, and can be specified more than once for
- /// multiple scope requests. You can obtain this from the Www-Authenticate
- /// response header from the challenge.
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task GetFromLoginAsync(this IAccessTokensOperations operations, string service, string scope, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.GetFromLoginWithHttpMessagesAsync(service, scope, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/AzureContainerRegistryClient.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/AzureContainerRegistryClient.cs
deleted file mode 100644
index 735420bc400d..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/AzureContainerRegistryClient.cs
+++ /dev/null
@@ -1,274 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Microsoft.Rest.Serialization;
- using Models;
- using Newtonsoft.Json;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
-
- ///
- /// Metadata API definition for the Azure Container Registry runtime
- ///
- public partial class AzureContainerRegistryClient : ServiceClient, IAzureContainerRegistryClient, IAzureClient
- {
- ///
- /// The base URI of the service.
- ///
- internal string BaseUri {get; set;}
-
- ///
- /// Gets or sets json serialization settings.
- ///
- public JsonSerializerSettings SerializationSettings { get; private set; }
-
- ///
- /// Gets or sets json deserialization settings.
- ///
- public JsonSerializerSettings DeserializationSettings { get; private set; }
-
- ///
- /// Credentials needed for the client to connect to Azure.
- ///
- public ServiceClientCredentials Credentials { get; private set; }
-
- ///
- /// Registry login URL
- ///
- public string LoginUri { get; set; }
-
- ///
- /// The preferred language for the response.
- ///
- public string AcceptLanguage { get; set; }
-
- ///
- /// The retry timeout in seconds for Long Running Operations. Default value is
- /// 30.
- ///
- public int? LongRunningOperationRetryTimeout { get; set; }
-
- ///
- /// Whether a unique x-ms-client-request-id should be generated. When set to
- /// true a unique x-ms-client-request-id value is generated and included in
- /// each request. Default is true.
- ///
- public bool? GenerateClientRequestId { get; set; }
-
- ///
- /// Gets the IV2SupportOperations.
- ///
- public virtual IV2SupportOperations V2Support { get; private set; }
-
- ///
- /// Gets the IManifestsOperations.
- ///
- public virtual IManifestsOperations Manifests { get; private set; }
-
- ///
- /// Gets the IBlobOperations.
- ///
- public virtual IBlobOperations Blob { get; private set; }
-
- ///
- /// Gets the IRepositoryOperations.
- ///
- public virtual IRepositoryOperations Repository { get; private set; }
-
- ///
- /// Gets the ITagOperations.
- ///
- public virtual ITagOperations Tag { get; private set; }
-
- ///
- /// Gets the IRefreshTokensOperations.
- ///
- public virtual IRefreshTokensOperations RefreshTokens { get; private set; }
-
- ///
- /// Gets the IAccessTokensOperations.
- ///
- public virtual IAccessTokensOperations AccessTokens { get; private set; }
-
- ///
- /// Initializes a new instance of the AzureContainerRegistryClient class.
- ///
- ///
- /// HttpClient to be used
- ///
- ///
- /// True: will dispose the provided httpClient on calling AzureContainerRegistryClient.Dispose(). False: will not dispose provided httpClient
- protected AzureContainerRegistryClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
- {
- Initialize();
- }
-
- ///
- /// Initializes a new instance of the AzureContainerRegistryClient class.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- protected AzureContainerRegistryClient(params DelegatingHandler[] handlers) : base(handlers)
- {
- Initialize();
- }
-
- ///
- /// Initializes a new instance of the AzureContainerRegistryClient class.
- ///
- ///
- /// Optional. The http client handler used to handle http transport.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- protected AzureContainerRegistryClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
- {
- Initialize();
- }
-
- ///
- /// Initializes a new instance of the AzureContainerRegistryClient class.
- ///
- ///
- /// Required. Credentials needed for the client to connect to Azure.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- public AzureContainerRegistryClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
- {
- if (credentials == null)
- {
- throw new System.ArgumentNullException("credentials");
- }
- Credentials = credentials;
- if (Credentials != null)
- {
- Credentials.InitializeServiceClient(this);
- }
- }
-
- ///
- /// Initializes a new instance of the AzureContainerRegistryClient class.
- ///
- ///
- /// Required. Credentials needed for the client to connect to Azure.
- ///
- ///
- /// HttpClient to be used
- ///
- ///
- /// True: will dispose the provided httpClient on calling AzureContainerRegistryClient.Dispose(). False: will not dispose provided httpClient
- ///
- /// Thrown when a required parameter is null
- ///
- public AzureContainerRegistryClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient)
- {
- if (credentials == null)
- {
- throw new System.ArgumentNullException("credentials");
- }
- Credentials = credentials;
- if (Credentials != null)
- {
- Credentials.InitializeServiceClient(this);
- }
- }
-
- ///
- /// Initializes a new instance of the AzureContainerRegistryClient class.
- ///
- ///
- /// Required. Credentials needed for the client to connect to Azure.
- ///
- ///
- /// Optional. The http client handler used to handle http transport.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- public AzureContainerRegistryClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
- {
- if (credentials == null)
- {
- throw new System.ArgumentNullException("credentials");
- }
- Credentials = credentials;
- if (Credentials != null)
- {
- Credentials.InitializeServiceClient(this);
- }
- }
-
- ///
- /// An optional partial-method to perform custom initialization.
- ///
- partial void CustomInitialize();
- ///
- /// Initializes client properties.
- ///
- private void Initialize()
- {
- V2Support = new V2SupportOperations(this);
- Manifests = new ManifestsOperations(this);
- Blob = new BlobOperations(this);
- Repository = new RepositoryOperations(this);
- Tag = new TagOperations(this);
- RefreshTokens = new RefreshTokensOperations(this);
- AccessTokens = new AccessTokensOperations(this);
- BaseUri = "{url}";
- AcceptLanguage = "en-US";
- LongRunningOperationRetryTimeout = 30;
- GenerateClientRequestId = true;
- SerializationSettings = new JsonSerializerSettings
- {
- Formatting = Newtonsoft.Json.Formatting.Indented,
- DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
- DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
- NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
- ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
- ContractResolver = new ReadOnlyJsonContractResolver(),
- Converters = new List
- {
- new Iso8601TimeSpanConverter()
- }
- };
- DeserializationSettings = new JsonSerializerSettings
- {
- DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
- DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
- NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
- ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
- ContractResolver = new ReadOnlyJsonContractResolver(),
- Converters = new List
- {
- new Iso8601TimeSpanConverter()
- }
- };
- CustomInitialize();
- DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
- }
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperations.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperations.cs
deleted file mode 100644
index 3092d0aa255a..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperations.cs
+++ /dev/null
@@ -1,2059 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using Newtonsoft.Json;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// BlobOperations operations.
- ///
- internal partial class BlobOperations : IServiceOperations, IBlobOperations
- {
- ///
- /// Initializes a new instance of the BlobOperations class.
- ///
- ///
- /// Reference to the service client.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- internal BlobOperations(AzureContainerRegistryClient client)
- {
- if (client == null)
- {
- throw new System.ArgumentNullException("client");
- }
- Client = client;
- }
-
- ///
- /// Gets a reference to the AzureContainerRegistryClient
- ///
- public AzureContainerRegistryClient Client { get; private set; }
-
- ///
- /// Retrieve the blob from the registry identified by digest.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// 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 Task> GetWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "name");
- }
- if (digest == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "digest");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("name", name);
- tracingParameters.Add("digest", digest);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/{digest}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
- _url = _url.Replace("{digest}", System.Uri.EscapeDataString(digest));
- 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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 200 && (int)_statusCode != 307)
- {
- 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)
- {
- _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
- }
- try
- {
- _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Same as GET, except only the headers are returned.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// 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 Task> CheckWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "name");
- }
- if (digest == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "digest");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("name", name);
- tracingParameters.Add("digest", digest);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "Check", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/{digest}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
- _url = _url.Replace("{digest}", System.Uri.EscapeDataString(digest));
- 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("HEAD");
- _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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 200 && (int)_statusCode != 307)
- {
- var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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 AzureOperationHeaderResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_httpResponse.Headers.Contains("x-ms-request-id"))
- {
- _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
- }
- try
- {
- _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Removes an already uploaded blob.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// 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 Task> DeleteWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "name");
- }
- if (digest == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "digest");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("name", name);
- tracingParameters.Add("digest", digest);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/{digest}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
- _url = _url.Replace("{digest}", System.Uri.EscapeDataString(digest));
- 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("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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 202)
- {
- 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 == 202)
- {
- _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
- }
- try
- {
- _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Mount a blob identified by the `mount` parameter from another repository.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Name of the source repository.
- ///
- ///
- /// Digest of blob to mount from the source repository.
- ///
- ///
- /// 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 Task> MountWithHttpMessagesAsync(string name, string fromParameter, string mount, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "name");
- }
- if (fromParameter == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "fromParameter");
- }
- if (mount == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "mount");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("name", name);
- tracingParameters.Add("fromParameter", fromParameter);
- tracingParameters.Add("mount", mount);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "Mount", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/uploads/";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
- List _queryParameters = new List();
- if (fromParameter != null)
- {
- _queryParameters.Add(string.Format("from={0}", System.Uri.EscapeDataString(fromParameter)));
- }
- if (mount != null)
- {
- _queryParameters.Add(string.Format("mount={0}", System.Uri.EscapeDataString(mount)));
- }
- 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;
- // 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 != 201)
- {
- var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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 AzureOperationHeaderResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_httpResponse.Headers.Contains("x-ms-request-id"))
- {
- _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
- }
- try
- {
- _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Retrieve status of upload identified by uuid. The primary purpose of this
- /// endpoint is to resolve the current status of a resumable upload.
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not include
- /// initial / (must do substring(1) )
- ///
- ///
- /// 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 Task> GetStatusWithHttpMessagesAsync(string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (location == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "location");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("location", location);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "GetStatus", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "{nextBlobUuidLink}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace(location.StartsWith("/") ? "/{nextBlobUuidLink}" : "{nextBlobUuidLink}", location);
- 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 != 204)
- {
- var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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 AzureOperationHeaderResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_httpResponse.Headers.Contains("x-ms-request-id"))
- {
- _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
- }
- try
- {
- _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Upload a stream of data without completing the upload.
- ///
- ///
- /// Raw data of blob
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not include
- /// initial / (must do substring(1) )
- ///
- ///
- /// 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 Task> UploadWithHttpMessagesAsync(Stream value, string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (value == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "value");
- }
- if (location == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "location");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("value", value);
- tracingParameters.Add("location", location);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "Upload", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "{nextBlobUuidLink}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace(location.StartsWith("/") ? "/{nextBlobUuidLink}" : "{nextBlobUuidLink}", location);
- 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("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(value == null)
- {
- throw new System.ArgumentNullException("value");
- }
- if (value != null && value != Stream.Null)
- {
- _httpRequest.Content = new StreamContent(value);
- _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
- }
- // 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 != 202)
- {
- var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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 AzureOperationHeaderResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_httpResponse.Headers.Contains("x-ms-request-id"))
- {
- _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
- }
- try
- {
- _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Complete the upload, providing all the data in the body, if necessary. A
- /// request without a body will just complete the upload with previously
- /// uploaded content.
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not include
- /// initial / (must do substring(1) )
- ///
- ///
- /// Optional raw data of blob
- ///
- ///
- /// 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 Task> EndUploadWithHttpMessagesAsync(string digest, string location, Stream value = default(Stream), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (digest == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "digest");
- }
- if (location == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "location");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("digest", digest);
- tracingParameters.Add("value", value);
- tracingParameters.Add("location", location);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "EndUpload", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "{nextBlobUuidLink}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace(location.StartsWith("/") ? "/{nextBlobUuidLink}" : "{nextBlobUuidLink}", location);
- List _queryParameters = new List();
- if (digest != null)
- {
- _queryParameters.Add(string.Format("digest={0}", System.Uri.EscapeDataString(digest)));
- }
- 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 (value != null && value != Stream.Null)
- {
- _httpRequest.Content = new StreamContent(value);
- _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
- }
- // 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 != 201)
- {
- var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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 AzureOperationHeaderResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_httpResponse.Headers.Contains("x-ms-request-id"))
- {
- _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
- }
- try
- {
- _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Cancel outstanding upload processes, releasing associated resources. If
- /// this is not called, the unfinished uploads will eventually timeout.
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not include
- /// initial / (must do substring(1) )
- ///
- ///
- /// 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 Task CancelUploadWithHttpMessagesAsync(string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (location == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "location");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("location", location);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "CancelUpload", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "{nextBlobUuidLink}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace(location.StartsWith("/") ? "/{nextBlobUuidLink}" : "{nextBlobUuidLink}", location);
- 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("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 != 204)
- {
- var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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;
- }
-
- ///
- /// Initiate a resumable blob upload with an empty request body.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// 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 Task> StartUploadWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "name");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("name", name);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "StartUpload", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/uploads/";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
- 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("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;
- // 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 != 202)
- {
- var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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 AzureOperationHeaderResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_httpResponse.Headers.Contains("x-ms-request-id"))
- {
- _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
- }
- try
- {
- _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Retrieve the blob from the registry identified by `digest`. This endpoint
- /// may also support RFC7233 compliant range requests. Support can be detected
- /// by issuing a HEAD request. If the header `Accept-Range: bytes` is returned,
- /// range requests can be used to fetch partial content.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// Format : bytes=<start>-<end>, HTTP Range header specifying
- /// blob chunk.
- ///
- ///
- /// 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 Task> GetChunkWithHttpMessagesAsync(string name, string digest, string range, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "name");
- }
- if (digest == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "digest");
- }
- if (range == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "range");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("name", name);
- tracingParameters.Add("digest", digest);
- tracingParameters.Add("range", range);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "GetChunk", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/{digest}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
- _url = _url.Replace("{digest}", System.Uri.EscapeDataString(digest));
- 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 (range != null)
- {
- if (_httpRequest.Headers.Contains("Range"))
- {
- _httpRequest.Headers.Remove("Range");
- }
- _httpRequest.Headers.TryAddWithoutValidation("Range", range);
- }
- 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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 206)
- {
- 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 == 206)
- {
- _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
- }
- try
- {
- _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Same as GET, except only the headers are returned.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// Format : bytes=<start>-<end>, HTTP Range header specifying
- /// blob chunk.
- ///
- ///
- /// 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 Task> CheckChunkWithHttpMessagesAsync(string name, string digest, string range, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "name");
- }
- if (digest == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "digest");
- }
- if (range == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "range");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("name", name);
- tracingParameters.Add("digest", digest);
- tracingParameters.Add("range", range);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "CheckChunk", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/{digest}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
- _url = _url.Replace("{digest}", System.Uri.EscapeDataString(digest));
- 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("HEAD");
- _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 (range != null)
- {
- if (_httpRequest.Headers.Contains("Range"))
- {
- _httpRequest.Headers.Remove("Range");
- }
- _httpRequest.Headers.TryAddWithoutValidation("Range", range);
- }
- 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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, 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 AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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 AzureOperationHeaderResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_httpResponse.Headers.Contains("x-ms-request-id"))
- {
- _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
- }
- try
- {
- _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperationsExtensions.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperationsExtensions.cs
deleted file mode 100644
index f93a84318eac..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperationsExtensions.cs
+++ /dev/null
@@ -1,289 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using System.IO;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// Extension methods for BlobOperations.
- ///
- public static partial class BlobOperationsExtensions
- {
- ///
- /// Retrieve the blob from the registry identified by digest.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task GetAsync(this IBlobOperations operations, string name, string digest, CancellationToken cancellationToken = default(CancellationToken))
- {
- var _result = await operations.GetWithHttpMessagesAsync(name, digest, null, cancellationToken).ConfigureAwait(false);
- _result.Request.Dispose();
- return _result.Body;
- }
-
- ///
- /// Same as GET, except only the headers are returned.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task CheckAsync(this IBlobOperations operations, string name, string digest, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.CheckWithHttpMessagesAsync(name, digest, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Headers;
- }
- }
-
- ///
- /// Removes an already uploaded blob.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task DeleteAsync(this IBlobOperations operations, string name, string digest, CancellationToken cancellationToken = default(CancellationToken))
- {
- var _result = await operations.DeleteWithHttpMessagesAsync(name, digest, null, cancellationToken).ConfigureAwait(false);
- _result.Request.Dispose();
- return _result.Body;
- }
-
- ///
- /// Mount a blob identified by the `mount` parameter from another repository.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Name of the source repository.
- ///
- ///
- /// Digest of blob to mount from the source repository.
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task MountAsync(this IBlobOperations operations, string name, string fromParameter, string mount, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.MountWithHttpMessagesAsync(name, fromParameter, mount, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Headers;
- }
- }
-
- ///
- /// Retrieve status of upload identified by uuid. The primary purpose of this
- /// endpoint is to resolve the current status of a resumable upload.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not include
- /// initial / (must do substring(1) )
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task GetStatusAsync(this IBlobOperations operations, string location, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.GetStatusWithHttpMessagesAsync(location, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Headers;
- }
- }
-
- ///
- /// Upload a stream of data without completing the upload.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Raw data of blob
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not include
- /// initial / (must do substring(1) )
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task UploadAsync(this IBlobOperations operations, Stream value, string location, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.UploadWithHttpMessagesAsync(value, location, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Headers;
- }
- }
-
- ///
- /// Complete the upload, providing all the data in the body, if necessary. A
- /// request without a body will just complete the upload with previously
- /// uploaded content.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not include
- /// initial / (must do substring(1) )
- ///
- ///
- /// Optional raw data of blob
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task EndUploadAsync(this IBlobOperations operations, string digest, string location, Stream value = default(Stream), CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.EndUploadWithHttpMessagesAsync(digest, location, value, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Headers;
- }
- }
-
- ///
- /// Cancel outstanding upload processes, releasing associated resources. If
- /// this is not called, the unfinished uploads will eventually timeout.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not include
- /// initial / (must do substring(1) )
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task CancelUploadAsync(this IBlobOperations operations, string location, CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.CancelUploadWithHttpMessagesAsync(location, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Initiate a resumable blob upload with an empty request body.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task StartUploadAsync(this IBlobOperations operations, string name, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.StartUploadWithHttpMessagesAsync(name, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Headers;
- }
- }
-
- ///
- /// Retrieve the blob from the registry identified by `digest`. This endpoint
- /// may also support RFC7233 compliant range requests. Support can be detected
- /// by issuing a HEAD request. If the header `Accept-Range: bytes` is returned,
- /// range requests can be used to fetch partial content.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// Format : bytes=<start>-<end>, HTTP Range header specifying
- /// blob chunk.
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task GetChunkAsync(this IBlobOperations operations, string name, string digest, string range, CancellationToken cancellationToken = default(CancellationToken))
- {
- var _result = await operations.GetChunkWithHttpMessagesAsync(name, digest, range, null, cancellationToken).ConfigureAwait(false);
- _result.Request.Dispose();
- return _result.Body;
- }
-
- ///
- /// Same as GET, except only the headers are returned.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// Format : bytes=<start>-<end>, HTTP Range header specifying
- /// blob chunk.
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task CheckChunkAsync(this IBlobOperations operations, string name, string digest, string range, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.CheckChunkWithHttpMessagesAsync(name, digest, range, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Headers;
- }
- }
-
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAccessTokensOperations.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAccessTokensOperations.cs
deleted file mode 100644
index b6adbea754f5..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAccessTokensOperations.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// AccessTokensOperations operations.
- ///
- public partial interface IAccessTokensOperations
- {
- ///
- /// Exchange ACR Refresh token for an ACR Access Token
- ///
- ///
- /// Indicates the name of your Azure container registry.
- ///
- ///
- /// Which is expected to be a valid scope, and can be specified more
- /// than once for multiple scope requests. You obtained this from the
- /// Www-Authenticate response header from the challenge.
- ///
- ///
- /// Must be a valid ACR refresh 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
- ///
- Task> GetWithHttpMessagesAsync(string service, string scope, string refreshToken, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Exchange Username, Password and Scope an ACR Access Token
- ///
- ///
- /// Indicates the name of your Azure container registry.
- ///
- ///
- /// Expected to be a valid scope, and can be specified more than once
- /// for multiple scope requests. You can obtain this from the
- /// Www-Authenticate response header from the challenge.
- ///
- ///
- /// 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
- ///
- Task> GetFromLoginWithHttpMessagesAsync(string service, string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAzureContainerRegistryClient.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAzureContainerRegistryClient.cs
deleted file mode 100644
index aa7ce06fa71c..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAzureContainerRegistryClient.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using Newtonsoft.Json;
-
- ///
- /// Metadata API definition for the Azure Container Registry runtime
- ///
- public partial interface IAzureContainerRegistryClient : System.IDisposable
- {
- ///
- /// The base URI of the service.
- ///
-
- ///
- /// Gets or sets json serialization settings.
- ///
- JsonSerializerSettings SerializationSettings { get; }
-
- ///
- /// Gets or sets json deserialization settings.
- ///
- JsonSerializerSettings DeserializationSettings { get; }
-
- ///
- /// Credentials needed for the client to connect to Azure.
- ///
- ServiceClientCredentials Credentials { get; }
-
- ///
- /// Registry login URL
- ///
- string LoginUri { get; set; }
-
- ///
- /// The preferred language for the response.
- ///
- string AcceptLanguage { get; set; }
-
- ///
- /// The retry timeout in seconds for Long Running Operations. Default
- /// value is 30.
- ///
- int? LongRunningOperationRetryTimeout { get; set; }
-
- ///
- /// Whether a unique x-ms-client-request-id should be generated. When
- /// set to true a unique x-ms-client-request-id value is generated and
- /// included in each request. Default is true.
- ///
- bool? GenerateClientRequestId { get; set; }
-
-
- ///
- /// Gets the IV2SupportOperations.
- ///
- IV2SupportOperations V2Support { get; }
-
- ///
- /// Gets the IManifestsOperations.
- ///
- IManifestsOperations Manifests { get; }
-
- ///
- /// Gets the IBlobOperations.
- ///
- IBlobOperations Blob { get; }
-
- ///
- /// Gets the IRepositoryOperations.
- ///
- IRepositoryOperations Repository { get; }
-
- ///
- /// Gets the ITagOperations.
- ///
- ITagOperations Tag { get; }
-
- ///
- /// Gets the IRefreshTokensOperations.
- ///
- IRefreshTokensOperations RefreshTokens { get; }
-
- ///
- /// Gets the IAccessTokensOperations.
- ///
- IAccessTokensOperations AccessTokens { get; }
-
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IBlobOperations.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IBlobOperations.cs
deleted file mode 100644
index 31215937a9c5..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IBlobOperations.cs
+++ /dev/null
@@ -1,299 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// BlobOperations operations.
- ///
- public partial interface IBlobOperations
- {
- ///
- /// Retrieve the blob from the registry identified by digest.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// 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
- ///
- Task> GetWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Same as GET, except only the headers are returned.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// 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
- ///
- Task> CheckWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Removes an already uploaded blob.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// 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
- ///
- Task> DeleteWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Mount a blob identified by the `mount` parameter from another
- /// repository.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Name of the source repository.
- ///
- ///
- /// Digest of blob to mount from the source repository.
- ///
- ///
- /// 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
- ///
- Task> MountWithHttpMessagesAsync(string name, string fromParameter, string mount, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Retrieve status of upload identified by uuid. The primary purpose
- /// of this endpoint is to resolve the current status of a resumable
- /// upload.
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not
- /// include initial / (must do substring(1) )
- ///
- ///
- /// 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
- ///
- Task> GetStatusWithHttpMessagesAsync(string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Upload a stream of data without completing the upload.
- ///
- ///
- /// Raw data of blob
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not
- /// include initial / (must do substring(1) )
- ///
- ///
- /// 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
- ///
- Task> UploadWithHttpMessagesAsync(Stream value, string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Complete the upload, providing all the data in the body, if
- /// necessary. A request without a body will just complete the upload
- /// with previously uploaded content.
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not
- /// include initial / (must do substring(1) )
- ///
- ///
- /// Optional raw data of blob
- ///
- ///
- /// 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
- ///
- Task> EndUploadWithHttpMessagesAsync(string digest, string location, Stream value = default(Stream), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Cancel outstanding upload processes, releasing associated
- /// resources. If this is not called, the unfinished uploads will
- /// eventually timeout.
- ///
- ///
- /// Link acquired from upload start or previous chunk. Note, do not
- /// include initial / (must do substring(1) )
- ///
- ///
- /// 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
- ///
- Task CancelUploadWithHttpMessagesAsync(string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Initiate a resumable blob upload with an empty request body.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// 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
- ///
- Task> StartUploadWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Retrieve the blob from the registry identified by `digest`. This
- /// endpoint may also support RFC7233 compliant range requests. Support
- /// can be detected by issuing a HEAD request. If the header
- /// `Accept-Range: bytes` is returned, range requests can be used to
- /// fetch partial content.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// Format : bytes=<start>-<end>, HTTP Range header
- /// specifying blob chunk.
- ///
- ///
- /// 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
- ///
- Task> GetChunkWithHttpMessagesAsync(string name, string digest, string range, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Same as GET, except only the headers are returned.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Digest of a BLOB
- ///
- ///
- /// Format : bytes=<start>-<end>, HTTP Range header
- /// specifying blob chunk.
- ///
- ///
- /// 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
- ///
- Task> CheckChunkWithHttpMessagesAsync(string name, string digest, string range, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IManifestsOperations.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IManifestsOperations.cs
deleted file mode 100644
index 4ca2a9c8cb5c..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IManifestsOperations.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// ManifestsOperations operations.
- ///
- public partial interface IManifestsOperations
- {
- ///
- /// Get the manifest identified by `name` and `reference` where
- /// `reference` can be a tag or digest.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// A tag or a digest, pointing to a specific image
- ///
- ///
- /// Accept header string delimited by comma. For example,
- /// application/vnd.docker.distribution.manifest.v2+json
- ///
- ///
- /// 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
- ///
- Task> GetWithHttpMessagesAsync(string name, string reference, string accept = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Put the manifest identified by `name` and `reference` where
- /// `reference` can be a tag or digest.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// A tag or a digest, pointing to a specific image
- ///
- ///
- /// Manifest body, can take v1 or v2 values depending on accept header
- ///
- ///
- /// 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
- ///
- Task> CreateWithHttpMessagesAsync(string name, string reference, Manifest payload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Delete the manifest identified by `name` and `reference`. Note that
- /// a manifest can _only_ be deleted by `digest`.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// A tag or a digest, pointing to a specific image
- ///
- ///
- /// 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
- ///
- Task DeleteWithHttpMessagesAsync(string name, string reference, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// List manifests of a repository
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Query parameter for the last item in previous query. Result set
- /// will include values lexically after last.
- ///
- ///
- /// query parameter for max number of items
- ///
- ///
- /// orderby query parameter
- ///
- ///
- /// 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
- ///
- Task> GetListWithHttpMessagesAsync(string name, string last = default(string), int? n = default(int?), string orderby = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Get manifest attributes
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// A tag or a digest, pointing to a specific image
- ///
- ///
- /// 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
- ///
- Task> GetAttributesWithHttpMessagesAsync(string name, string reference, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Update attributes of a manifest
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// A tag or a digest, pointing to a specific image
- ///
- ///
- /// Repository attribute value
- ///
- ///
- /// 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
- ///
- Task UpdateAttributesWithHttpMessagesAsync(string name, string reference, ChangeableAttributes value = default(ChangeableAttributes), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRefreshTokensOperations.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRefreshTokensOperations.cs
deleted file mode 100644
index d9888da30e89..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRefreshTokensOperations.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// RefreshTokensOperations operations.
- ///
- public partial interface IRefreshTokensOperations
- {
- ///
- /// Exchange AAD tokens for an ACR refresh Token
- ///
- ///
- /// Can take a value of access_token_refresh_token, or access_token, or
- /// refresh_token. Possible values include:
- /// 'access_token_refresh_token', 'access_token', 'refresh_token'
- ///
- ///
- /// Indicates the name of your Azure container registry.
- ///
- ///
- /// AAD tenant associated to the AAD credentials.
- ///
- ///
- /// AAD refresh token, mandatory when grant_type is
- /// access_token_refresh_token or refresh_token
- ///
- ///
- /// AAD access token, mandatory when grant_type is
- /// access_token_refresh_token or access_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
- ///
- Task> GetFromExchangeWithHttpMessagesAsync(string grantType, string service, string tenant = default(string), string refreshToken = default(string), string accessToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRepositoryOperations.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRepositoryOperations.cs
deleted file mode 100644
index 56ff7dcda648..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRepositoryOperations.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// RepositoryOperations operations.
- ///
- public partial interface IRepositoryOperations
- {
- ///
- /// List repositories
- ///
- ///
- /// Query parameter for the last item in previous query. Result set
- /// will include values lexically after last.
- ///
- ///
- /// query parameter for max number of items
- ///
- ///
- /// 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
- ///
- Task> GetListWithHttpMessagesAsync(string last = default(string), int? n = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Get repository attributes
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// 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
- ///
- Task> GetAttributesWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Delete the repository identified by `name`
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// 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
- ///
- Task> DeleteWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Update the attribute identified by `name` where `reference` is the
- /// name of the repository.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Repository attribute value
- ///
- ///
- /// 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
- ///
- Task UpdateAttributesWithHttpMessagesAsync(string name, ChangeableAttributes value = default(ChangeableAttributes), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/ITagOperations.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/ITagOperations.cs
deleted file mode 100644
index ab184b3f4cff..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/ITagOperations.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// TagOperations operations.
- ///
- public partial interface ITagOperations
- {
- ///
- /// List tags of a repository
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Query parameter for the last item in previous query. Result set
- /// will include values lexically after last.
- ///
- ///
- /// query parameter for max number of items
- ///
- ///
- /// orderby query parameter
- ///
- ///
- /// filter by digest
- ///
- ///
- /// 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
- ///
- Task> GetListWithHttpMessagesAsync(string name, string last = default(string), int? n = default(int?), string orderby = default(string), string digest = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Get tag attributes by tag
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Tag 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
- ///
- Task> GetAttributesWithHttpMessagesAsync(string name, string reference, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Update tag attributes
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Tag name
- ///
- ///
- /// Repository attribute value
- ///
- ///
- /// 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
- ///
- Task UpdateAttributesWithHttpMessagesAsync(string name, string reference, ChangeableAttributes value = default(ChangeableAttributes), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- ///
- /// Delete tag
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// Tag 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
- ///
- Task DeleteWithHttpMessagesAsync(string name, string reference, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IV2SupportOperations.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IV2SupportOperations.cs
deleted file mode 100644
index 3ed6177c7667..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/IV2SupportOperations.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// 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.ContainerRegistry
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// V2SupportOperations operations.
- ///
- public partial interface IV2SupportOperations
- {
- ///
- /// Tells whether this Docker Registry instance supports Docker
- /// Registry HTTP API v2
- ///
- ///
- /// 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
- ///
- Task CheckWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
- }
-}
diff --git a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/ManifestsOperations.cs b/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/ManifestsOperations.cs
deleted file mode 100644
index ffe3def63ff5..000000000000
--- a/sdk/containerregistry/Microsoft.Azure.ContainerRegistry/src/Generated/ManifestsOperations.cs
+++ /dev/null
@@ -1,1200 +0,0 @@
-//
-// 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.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;
- using System.Threading.Tasks;
-
- ///
- /// ManifestsOperations operations.
- ///
- internal partial class ManifestsOperations : IServiceOperations, IManifestsOperations
- {
- ///
- /// Initializes a new instance of the ManifestsOperations class.
- ///
- ///
- /// Reference to the service client.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- internal ManifestsOperations(AzureContainerRegistryClient client)
- {
- if (client == null)
- {
- throw new System.ArgumentNullException("client");
- }
- Client = client;
- }
-
- ///
- /// Gets a reference to the AzureContainerRegistryClient
- ///
- public AzureContainerRegistryClient Client { get; private set; }
-
- ///
- /// Get the manifest identified by `name` and `reference` where `reference` can
- /// be a tag or digest.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// A tag or a digest, pointing to a specific image
- ///
- ///
- /// Accept header string delimited by comma. For example,
- /// application/vnd.docker.distribution.manifest.v2+json
- ///
- ///
- /// 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 Task> GetWithHttpMessagesAsync(string name, string reference, string accept = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "name");
- }
- if (reference == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "reference");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("name", name);
- tracingParameters.Add("reference", reference);
- tracingParameters.Add("accept", accept);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/manifests/{reference}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
- _url = _url.Replace("{reference}", System.Uri.EscapeDataString(reference));
- 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 (accept != null)
- {
- if (_httpRequest.Headers.Contains("accept"))
- {
- _httpRequest.Headers.Remove("accept");
- }
- _httpRequest.Headers.TryAddWithoutValidation("accept", accept);
- }
- 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 AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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;
- }
-
- ///
- /// Put the manifest identified by `name` and `reference` where `reference` can
- /// be a tag or digest.
- ///
- ///
- /// Name of the image (including the namespace)
- ///
- ///
- /// A tag or a digest, pointing to a specific image
- ///
- ///
- /// Manifest body, can take v1 or v2 values depending on accept header
- ///
- ///
- /// 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 Task> CreateWithHttpMessagesAsync(string name, string reference, Manifest payload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (Client.LoginUri == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
- }
- if (name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "name");
- }
- if (reference == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "reference");
- }
- if (payload == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "payload");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("name", name);
- tracingParameters.Add("reference", reference);
- tracingParameters.Add("payload", payload);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
- }
- // Construct URL
- var _baseUrl = Client.BaseUri;
- var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/manifests/{reference}";
- _url = _url.Replace("{url}", Client.LoginUri);
- _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
- _url = _url.Replace("{reference}", System.Uri.EscapeDataString(reference));
- 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("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(payload != null)
- {
- _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(payload, Client.SerializationSettings);
- _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
- string mediaType = string.Empty;
- switch (payload)
- {
- case V2Manifest v2Manifest:
- mediaType = v2Manifest.MediaType;
- break;
- case V1Manifest v1Manifest:
- mediaType = v1Manifest.MediaType;
- break;
- case ManifestList manifestList:
- mediaType = manifestList.MediaType;
- break;
- case OCIManifest ociManifest:
- mediaType = ociManifest.MediaType;
- break;
- case OCIIndex ociIndex:
- mediaType = ociIndex.MediaType;
- break;
- default:
- throw new AcrErrorsException($"The manifest type is unknown: {payload}.");
- }
- _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse(mediaType);
- }
- // 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 != 201)
- {
- var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- try
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- AcrErrors _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