-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
AzureContainerRegistryClientExtended.cs
85 lines (73 loc) · 3.12 KB
/
AzureContainerRegistryClientExtended.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using Microsoft.Rest;
using Microsoft.Rest.Azure;
using System.Net.Http;
namespace Microsoft.Azure.ContainerRegistry
{
public partial class AzureContainerRegistryClient : ServiceClient<AzureContainerRegistryClient>, IAzureContainerRegistryClient, IAzureClient
{
// MANUALLY ADDED FOR INTERNAL TEST PURPOSES / FOR TESTING FRAMEWORK USE ONLY
/// <summary>
/// Initializes a new instance of the AzureContainerRegistryClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='credentials'>
/// Required. Credentials needed for the client to connect to Azure.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
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);
}
}
/// <summary>
/// Initializes a new instance of the AzureContainerRegistryClient class. Allows users to specify a loginUrl
/// </summary>
/// <param name='loginUrl'>
/// Required The base URl of the Azure Container Registry Service
/// </param>
/// <param name='credentials'>
/// Required. Credentials needed for the client to connect to Azure.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
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);
}
}
}