-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
MockableRecoveryServicesResourceGroupResource.cs
174 lines (159 loc) · 8.96 KB
/
MockableRecoveryServicesResourceGroupResource.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.ResourceManager;
using Azure.ResourceManager.RecoveryServices;
using Azure.ResourceManager.RecoveryServices.Models;
namespace Azure.ResourceManager.RecoveryServices.Mocking
{
/// <summary> A class to add extension methods to ResourceGroupResource. </summary>
public partial class MockableRecoveryServicesResourceGroupResource : ArmResource
{
private ClientDiagnostics _recoveryServicesClientDiagnostics;
private RecoveryServicesRestOperations _recoveryServicesRestClient;
/// <summary> Initializes a new instance of the <see cref="MockableRecoveryServicesResourceGroupResource"/> class for mocking. </summary>
protected MockableRecoveryServicesResourceGroupResource()
{
}
/// <summary> Initializes a new instance of the <see cref="MockableRecoveryServicesResourceGroupResource"/> class. </summary>
/// <param name="client"> The client parameters to use in these operations. </param>
/// <param name="id"> The identifier of the resource that is the target of operations. </param>
internal MockableRecoveryServicesResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id)
{
}
private ClientDiagnostics RecoveryServicesClientDiagnostics => _recoveryServicesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.RecoveryServices", ProviderConstants.DefaultProviderNamespace, Diagnostics);
private RecoveryServicesRestOperations RecoveryServicesRestClient => _recoveryServicesRestClient ??= new RecoveryServicesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint);
private string GetApiVersionOrNull(ResourceType resourceType)
{
TryGetApiVersion(resourceType, out string apiVersion);
return apiVersion;
}
/// <summary> Gets a collection of RecoveryServicesVaultResources in the ResourceGroupResource. </summary>
/// <returns> An object representing collection of RecoveryServicesVaultResources and their operations over a RecoveryServicesVaultResource. </returns>
public virtual RecoveryServicesVaultCollection GetRecoveryServicesVaults()
{
return GetCachedClient(client => new RecoveryServicesVaultCollection(client, Id));
}
/// <summary>
/// Get the Vault details.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Vaults_Get</description>
/// </item>
/// </list>
/// </summary>
/// <param name="vaultName"> The name of the recovery services vault. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="vaultName"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="vaultName"/> is an empty string, and was expected to be non-empty. </exception>
[ForwardsClientCalls]
public virtual async Task<Response<RecoveryServicesVaultResource>> GetRecoveryServicesVaultAsync(string vaultName, CancellationToken cancellationToken = default)
{
return await GetRecoveryServicesVaults().GetAsync(vaultName, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Get the Vault details.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Vaults_Get</description>
/// </item>
/// </list>
/// </summary>
/// <param name="vaultName"> The name of the recovery services vault. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="vaultName"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="vaultName"/> is an empty string, and was expected to be non-empty. </exception>
[ForwardsClientCalls]
public virtual Response<RecoveryServicesVaultResource> GetRecoveryServicesVault(string vaultName, CancellationToken cancellationToken = default)
{
return GetRecoveryServicesVaults().Get(vaultName, cancellationToken);
}
/// <summary>
/// API to check for resource name availability.
/// A name is available if no other resource exists that has the same SubscriptionId, Resource Name and Type
/// or if one or more such resources exist, each of these must be GC'd and their time of deletion be more than 24 Hours Ago
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/locations/{location}/checkNameAvailability</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>RecoveryServices_CheckNameAvailability</description>
/// </item>
/// </list>
/// </summary>
/// <param name="location"> Location of the resource. </param>
/// <param name="content"> Contains information about Resource type and Resource name. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
public virtual async Task<Response<RecoveryServicesNameAvailabilityResult>> CheckRecoveryServicesNameAvailabilityAsync(AzureLocation location, RecoveryServicesNameAvailabilityContent content, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(content, nameof(content));
using var scope = RecoveryServicesClientDiagnostics.CreateScope("MockableRecoveryServicesResourceGroupResource.CheckRecoveryServicesNameAvailability");
scope.Start();
try
{
var response = await RecoveryServicesRestClient.CheckNameAvailabilityAsync(Id.SubscriptionId, Id.ResourceGroupName, location, content, cancellationToken).ConfigureAwait(false);
return response;
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
}
/// <summary>
/// API to check for resource name availability.
/// A name is available if no other resource exists that has the same SubscriptionId, Resource Name and Type
/// or if one or more such resources exist, each of these must be GC'd and their time of deletion be more than 24 Hours Ago
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/locations/{location}/checkNameAvailability</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>RecoveryServices_CheckNameAvailability</description>
/// </item>
/// </list>
/// </summary>
/// <param name="location"> Location of the resource. </param>
/// <param name="content"> Contains information about Resource type and Resource name. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
public virtual Response<RecoveryServicesNameAvailabilityResult> CheckRecoveryServicesNameAvailability(AzureLocation location, RecoveryServicesNameAvailabilityContent content, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(content, nameof(content));
using var scope = RecoveryServicesClientDiagnostics.CreateScope("MockableRecoveryServicesResourceGroupResource.CheckRecoveryServicesNameAvailability");
scope.Start();
try
{
var response = RecoveryServicesRestClient.CheckNameAvailability(Id.SubscriptionId, Id.ResourceGroupName, location, content, cancellationToken);
return response;
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
}
}
}