| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Resources.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Resources |
| | 18 | | { |
| | 19 | | internal partial class ResourceGroupsRestOperations |
| | 20 | | { |
| | 21 | | private string subscriptionId; |
| | 22 | | private Uri endpoint; |
| | 23 | | private ClientDiagnostics _clientDiagnostics; |
| | 24 | | private HttpPipeline _pipeline; |
| | 25 | |
|
| | 26 | | /// <summary> Initializes a new instance of ResourceGroupsRestOperations. </summary> |
| | 27 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 28 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 29 | | /// <param name="subscriptionId"> The ID of the target subscription. </param> |
| | 30 | | /// <param name="endpoint"> server parameter. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 312 | 32 | | public ResourceGroupsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscript |
| | 33 | | { |
| 312 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 312 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 312 | 40 | | this.subscriptionId = subscriptionId; |
| 312 | 41 | | this.endpoint = endpoint; |
| 312 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 312 | 43 | | _pipeline = pipeline; |
| 312 | 44 | | } |
| | 45 | |
|
| | 46 | | internal Core.HttpMessage CreateCheckExistenceRequest(string resourceGroupName) |
| | 47 | | { |
| 20 | 48 | | var message = _pipeline.CreateMessage(); |
| 20 | 49 | | var request = message.Request; |
| 20 | 50 | | request.Method = RequestMethod.Head; |
| 20 | 51 | | var uri = new RawRequestUriBuilder(); |
| 20 | 52 | | uri.Reset(endpoint); |
| 20 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 20 | 54 | | uri.AppendPath(subscriptionId, true); |
| 20 | 55 | | uri.AppendPath("/resourcegroups/", false); |
| 20 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 20 | 57 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 20 | 58 | | request.Uri = uri; |
| 20 | 59 | | return message; |
| | 60 | | } |
| | 61 | |
|
| | 62 | | /// <summary> Checks whether a resource group exists. </summary> |
| | 63 | | /// <param name="resourceGroupName"> The name of the resource group to check. The name is case insensitive. </pa |
| | 64 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 65 | | public async Task<Response> CheckExistenceAsync(string resourceGroupName, CancellationToken cancellationToken = |
| | 66 | | { |
| 10 | 67 | | if (resourceGroupName == null) |
| | 68 | | { |
| 0 | 69 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 70 | | } |
| | 71 | |
|
| 10 | 72 | | using var message = CreateCheckExistenceRequest(resourceGroupName); |
| 10 | 73 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 10 | 74 | | switch (message.Response.Status) |
| | 75 | | { |
| | 76 | | case 204: |
| | 77 | | case 404: |
| 8 | 78 | | return message.Response; |
| | 79 | | default: |
| 2 | 80 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 81 | | } |
| 8 | 82 | | } |
| | 83 | |
|
| | 84 | | /// <summary> Checks whether a resource group exists. </summary> |
| | 85 | | /// <param name="resourceGroupName"> The name of the resource group to check. The name is case insensitive. </pa |
| | 86 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 87 | | public Response CheckExistence(string resourceGroupName, CancellationToken cancellationToken = default) |
| | 88 | | { |
| 10 | 89 | | if (resourceGroupName == null) |
| | 90 | | { |
| 0 | 91 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 92 | | } |
| | 93 | |
|
| 10 | 94 | | using var message = CreateCheckExistenceRequest(resourceGroupName); |
| 10 | 95 | | _pipeline.Send(message, cancellationToken); |
| 10 | 96 | | switch (message.Response.Status) |
| | 97 | | { |
| | 98 | | case 204: |
| | 99 | | case 404: |
| 8 | 100 | | return message.Response; |
| | 101 | | default: |
| 2 | 102 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 103 | | } |
| 8 | 104 | | } |
| | 105 | |
|
| | 106 | | internal Core.HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, ResourceGroup parameters) |
| | 107 | | { |
| 112 | 108 | | var message = _pipeline.CreateMessage(); |
| 112 | 109 | | var request = message.Request; |
| 112 | 110 | | request.Method = RequestMethod.Put; |
| 112 | 111 | | var uri = new RawRequestUriBuilder(); |
| 112 | 112 | | uri.Reset(endpoint); |
| 112 | 113 | | uri.AppendPath("/subscriptions/", false); |
| 112 | 114 | | uri.AppendPath(subscriptionId, true); |
| 112 | 115 | | uri.AppendPath("/resourcegroups/", false); |
| 112 | 116 | | uri.AppendPath(resourceGroupName, true); |
| 112 | 117 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 112 | 118 | | request.Uri = uri; |
| 112 | 119 | | request.Headers.Add("Content-Type", "application/json"); |
| 112 | 120 | | var content = new Utf8JsonRequestContent(); |
| 112 | 121 | | content.JsonWriter.WriteObjectValue(parameters); |
| 112 | 122 | | request.Content = content; |
| 112 | 123 | | return message; |
| | 124 | | } |
| | 125 | |
|
| | 126 | | /// <summary> Creates or updates a resource group. </summary> |
| | 127 | | /// <param name="resourceGroupName"> The name of the resource group to create or update. Can include alphanumeri |
| | 128 | | /// <param name="parameters"> Parameters supplied to the create or update a resource group. </param> |
| | 129 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 130 | | public async Task<Response<ResourceGroup>> CreateOrUpdateAsync(string resourceGroupName, ResourceGroup parameter |
| | 131 | | { |
| 60 | 132 | | if (resourceGroupName == null) |
| | 133 | | { |
| 2 | 134 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 135 | | } |
| 58 | 136 | | if (parameters == null) |
| | 137 | | { |
| 2 | 138 | | throw new ArgumentNullException(nameof(parameters)); |
| | 139 | | } |
| | 140 | |
|
| 56 | 141 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, parameters); |
| 56 | 142 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 56 | 143 | | switch (message.Response.Status) |
| | 144 | | { |
| | 145 | | case 200: |
| | 146 | | case 201: |
| | 147 | | { |
| 56 | 148 | | ResourceGroup value = default; |
| 56 | 149 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 56 | 150 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 151 | | { |
| 0 | 152 | | value = null; |
| | 153 | | } |
| | 154 | | else |
| | 155 | | { |
| 56 | 156 | | value = ResourceGroup.DeserializeResourceGroup(document.RootElement); |
| | 157 | | } |
| 56 | 158 | | return Response.FromValue(value, message.Response); |
| | 159 | | } |
| | 160 | | default: |
| 0 | 161 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 162 | | } |
| 56 | 163 | | } |
| | 164 | |
|
| | 165 | | /// <summary> Creates or updates a resource group. </summary> |
| | 166 | | /// <param name="resourceGroupName"> The name of the resource group to create or update. Can include alphanumeri |
| | 167 | | /// <param name="parameters"> Parameters supplied to the create or update a resource group. </param> |
| | 168 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 169 | | public Response<ResourceGroup> CreateOrUpdate(string resourceGroupName, ResourceGroup parameters, CancellationTo |
| | 170 | | { |
| 60 | 171 | | if (resourceGroupName == null) |
| | 172 | | { |
| 2 | 173 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 174 | | } |
| 58 | 175 | | if (parameters == null) |
| | 176 | | { |
| 2 | 177 | | throw new ArgumentNullException(nameof(parameters)); |
| | 178 | | } |
| | 179 | |
|
| 56 | 180 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, parameters); |
| 56 | 181 | | _pipeline.Send(message, cancellationToken); |
| 56 | 182 | | switch (message.Response.Status) |
| | 183 | | { |
| | 184 | | case 200: |
| | 185 | | case 201: |
| | 186 | | { |
| 56 | 187 | | ResourceGroup value = default; |
| 56 | 188 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 56 | 189 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 190 | | { |
| 0 | 191 | | value = null; |
| | 192 | | } |
| | 193 | | else |
| | 194 | | { |
| 56 | 195 | | value = ResourceGroup.DeserializeResourceGroup(document.RootElement); |
| | 196 | | } |
| 56 | 197 | | return Response.FromValue(value, message.Response); |
| | 198 | | } |
| | 199 | | default: |
| 0 | 200 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 201 | | } |
| 56 | 202 | | } |
| | 203 | |
|
| | 204 | | internal Core.HttpMessage CreateDeleteRequest(string resourceGroupName) |
| | 205 | | { |
| 32 | 206 | | var message = _pipeline.CreateMessage(); |
| 32 | 207 | | var request = message.Request; |
| 32 | 208 | | request.Method = RequestMethod.Delete; |
| 32 | 209 | | var uri = new RawRequestUriBuilder(); |
| 32 | 210 | | uri.Reset(endpoint); |
| 32 | 211 | | uri.AppendPath("/subscriptions/", false); |
| 32 | 212 | | uri.AppendPath(subscriptionId, true); |
| 32 | 213 | | uri.AppendPath("/resourcegroups/", false); |
| 32 | 214 | | uri.AppendPath(resourceGroupName, true); |
| 32 | 215 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 32 | 216 | | request.Uri = uri; |
| 32 | 217 | | return message; |
| | 218 | | } |
| | 219 | |
|
| | 220 | | /// <summary> When you delete a resource group, all of its resources are also deleted. Deleting a resource group |
| | 221 | | /// <param name="resourceGroupName"> The name of the resource group to delete. The name is case insensitive. </p |
| | 222 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 223 | | public async Task<Response> DeleteAsync(string resourceGroupName, CancellationToken cancellationToken = default) |
| | 224 | | { |
| 8 | 225 | | if (resourceGroupName == null) |
| | 226 | | { |
| 0 | 227 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 228 | | } |
| | 229 | |
|
| 8 | 230 | | using var message = CreateDeleteRequest(resourceGroupName); |
| 8 | 231 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 8 | 232 | | switch (message.Response.Status) |
| | 233 | | { |
| | 234 | | case 200: |
| | 235 | | case 202: |
| 8 | 236 | | return message.Response; |
| | 237 | | default: |
| 0 | 238 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 239 | | } |
| 8 | 240 | | } |
| | 241 | |
|
| | 242 | | /// <summary> When you delete a resource group, all of its resources are also deleted. Deleting a resource group |
| | 243 | | /// <param name="resourceGroupName"> The name of the resource group to delete. The name is case insensitive. </p |
| | 244 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 245 | | public Response Delete(string resourceGroupName, CancellationToken cancellationToken = default) |
| | 246 | | { |
| 8 | 247 | | if (resourceGroupName == null) |
| | 248 | | { |
| 0 | 249 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 250 | | } |
| | 251 | |
|
| 8 | 252 | | using var message = CreateDeleteRequest(resourceGroupName); |
| 8 | 253 | | _pipeline.Send(message, cancellationToken); |
| 8 | 254 | | switch (message.Response.Status) |
| | 255 | | { |
| | 256 | | case 200: |
| | 257 | | case 202: |
| 8 | 258 | | return message.Response; |
| | 259 | | default: |
| 0 | 260 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 261 | | } |
| 8 | 262 | | } |
| | 263 | |
|
| | 264 | | internal Core.HttpMessage CreateGetRequest(string resourceGroupName) |
| | 265 | | { |
| 16 | 266 | | var message = _pipeline.CreateMessage(); |
| 16 | 267 | | var request = message.Request; |
| 16 | 268 | | request.Method = RequestMethod.Get; |
| 16 | 269 | | var uri = new RawRequestUriBuilder(); |
| 16 | 270 | | uri.Reset(endpoint); |
| 16 | 271 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 272 | | uri.AppendPath(subscriptionId, true); |
| 16 | 273 | | uri.AppendPath("/resourcegroups/", false); |
| 16 | 274 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 275 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 16 | 276 | | request.Uri = uri; |
| 16 | 277 | | return message; |
| | 278 | | } |
| | 279 | |
|
| | 280 | | /// <summary> Gets a resource group. </summary> |
| | 281 | | /// <param name="resourceGroupName"> The name of the resource group to get. The name is case insensitive. </para |
| | 282 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 283 | | public async Task<Response<ResourceGroup>> GetAsync(string resourceGroupName, CancellationToken cancellationToke |
| | 284 | | { |
| 8 | 285 | | if (resourceGroupName == null) |
| | 286 | | { |
| 0 | 287 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 288 | | } |
| | 289 | |
|
| 8 | 290 | | using var message = CreateGetRequest(resourceGroupName); |
| 8 | 291 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 8 | 292 | | switch (message.Response.Status) |
| | 293 | | { |
| | 294 | | case 200: |
| | 295 | | { |
| 8 | 296 | | ResourceGroup value = default; |
| 8 | 297 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 8 | 298 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 299 | | { |
| 0 | 300 | | value = null; |
| | 301 | | } |
| | 302 | | else |
| | 303 | | { |
| 8 | 304 | | value = ResourceGroup.DeserializeResourceGroup(document.RootElement); |
| | 305 | | } |
| 8 | 306 | | return Response.FromValue(value, message.Response); |
| | 307 | | } |
| | 308 | | default: |
| 0 | 309 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 310 | | } |
| 8 | 311 | | } |
| | 312 | |
|
| | 313 | | /// <summary> Gets a resource group. </summary> |
| | 314 | | /// <param name="resourceGroupName"> The name of the resource group to get. The name is case insensitive. </para |
| | 315 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 316 | | public Response<ResourceGroup> Get(string resourceGroupName, CancellationToken cancellationToken = default) |
| | 317 | | { |
| 8 | 318 | | if (resourceGroupName == null) |
| | 319 | | { |
| 0 | 320 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 321 | | } |
| | 322 | |
|
| 8 | 323 | | using var message = CreateGetRequest(resourceGroupName); |
| 8 | 324 | | _pipeline.Send(message, cancellationToken); |
| 8 | 325 | | switch (message.Response.Status) |
| | 326 | | { |
| | 327 | | case 200: |
| | 328 | | { |
| 8 | 329 | | ResourceGroup value = default; |
| 8 | 330 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 8 | 331 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 332 | | { |
| 0 | 333 | | value = null; |
| | 334 | | } |
| | 335 | | else |
| | 336 | | { |
| 8 | 337 | | value = ResourceGroup.DeserializeResourceGroup(document.RootElement); |
| | 338 | | } |
| 8 | 339 | | return Response.FromValue(value, message.Response); |
| | 340 | | } |
| | 341 | | default: |
| 0 | 342 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 343 | | } |
| 8 | 344 | | } |
| | 345 | |
|
| | 346 | | internal Core.HttpMessage CreateUpdateRequest(string resourceGroupName, ResourceGroupPatchable parameters) |
| | 347 | | { |
| 4 | 348 | | var message = _pipeline.CreateMessage(); |
| 4 | 349 | | var request = message.Request; |
| 4 | 350 | | request.Method = RequestMethod.Patch; |
| 4 | 351 | | var uri = new RawRequestUriBuilder(); |
| 4 | 352 | | uri.Reset(endpoint); |
| 4 | 353 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 354 | | uri.AppendPath(subscriptionId, true); |
| 4 | 355 | | uri.AppendPath("/resourcegroups/", false); |
| 4 | 356 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 357 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 4 | 358 | | request.Uri = uri; |
| 4 | 359 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 360 | | var content = new Utf8JsonRequestContent(); |
| 4 | 361 | | content.JsonWriter.WriteObjectValue(parameters); |
| 4 | 362 | | request.Content = content; |
| 4 | 363 | | return message; |
| | 364 | | } |
| | 365 | |
|
| | 366 | | /// <summary> Resource groups can be updated through a simple PATCH operation to a group address. The format of |
| | 367 | | /// <param name="resourceGroupName"> The name of the resource group to update. The name is case insensitive. </p |
| | 368 | | /// <param name="parameters"> Parameters supplied to update a resource group. </param> |
| | 369 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 370 | | public async Task<Response<ResourceGroup>> UpdateAsync(string resourceGroupName, ResourceGroupPatchable paramete |
| | 371 | | { |
| 2 | 372 | | if (resourceGroupName == null) |
| | 373 | | { |
| 0 | 374 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 375 | | } |
| 2 | 376 | | if (parameters == null) |
| | 377 | | { |
| 0 | 378 | | throw new ArgumentNullException(nameof(parameters)); |
| | 379 | | } |
| | 380 | |
|
| 2 | 381 | | using var message = CreateUpdateRequest(resourceGroupName, parameters); |
| 2 | 382 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 383 | | switch (message.Response.Status) |
| | 384 | | { |
| | 385 | | case 200: |
| | 386 | | { |
| 2 | 387 | | ResourceGroup value = default; |
| 2 | 388 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 389 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 390 | | { |
| 0 | 391 | | value = null; |
| | 392 | | } |
| | 393 | | else |
| | 394 | | { |
| 2 | 395 | | value = ResourceGroup.DeserializeResourceGroup(document.RootElement); |
| | 396 | | } |
| 2 | 397 | | return Response.FromValue(value, message.Response); |
| | 398 | | } |
| | 399 | | default: |
| 0 | 400 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 401 | | } |
| 2 | 402 | | } |
| | 403 | |
|
| | 404 | | /// <summary> Resource groups can be updated through a simple PATCH operation to a group address. The format of |
| | 405 | | /// <param name="resourceGroupName"> The name of the resource group to update. The name is case insensitive. </p |
| | 406 | | /// <param name="parameters"> Parameters supplied to update a resource group. </param> |
| | 407 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 408 | | public Response<ResourceGroup> Update(string resourceGroupName, ResourceGroupPatchable parameters, CancellationT |
| | 409 | | { |
| 2 | 410 | | if (resourceGroupName == null) |
| | 411 | | { |
| 0 | 412 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 413 | | } |
| 2 | 414 | | if (parameters == null) |
| | 415 | | { |
| 0 | 416 | | throw new ArgumentNullException(nameof(parameters)); |
| | 417 | | } |
| | 418 | |
|
| 2 | 419 | | using var message = CreateUpdateRequest(resourceGroupName, parameters); |
| 2 | 420 | | _pipeline.Send(message, cancellationToken); |
| 2 | 421 | | switch (message.Response.Status) |
| | 422 | | { |
| | 423 | | case 200: |
| | 424 | | { |
| 2 | 425 | | ResourceGroup value = default; |
| 2 | 426 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 427 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 428 | | { |
| 0 | 429 | | value = null; |
| | 430 | | } |
| | 431 | | else |
| | 432 | | { |
| 2 | 433 | | value = ResourceGroup.DeserializeResourceGroup(document.RootElement); |
| | 434 | | } |
| 2 | 435 | | return Response.FromValue(value, message.Response); |
| | 436 | | } |
| | 437 | | default: |
| 0 | 438 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 439 | | } |
| 2 | 440 | | } |
| | 441 | |
|
| | 442 | | internal Core.HttpMessage CreateExportTemplateRequest(string resourceGroupName, ExportTemplateRequest parameters |
| | 443 | | { |
| 0 | 444 | | var message = _pipeline.CreateMessage(); |
| 0 | 445 | | var request = message.Request; |
| 0 | 446 | | request.Method = RequestMethod.Post; |
| 0 | 447 | | var uri = new RawRequestUriBuilder(); |
| 0 | 448 | | uri.Reset(endpoint); |
| 0 | 449 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 450 | | uri.AppendPath(subscriptionId, true); |
| 0 | 451 | | uri.AppendPath("/resourcegroups/", false); |
| 0 | 452 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 453 | | uri.AppendPath("/exportTemplate", false); |
| 0 | 454 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 455 | | request.Uri = uri; |
| 0 | 456 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 457 | | var content = new Utf8JsonRequestContent(); |
| 0 | 458 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 459 | | request.Content = content; |
| 0 | 460 | | return message; |
| | 461 | | } |
| | 462 | |
|
| | 463 | | /// <summary> Captures the specified resource group as a template. </summary> |
| | 464 | | /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param> |
| | 465 | | /// <param name="parameters"> Parameters for exporting the template. </param> |
| | 466 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 467 | | public async Task<Response> ExportTemplateAsync(string resourceGroupName, ExportTemplateRequest parameters, Canc |
| | 468 | | { |
| 0 | 469 | | if (resourceGroupName == null) |
| | 470 | | { |
| 0 | 471 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 472 | | } |
| 0 | 473 | | if (parameters == null) |
| | 474 | | { |
| 0 | 475 | | throw new ArgumentNullException(nameof(parameters)); |
| | 476 | | } |
| | 477 | |
|
| 0 | 478 | | using var message = CreateExportTemplateRequest(resourceGroupName, parameters); |
| 0 | 479 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 480 | | switch (message.Response.Status) |
| | 481 | | { |
| | 482 | | case 200: |
| | 483 | | case 202: |
| 0 | 484 | | return message.Response; |
| | 485 | | default: |
| 0 | 486 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 487 | | } |
| 0 | 488 | | } |
| | 489 | |
|
| | 490 | | /// <summary> Captures the specified resource group as a template. </summary> |
| | 491 | | /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param> |
| | 492 | | /// <param name="parameters"> Parameters for exporting the template. </param> |
| | 493 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 494 | | public Response ExportTemplate(string resourceGroupName, ExportTemplateRequest parameters, CancellationToken can |
| | 495 | | { |
| 0 | 496 | | if (resourceGroupName == null) |
| | 497 | | { |
| 0 | 498 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 499 | | } |
| 0 | 500 | | if (parameters == null) |
| | 501 | | { |
| 0 | 502 | | throw new ArgumentNullException(nameof(parameters)); |
| | 503 | | } |
| | 504 | |
|
| 0 | 505 | | using var message = CreateExportTemplateRequest(resourceGroupName, parameters); |
| 0 | 506 | | _pipeline.Send(message, cancellationToken); |
| 0 | 507 | | switch (message.Response.Status) |
| | 508 | | { |
| | 509 | | case 200: |
| | 510 | | case 202: |
| 0 | 511 | | return message.Response; |
| | 512 | | default: |
| 0 | 513 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 514 | | } |
| 0 | 515 | | } |
| | 516 | |
|
| | 517 | | internal Core.HttpMessage CreateListRequest(string filter, int? top) |
| | 518 | | { |
| 20 | 519 | | var message = _pipeline.CreateMessage(); |
| 20 | 520 | | var request = message.Request; |
| 20 | 521 | | request.Method = RequestMethod.Get; |
| 20 | 522 | | var uri = new RawRequestUriBuilder(); |
| 20 | 523 | | uri.Reset(endpoint); |
| 20 | 524 | | uri.AppendPath("/subscriptions/", false); |
| 20 | 525 | | uri.AppendPath(subscriptionId, true); |
| 20 | 526 | | uri.AppendPath("/resourcegroups", false); |
| 20 | 527 | | if (filter != null) |
| | 528 | | { |
| 0 | 529 | | uri.AppendQuery("$filter", filter, true); |
| | 530 | | } |
| 20 | 531 | | if (top != null) |
| | 532 | | { |
| 4 | 533 | | uri.AppendQuery("$top", top.Value, true); |
| | 534 | | } |
| 20 | 535 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 20 | 536 | | request.Uri = uri; |
| 20 | 537 | | return message; |
| | 538 | | } |
| | 539 | |
|
| | 540 | | /// <summary> Gets all the resource groups for a subscription. </summary> |
| | 541 | | /// <param name="filter"> The filter to apply on the operation.<br><br>You can filter by tag names a |
| | 542 | | /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param> |
| | 543 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 544 | | public async Task<Response<ResourceGroupListResult>> ListAsync(string filter = null, int? top = null, Cancellati |
| | 545 | | { |
| 10 | 546 | | using var message = CreateListRequest(filter, top); |
| 10 | 547 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 10 | 548 | | switch (message.Response.Status) |
| | 549 | | { |
| | 550 | | case 200: |
| | 551 | | { |
| 10 | 552 | | ResourceGroupListResult value = default; |
| 10 | 553 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 10 | 554 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 555 | | { |
| 0 | 556 | | value = null; |
| | 557 | | } |
| | 558 | | else |
| | 559 | | { |
| 10 | 560 | | value = ResourceGroupListResult.DeserializeResourceGroupListResult(document.RootElement); |
| | 561 | | } |
| 10 | 562 | | return Response.FromValue(value, message.Response); |
| | 563 | | } |
| | 564 | | default: |
| 0 | 565 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 566 | | } |
| 10 | 567 | | } |
| | 568 | |
|
| | 569 | | /// <summary> Gets all the resource groups for a subscription. </summary> |
| | 570 | | /// <param name="filter"> The filter to apply on the operation.<br><br>You can filter by tag names a |
| | 571 | | /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param> |
| | 572 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 573 | | public Response<ResourceGroupListResult> List(string filter = null, int? top = null, CancellationToken cancellat |
| | 574 | | { |
| 10 | 575 | | using var message = CreateListRequest(filter, top); |
| 10 | 576 | | _pipeline.Send(message, cancellationToken); |
| 10 | 577 | | switch (message.Response.Status) |
| | 578 | | { |
| | 579 | | case 200: |
| | 580 | | { |
| 10 | 581 | | ResourceGroupListResult value = default; |
| 10 | 582 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 10 | 583 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 584 | | { |
| 0 | 585 | | value = null; |
| | 586 | | } |
| | 587 | | else |
| | 588 | | { |
| 10 | 589 | | value = ResourceGroupListResult.DeserializeResourceGroupListResult(document.RootElement); |
| | 590 | | } |
| 10 | 591 | | return Response.FromValue(value, message.Response); |
| | 592 | | } |
| | 593 | | default: |
| 0 | 594 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 595 | | } |
| 10 | 596 | | } |
| | 597 | |
|
| | 598 | | internal Core.HttpMessage CreateListNextPageRequest(string nextLink, string filter, int? top) |
| | 599 | | { |
| 0 | 600 | | var message = _pipeline.CreateMessage(); |
| 0 | 601 | | var request = message.Request; |
| 0 | 602 | | request.Method = RequestMethod.Get; |
| 0 | 603 | | var uri = new RawRequestUriBuilder(); |
| 0 | 604 | | uri.Reset(endpoint); |
| 0 | 605 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 606 | | request.Uri = uri; |
| 0 | 607 | | return message; |
| | 608 | | } |
| | 609 | |
|
| | 610 | | /// <summary> Gets all the resource groups for a subscription. </summary> |
| | 611 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 612 | | /// <param name="filter"> The filter to apply on the operation.<br><br>You can filter by tag names a |
| | 613 | | /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param> |
| | 614 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 615 | | public async Task<Response<ResourceGroupListResult>> ListNextPageAsync(string nextLink, string filter = null, in |
| | 616 | | { |
| 0 | 617 | | if (nextLink == null) |
| | 618 | | { |
| 0 | 619 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 620 | | } |
| | 621 | |
|
| 0 | 622 | | using var message = CreateListNextPageRequest(nextLink, filter, top); |
| 0 | 623 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 624 | | switch (message.Response.Status) |
| | 625 | | { |
| | 626 | | case 200: |
| | 627 | | { |
| 0 | 628 | | ResourceGroupListResult value = default; |
| 0 | 629 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 630 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 631 | | { |
| 0 | 632 | | value = null; |
| | 633 | | } |
| | 634 | | else |
| | 635 | | { |
| 0 | 636 | | value = ResourceGroupListResult.DeserializeResourceGroupListResult(document.RootElement); |
| | 637 | | } |
| 0 | 638 | | return Response.FromValue(value, message.Response); |
| | 639 | | } |
| | 640 | | default: |
| 0 | 641 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 642 | | } |
| 0 | 643 | | } |
| | 644 | |
|
| | 645 | | /// <summary> Gets all the resource groups for a subscription. </summary> |
| | 646 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 647 | | /// <param name="filter"> The filter to apply on the operation.<br><br>You can filter by tag names a |
| | 648 | | /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param> |
| | 649 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 650 | | public Response<ResourceGroupListResult> ListNextPage(string nextLink, string filter = null, int? top = null, Ca |
| | 651 | | { |
| 0 | 652 | | if (nextLink == null) |
| | 653 | | { |
| 0 | 654 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 655 | | } |
| | 656 | |
|
| 0 | 657 | | using var message = CreateListNextPageRequest(nextLink, filter, top); |
| 0 | 658 | | _pipeline.Send(message, cancellationToken); |
| 0 | 659 | | switch (message.Response.Status) |
| | 660 | | { |
| | 661 | | case 200: |
| | 662 | | { |
| 0 | 663 | | ResourceGroupListResult value = default; |
| 0 | 664 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 665 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 666 | | { |
| 0 | 667 | | value = null; |
| | 668 | | } |
| | 669 | | else |
| | 670 | | { |
| 0 | 671 | | value = ResourceGroupListResult.DeserializeResourceGroupListResult(document.RootElement); |
| | 672 | | } |
| 0 | 673 | | return Response.FromValue(value, message.Response); |
| | 674 | | } |
| | 675 | | default: |
| 0 | 676 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 677 | | } |
| 0 | 678 | | } |
| | 679 | | } |
| | 680 | | } |