| | 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 ResourcesRestOperations |
| | 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 ResourcesRestOperations. </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 |
| 336 | 32 | | public ResourcesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId |
| | 33 | | { |
| 336 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 336 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 336 | 40 | | this.subscriptionId = subscriptionId; |
| 336 | 41 | | this.endpoint = endpoint; |
| 336 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 336 | 43 | | _pipeline = pipeline; |
| 336 | 44 | | } |
| | 45 | |
|
| | 46 | | internal Core.HttpMessage CreateListByResourceGroupRequest(string resourceGroupName, string filter, string expan |
| | 47 | | { |
| 32 | 48 | | var message = _pipeline.CreateMessage(); |
| 32 | 49 | | var request = message.Request; |
| 32 | 50 | | request.Method = RequestMethod.Get; |
| 32 | 51 | | var uri = new RawRequestUriBuilder(); |
| 32 | 52 | | uri.Reset(endpoint); |
| 32 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 32 | 54 | | uri.AppendPath(subscriptionId, true); |
| 32 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 32 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 32 | 57 | | uri.AppendPath("/resources", false); |
| 32 | 58 | | if (filter != null) |
| | 59 | | { |
| 16 | 60 | | uri.AppendQuery("$filter", filter, true); |
| | 61 | | } |
| 32 | 62 | | if (expand != null) |
| | 63 | | { |
| 0 | 64 | | uri.AppendQuery("$expand", expand, true); |
| | 65 | | } |
| 32 | 66 | | if (top != null) |
| | 67 | | { |
| 4 | 68 | | uri.AppendQuery("$top", top.Value, true); |
| | 69 | | } |
| 32 | 70 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 32 | 71 | | request.Uri = uri; |
| 32 | 72 | | return message; |
| | 73 | | } |
| | 74 | |
|
| | 75 | | /// <summary> Get all the resources for a resource group. </summary> |
| | 76 | | /// <param name="resourceGroupName"> The resource group with the resources to get. </param> |
| | 77 | | /// <param name="filter"> The filter to apply on the operation.<br><br>The properties you can use fo |
| | 78 | | /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va |
| | 79 | | /// <param name="top"> The number of results to return. If null is passed, returns all resources. </param> |
| | 80 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 81 | | public async Task<Response<ResourceListResult>> ListByResourceGroupAsync(string resourceGroupName, string filter |
| | 82 | | { |
| 16 | 83 | | if (resourceGroupName == null) |
| | 84 | | { |
| 0 | 85 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 86 | | } |
| | 87 | |
|
| 16 | 88 | | using var message = CreateListByResourceGroupRequest(resourceGroupName, filter, expand, top); |
| 16 | 89 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 16 | 90 | | switch (message.Response.Status) |
| | 91 | | { |
| | 92 | | case 200: |
| | 93 | | { |
| 16 | 94 | | ResourceListResult value = default; |
| 16 | 95 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 16 | 96 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 97 | | { |
| 0 | 98 | | value = null; |
| | 99 | | } |
| | 100 | | else |
| | 101 | | { |
| 16 | 102 | | value = ResourceListResult.DeserializeResourceListResult(document.RootElement); |
| | 103 | | } |
| 16 | 104 | | return Response.FromValue(value, message.Response); |
| | 105 | | } |
| | 106 | | default: |
| 0 | 107 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 108 | | } |
| 16 | 109 | | } |
| | 110 | |
|
| | 111 | | /// <summary> Get all the resources for a resource group. </summary> |
| | 112 | | /// <param name="resourceGroupName"> The resource group with the resources to get. </param> |
| | 113 | | /// <param name="filter"> The filter to apply on the operation.<br><br>The properties you can use fo |
| | 114 | | /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va |
| | 115 | | /// <param name="top"> The number of results to return. If null is passed, returns all resources. </param> |
| | 116 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 117 | | public Response<ResourceListResult> ListByResourceGroup(string resourceGroupName, string filter = null, string e |
| | 118 | | { |
| 16 | 119 | | if (resourceGroupName == null) |
| | 120 | | { |
| 0 | 121 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 122 | | } |
| | 123 | |
|
| 16 | 124 | | using var message = CreateListByResourceGroupRequest(resourceGroupName, filter, expand, top); |
| 16 | 125 | | _pipeline.Send(message, cancellationToken); |
| 16 | 126 | | switch (message.Response.Status) |
| | 127 | | { |
| | 128 | | case 200: |
| | 129 | | { |
| 16 | 130 | | ResourceListResult value = default; |
| 16 | 131 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 16 | 132 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 133 | | { |
| 0 | 134 | | value = null; |
| | 135 | | } |
| | 136 | | else |
| | 137 | | { |
| 16 | 138 | | value = ResourceListResult.DeserializeResourceListResult(document.RootElement); |
| | 139 | | } |
| 16 | 140 | | return Response.FromValue(value, message.Response); |
| | 141 | | } |
| | 142 | | default: |
| 0 | 143 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 144 | | } |
| 16 | 145 | | } |
| | 146 | |
|
| | 147 | | internal Core.HttpMessage CreateMoveResourcesRequest(string sourceResourceGroupName, ResourcesMoveInfo parameter |
| | 148 | | { |
| 0 | 149 | | var message = _pipeline.CreateMessage(); |
| 0 | 150 | | var request = message.Request; |
| 0 | 151 | | request.Method = RequestMethod.Post; |
| 0 | 152 | | var uri = new RawRequestUriBuilder(); |
| 0 | 153 | | uri.Reset(endpoint); |
| 0 | 154 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 155 | | uri.AppendPath(subscriptionId, true); |
| 0 | 156 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 157 | | uri.AppendPath(sourceResourceGroupName, true); |
| 0 | 158 | | uri.AppendPath("/moveResources", false); |
| 0 | 159 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 160 | | request.Uri = uri; |
| 0 | 161 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 162 | | var content = new Utf8JsonRequestContent(); |
| 0 | 163 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 164 | | request.Content = content; |
| 0 | 165 | | return message; |
| | 166 | | } |
| | 167 | |
|
| | 168 | | /// <summary> The resources to move must be in the same source resource group. The target resource group may be |
| | 169 | | /// <param name="sourceResourceGroupName"> The name of the resource group containing the resources to move. </pa |
| | 170 | | /// <param name="parameters"> Parameters for moving resources. </param> |
| | 171 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 172 | | public async Task<Response> MoveResourcesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, Can |
| | 173 | | { |
| 0 | 174 | | if (sourceResourceGroupName == null) |
| | 175 | | { |
| 0 | 176 | | throw new ArgumentNullException(nameof(sourceResourceGroupName)); |
| | 177 | | } |
| 0 | 178 | | if (parameters == null) |
| | 179 | | { |
| 0 | 180 | | throw new ArgumentNullException(nameof(parameters)); |
| | 181 | | } |
| | 182 | |
|
| 0 | 183 | | using var message = CreateMoveResourcesRequest(sourceResourceGroupName, parameters); |
| 0 | 184 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 185 | | switch (message.Response.Status) |
| | 186 | | { |
| | 187 | | case 202: |
| | 188 | | case 204: |
| 0 | 189 | | return message.Response; |
| | 190 | | default: |
| 0 | 191 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 192 | | } |
| 0 | 193 | | } |
| | 194 | |
|
| | 195 | | /// <summary> The resources to move must be in the same source resource group. The target resource group may be |
| | 196 | | /// <param name="sourceResourceGroupName"> The name of the resource group containing the resources to move. </pa |
| | 197 | | /// <param name="parameters"> Parameters for moving resources. </param> |
| | 198 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 199 | | public Response MoveResources(string sourceResourceGroupName, ResourcesMoveInfo parameters, CancellationToken ca |
| | 200 | | { |
| 0 | 201 | | if (sourceResourceGroupName == null) |
| | 202 | | { |
| 0 | 203 | | throw new ArgumentNullException(nameof(sourceResourceGroupName)); |
| | 204 | | } |
| 0 | 205 | | if (parameters == null) |
| | 206 | | { |
| 0 | 207 | | throw new ArgumentNullException(nameof(parameters)); |
| | 208 | | } |
| | 209 | |
|
| 0 | 210 | | using var message = CreateMoveResourcesRequest(sourceResourceGroupName, parameters); |
| 0 | 211 | | _pipeline.Send(message, cancellationToken); |
| 0 | 212 | | switch (message.Response.Status) |
| | 213 | | { |
| | 214 | | case 202: |
| | 215 | | case 204: |
| 0 | 216 | | return message.Response; |
| | 217 | | default: |
| 0 | 218 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 219 | | } |
| 0 | 220 | | } |
| | 221 | |
|
| | 222 | | internal Core.HttpMessage CreateValidateMoveResourcesRequest(string sourceResourceGroupName, ResourcesMoveInfo p |
| | 223 | | { |
| 0 | 224 | | var message = _pipeline.CreateMessage(); |
| 0 | 225 | | var request = message.Request; |
| 0 | 226 | | request.Method = RequestMethod.Post; |
| 0 | 227 | | var uri = new RawRequestUriBuilder(); |
| 0 | 228 | | uri.Reset(endpoint); |
| 0 | 229 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 230 | | uri.AppendPath(subscriptionId, true); |
| 0 | 231 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 232 | | uri.AppendPath(sourceResourceGroupName, true); |
| 0 | 233 | | uri.AppendPath("/validateMoveResources", false); |
| 0 | 234 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 235 | | request.Uri = uri; |
| 0 | 236 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 237 | | var content = new Utf8JsonRequestContent(); |
| 0 | 238 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 239 | | request.Content = content; |
| 0 | 240 | | return message; |
| | 241 | | } |
| | 242 | |
|
| | 243 | | /// <summary> This operation checks whether the specified resources can be moved to the target. The resources to |
| | 244 | | /// <param name="sourceResourceGroupName"> The name of the resource group containing the resources to validate f |
| | 245 | | /// <param name="parameters"> Parameters for moving resources. </param> |
| | 246 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 247 | | public async Task<Response> ValidateMoveResourcesAsync(string sourceResourceGroupName, ResourcesMoveInfo paramet |
| | 248 | | { |
| 0 | 249 | | if (sourceResourceGroupName == null) |
| | 250 | | { |
| 0 | 251 | | throw new ArgumentNullException(nameof(sourceResourceGroupName)); |
| | 252 | | } |
| 0 | 253 | | if (parameters == null) |
| | 254 | | { |
| 0 | 255 | | throw new ArgumentNullException(nameof(parameters)); |
| | 256 | | } |
| | 257 | |
|
| 0 | 258 | | using var message = CreateValidateMoveResourcesRequest(sourceResourceGroupName, parameters); |
| 0 | 259 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 260 | | switch (message.Response.Status) |
| | 261 | | { |
| | 262 | | case 202: |
| | 263 | | case 204: |
| 0 | 264 | | return message.Response; |
| | 265 | | default: |
| 0 | 266 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 267 | | } |
| 0 | 268 | | } |
| | 269 | |
|
| | 270 | | /// <summary> This operation checks whether the specified resources can be moved to the target. The resources to |
| | 271 | | /// <param name="sourceResourceGroupName"> The name of the resource group containing the resources to validate f |
| | 272 | | /// <param name="parameters"> Parameters for moving resources. </param> |
| | 273 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 274 | | public Response ValidateMoveResources(string sourceResourceGroupName, ResourcesMoveInfo parameters, Cancellation |
| | 275 | | { |
| 0 | 276 | | if (sourceResourceGroupName == null) |
| | 277 | | { |
| 0 | 278 | | throw new ArgumentNullException(nameof(sourceResourceGroupName)); |
| | 279 | | } |
| 0 | 280 | | if (parameters == null) |
| | 281 | | { |
| 0 | 282 | | throw new ArgumentNullException(nameof(parameters)); |
| | 283 | | } |
| | 284 | |
|
| 0 | 285 | | using var message = CreateValidateMoveResourcesRequest(sourceResourceGroupName, parameters); |
| 0 | 286 | | _pipeline.Send(message, cancellationToken); |
| 0 | 287 | | switch (message.Response.Status) |
| | 288 | | { |
| | 289 | | case 202: |
| | 290 | | case 204: |
| 0 | 291 | | return message.Response; |
| | 292 | | default: |
| 0 | 293 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 294 | | } |
| 0 | 295 | | } |
| | 296 | |
|
| | 297 | | internal Core.HttpMessage CreateListRequest(string filter, string expand, int? top) |
| | 298 | | { |
| 4 | 299 | | var message = _pipeline.CreateMessage(); |
| 4 | 300 | | var request = message.Request; |
| 4 | 301 | | request.Method = RequestMethod.Get; |
| 4 | 302 | | var uri = new RawRequestUriBuilder(); |
| 4 | 303 | | uri.Reset(endpoint); |
| 4 | 304 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 305 | | uri.AppendPath(subscriptionId, true); |
| 4 | 306 | | uri.AppendPath("/resources", false); |
| 4 | 307 | | if (filter != null) |
| | 308 | | { |
| 0 | 309 | | uri.AppendQuery("$filter", filter, true); |
| | 310 | | } |
| 4 | 311 | | if (expand != null) |
| | 312 | | { |
| 0 | 313 | | uri.AppendQuery("$expand", expand, true); |
| | 314 | | } |
| 4 | 315 | | if (top != null) |
| | 316 | | { |
| 0 | 317 | | uri.AppendQuery("$top", top.Value, true); |
| | 318 | | } |
| 4 | 319 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 4 | 320 | | request.Uri = uri; |
| 4 | 321 | | return message; |
| | 322 | | } |
| | 323 | |
|
| | 324 | | /// <summary> Get all the resources in a subscription. </summary> |
| | 325 | | /// <param name="filter"> The filter to apply on the operation.<br><br>The properties you can use fo |
| | 326 | | /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va |
| | 327 | | /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param> |
| | 328 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 329 | | public async Task<Response<ResourceListResult>> ListAsync(string filter = null, string expand = null, int? top = |
| | 330 | | { |
| 2 | 331 | | using var message = CreateListRequest(filter, expand, top); |
| 2 | 332 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 333 | | switch (message.Response.Status) |
| | 334 | | { |
| | 335 | | case 200: |
| | 336 | | { |
| 2 | 337 | | ResourceListResult value = default; |
| 2 | 338 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 339 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 340 | | { |
| 0 | 341 | | value = null; |
| | 342 | | } |
| | 343 | | else |
| | 344 | | { |
| 2 | 345 | | value = ResourceListResult.DeserializeResourceListResult(document.RootElement); |
| | 346 | | } |
| 2 | 347 | | return Response.FromValue(value, message.Response); |
| | 348 | | } |
| | 349 | | default: |
| 0 | 350 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 351 | | } |
| 2 | 352 | | } |
| | 353 | |
|
| | 354 | | /// <summary> Get all the resources in a subscription. </summary> |
| | 355 | | /// <param name="filter"> The filter to apply on the operation.<br><br>The properties you can use fo |
| | 356 | | /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va |
| | 357 | | /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param> |
| | 358 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 359 | | public Response<ResourceListResult> List(string filter = null, string expand = null, int? top = null, Cancellati |
| | 360 | | { |
| 2 | 361 | | using var message = CreateListRequest(filter, expand, top); |
| 2 | 362 | | _pipeline.Send(message, cancellationToken); |
| 2 | 363 | | switch (message.Response.Status) |
| | 364 | | { |
| | 365 | | case 200: |
| | 366 | | { |
| 2 | 367 | | ResourceListResult value = default; |
| 2 | 368 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 369 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 370 | | { |
| 0 | 371 | | value = null; |
| | 372 | | } |
| | 373 | | else |
| | 374 | | { |
| 2 | 375 | | value = ResourceListResult.DeserializeResourceListResult(document.RootElement); |
| | 376 | | } |
| 2 | 377 | | return Response.FromValue(value, message.Response); |
| | 378 | | } |
| | 379 | | default: |
| 0 | 380 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 381 | | } |
| 2 | 382 | | } |
| | 383 | |
|
| | 384 | | internal Core.HttpMessage CreateCheckExistenceRequest(string resourceGroupName, string resourceProviderNamespace |
| | 385 | | { |
| 12 | 386 | | var message = _pipeline.CreateMessage(); |
| 12 | 387 | | var request = message.Request; |
| 12 | 388 | | request.Method = RequestMethod.Head; |
| 12 | 389 | | var uri = new RawRequestUriBuilder(); |
| 12 | 390 | | uri.Reset(endpoint); |
| 12 | 391 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 392 | | uri.AppendPath(subscriptionId, true); |
| 12 | 393 | | uri.AppendPath("/resourcegroups/", false); |
| 12 | 394 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 395 | | uri.AppendPath("/providers/", false); |
| 12 | 396 | | uri.AppendPath(resourceProviderNamespace, true); |
| 12 | 397 | | uri.AppendPath("/", false); |
| 12 | 398 | | uri.AppendPath(parentResourcePath, false); |
| 12 | 399 | | uri.AppendPath("/", false); |
| 12 | 400 | | uri.AppendPath(resourceType, false); |
| 12 | 401 | | uri.AppendPath("/", false); |
| 12 | 402 | | uri.AppendPath(resourceName, true); |
| 12 | 403 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 404 | | request.Uri = uri; |
| 12 | 405 | | return message; |
| | 406 | | } |
| | 407 | |
|
| | 408 | | /// <summary> Checks whether a resource exists. </summary> |
| | 409 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource to check. The name i |
| | 410 | | /// <param name="resourceProviderNamespace"> The resource provider of the resource to check. </param> |
| | 411 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 412 | | /// <param name="resourceType"> The resource type. </param> |
| | 413 | | /// <param name="resourceName"> The name of the resource to check whether it exists. </param> |
| | 414 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 415 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 416 | | public async Task<Response> CheckExistenceAsync(string resourceGroupName, string resourceProviderNamespace, stri |
| | 417 | | { |
| 8 | 418 | | if (resourceGroupName == null) |
| | 419 | | { |
| 0 | 420 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 421 | | } |
| 8 | 422 | | if (resourceProviderNamespace == null) |
| | 423 | | { |
| 0 | 424 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 425 | | } |
| 8 | 426 | | if (parentResourcePath == null) |
| | 427 | | { |
| 0 | 428 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 429 | | } |
| 8 | 430 | | if (resourceType == null) |
| | 431 | | { |
| 0 | 432 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 433 | | } |
| 8 | 434 | | if (resourceName == null) |
| | 435 | | { |
| 0 | 436 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 437 | | } |
| 8 | 438 | | if (apiVersion == null) |
| | 439 | | { |
| 2 | 440 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 441 | | } |
| | 442 | |
|
| 6 | 443 | | using var message = CreateCheckExistenceRequest(resourceGroupName, resourceProviderNamespace, parentResource |
| 6 | 444 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 445 | | switch (message.Response.Status) |
| | 446 | | { |
| | 447 | | case 204: |
| | 448 | | case 404: |
| 6 | 449 | | return message.Response; |
| | 450 | | default: |
| 0 | 451 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 452 | | } |
| 6 | 453 | | } |
| | 454 | |
|
| | 455 | | /// <summary> Checks whether a resource exists. </summary> |
| | 456 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource to check. The name i |
| | 457 | | /// <param name="resourceProviderNamespace"> The resource provider of the resource to check. </param> |
| | 458 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 459 | | /// <param name="resourceType"> The resource type. </param> |
| | 460 | | /// <param name="resourceName"> The name of the resource to check whether it exists. </param> |
| | 461 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 462 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 463 | | public Response CheckExistence(string resourceGroupName, string resourceProviderNamespace, string parentResource |
| | 464 | | { |
| 8 | 465 | | if (resourceGroupName == null) |
| | 466 | | { |
| 0 | 467 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 468 | | } |
| 8 | 469 | | if (resourceProviderNamespace == null) |
| | 470 | | { |
| 0 | 471 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 472 | | } |
| 8 | 473 | | if (parentResourcePath == null) |
| | 474 | | { |
| 0 | 475 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 476 | | } |
| 8 | 477 | | if (resourceType == null) |
| | 478 | | { |
| 0 | 479 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 480 | | } |
| 8 | 481 | | if (resourceName == null) |
| | 482 | | { |
| 0 | 483 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 484 | | } |
| 8 | 485 | | if (apiVersion == null) |
| | 486 | | { |
| 2 | 487 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 488 | | } |
| | 489 | |
|
| 6 | 490 | | using var message = CreateCheckExistenceRequest(resourceGroupName, resourceProviderNamespace, parentResource |
| 6 | 491 | | _pipeline.Send(message, cancellationToken); |
| 6 | 492 | | switch (message.Response.Status) |
| | 493 | | { |
| | 494 | | case 204: |
| | 495 | | case 404: |
| 6 | 496 | | return message.Response; |
| | 497 | | default: |
| 0 | 498 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 499 | | } |
| 6 | 500 | | } |
| | 501 | |
|
| | 502 | | internal Core.HttpMessage CreateDeleteRequest(string resourceGroupName, string resourceProviderNamespace, string |
| | 503 | | { |
| 24 | 504 | | var message = _pipeline.CreateMessage(); |
| 24 | 505 | | var request = message.Request; |
| 24 | 506 | | request.Method = RequestMethod.Delete; |
| 24 | 507 | | var uri = new RawRequestUriBuilder(); |
| 24 | 508 | | uri.Reset(endpoint); |
| 24 | 509 | | uri.AppendPath("/subscriptions/", false); |
| 24 | 510 | | uri.AppendPath(subscriptionId, true); |
| 24 | 511 | | uri.AppendPath("/resourcegroups/", false); |
| 24 | 512 | | uri.AppendPath(resourceGroupName, true); |
| 24 | 513 | | uri.AppendPath("/providers/", false); |
| 24 | 514 | | uri.AppendPath(resourceProviderNamespace, true); |
| 24 | 515 | | uri.AppendPath("/", false); |
| 24 | 516 | | uri.AppendPath(parentResourcePath, false); |
| 24 | 517 | | uri.AppendPath("/", false); |
| 24 | 518 | | uri.AppendPath(resourceType, false); |
| 24 | 519 | | uri.AppendPath("/", false); |
| 24 | 520 | | uri.AppendPath(resourceName, true); |
| 24 | 521 | | uri.AppendQuery("api-version", apiVersion, true); |
| 24 | 522 | | request.Uri = uri; |
| 24 | 523 | | return message; |
| | 524 | | } |
| | 525 | |
|
| | 526 | | /// <summary> Deletes a resource. </summary> |
| | 527 | | /// <param name="resourceGroupName"> The name of the resource group that contains the resource to delete. The na |
| | 528 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 529 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 530 | | /// <param name="resourceType"> The resource type. </param> |
| | 531 | | /// <param name="resourceName"> The name of the resource to delete. </param> |
| | 532 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 533 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 534 | | public async Task<Response> DeleteAsync(string resourceGroupName, string resourceProviderNamespace, string paren |
| | 535 | | { |
| 6 | 536 | | if (resourceGroupName == null) |
| | 537 | | { |
| 0 | 538 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 539 | | } |
| 6 | 540 | | if (resourceProviderNamespace == null) |
| | 541 | | { |
| 0 | 542 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 543 | | } |
| 6 | 544 | | if (parentResourcePath == null) |
| | 545 | | { |
| 0 | 546 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 547 | | } |
| 6 | 548 | | if (resourceType == null) |
| | 549 | | { |
| 0 | 550 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 551 | | } |
| 6 | 552 | | if (resourceName == null) |
| | 553 | | { |
| 0 | 554 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 555 | | } |
| 6 | 556 | | if (apiVersion == null) |
| | 557 | | { |
| 0 | 558 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 559 | | } |
| | 560 | |
|
| 6 | 561 | | using var message = CreateDeleteRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, re |
| 6 | 562 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 563 | | switch (message.Response.Status) |
| | 564 | | { |
| | 565 | | case 200: |
| | 566 | | case 202: |
| | 567 | | case 204: |
| 6 | 568 | | return message.Response; |
| | 569 | | default: |
| 0 | 570 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 571 | | } |
| 6 | 572 | | } |
| | 573 | |
|
| | 574 | | /// <summary> Deletes a resource. </summary> |
| | 575 | | /// <param name="resourceGroupName"> The name of the resource group that contains the resource to delete. The na |
| | 576 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 577 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 578 | | /// <param name="resourceType"> The resource type. </param> |
| | 579 | | /// <param name="resourceName"> The name of the resource to delete. </param> |
| | 580 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 581 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 582 | | public Response Delete(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, st |
| | 583 | | { |
| 6 | 584 | | if (resourceGroupName == null) |
| | 585 | | { |
| 0 | 586 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 587 | | } |
| 6 | 588 | | if (resourceProviderNamespace == null) |
| | 589 | | { |
| 0 | 590 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 591 | | } |
| 6 | 592 | | if (parentResourcePath == null) |
| | 593 | | { |
| 0 | 594 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 595 | | } |
| 6 | 596 | | if (resourceType == null) |
| | 597 | | { |
| 0 | 598 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 599 | | } |
| 6 | 600 | | if (resourceName == null) |
| | 601 | | { |
| 0 | 602 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 603 | | } |
| 6 | 604 | | if (apiVersion == null) |
| | 605 | | { |
| 0 | 606 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 607 | | } |
| | 608 | |
|
| 6 | 609 | | using var message = CreateDeleteRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, re |
| 6 | 610 | | _pipeline.Send(message, cancellationToken); |
| 6 | 611 | | switch (message.Response.Status) |
| | 612 | | { |
| | 613 | | case 200: |
| | 614 | | case 202: |
| | 615 | | case 204: |
| 6 | 616 | | return message.Response; |
| | 617 | | default: |
| 0 | 618 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 619 | | } |
| 6 | 620 | | } |
| | 621 | |
|
| | 622 | | internal Core.HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string resourceProviderNamespace |
| | 623 | | { |
| 96 | 624 | | var message = _pipeline.CreateMessage(); |
| 96 | 625 | | var request = message.Request; |
| 96 | 626 | | request.Method = RequestMethod.Put; |
| 96 | 627 | | var uri = new RawRequestUriBuilder(); |
| 96 | 628 | | uri.Reset(endpoint); |
| 96 | 629 | | uri.AppendPath("/subscriptions/", false); |
| 96 | 630 | | uri.AppendPath(subscriptionId, true); |
| 96 | 631 | | uri.AppendPath("/resourcegroups/", false); |
| 96 | 632 | | uri.AppendPath(resourceGroupName, true); |
| 96 | 633 | | uri.AppendPath("/providers/", false); |
| 96 | 634 | | uri.AppendPath(resourceProviderNamespace, true); |
| 96 | 635 | | uri.AppendPath("/", false); |
| 96 | 636 | | uri.AppendPath(parentResourcePath, false); |
| 96 | 637 | | uri.AppendPath("/", false); |
| 96 | 638 | | uri.AppendPath(resourceType, false); |
| 96 | 639 | | uri.AppendPath("/", false); |
| 96 | 640 | | uri.AppendPath(resourceName, true); |
| 96 | 641 | | uri.AppendQuery("api-version", apiVersion, true); |
| 96 | 642 | | request.Uri = uri; |
| 96 | 643 | | request.Headers.Add("Content-Type", "application/json"); |
| 96 | 644 | | var content = new Utf8JsonRequestContent(); |
| 96 | 645 | | content.JsonWriter.WriteObjectValue(parameters); |
| 96 | 646 | | request.Content = content; |
| 96 | 647 | | return message; |
| | 648 | | } |
| | 649 | |
|
| | 650 | | /// <summary> Creates a resource. </summary> |
| | 651 | | /// <param name="resourceGroupName"> The name of the resource group for the resource. The name is case insensiti |
| | 652 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 653 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 654 | | /// <param name="resourceType"> The resource type of the resource to create. </param> |
| | 655 | | /// <param name="resourceName"> The name of the resource to create. </param> |
| | 656 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 657 | | /// <param name="parameters"> Parameters for creating or updating the resource. </param> |
| | 658 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 659 | | public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string resourceProviderNamespace, stri |
| | 660 | | { |
| 24 | 661 | | if (resourceGroupName == null) |
| | 662 | | { |
| 0 | 663 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 664 | | } |
| 24 | 665 | | if (resourceProviderNamespace == null) |
| | 666 | | { |
| 0 | 667 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 668 | | } |
| 24 | 669 | | if (parentResourcePath == null) |
| | 670 | | { |
| 0 | 671 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 672 | | } |
| 24 | 673 | | if (resourceType == null) |
| | 674 | | { |
| 0 | 675 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 676 | | } |
| 24 | 677 | | if (resourceName == null) |
| | 678 | | { |
| 0 | 679 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 680 | | } |
| 24 | 681 | | if (apiVersion == null) |
| | 682 | | { |
| 0 | 683 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 684 | | } |
| 24 | 685 | | if (parameters == null) |
| | 686 | | { |
| 0 | 687 | | throw new ArgumentNullException(nameof(parameters)); |
| | 688 | | } |
| | 689 | |
|
| 24 | 690 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, resourceProviderNamespace, parentResource |
| 24 | 691 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 24 | 692 | | switch (message.Response.Status) |
| | 693 | | { |
| | 694 | | case 200: |
| | 695 | | case 201: |
| | 696 | | case 202: |
| 24 | 697 | | return message.Response; |
| | 698 | | default: |
| 0 | 699 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 700 | | } |
| 24 | 701 | | } |
| | 702 | |
|
| | 703 | | /// <summary> Creates a resource. </summary> |
| | 704 | | /// <param name="resourceGroupName"> The name of the resource group for the resource. The name is case insensiti |
| | 705 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 706 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 707 | | /// <param name="resourceType"> The resource type of the resource to create. </param> |
| | 708 | | /// <param name="resourceName"> The name of the resource to create. </param> |
| | 709 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 710 | | /// <param name="parameters"> Parameters for creating or updating the resource. </param> |
| | 711 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 712 | | public Response CreateOrUpdate(string resourceGroupName, string resourceProviderNamespace, string parentResource |
| | 713 | | { |
| 24 | 714 | | if (resourceGroupName == null) |
| | 715 | | { |
| 0 | 716 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 717 | | } |
| 24 | 718 | | if (resourceProviderNamespace == null) |
| | 719 | | { |
| 0 | 720 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 721 | | } |
| 24 | 722 | | if (parentResourcePath == null) |
| | 723 | | { |
| 0 | 724 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 725 | | } |
| 24 | 726 | | if (resourceType == null) |
| | 727 | | { |
| 0 | 728 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 729 | | } |
| 24 | 730 | | if (resourceName == null) |
| | 731 | | { |
| 0 | 732 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 733 | | } |
| 24 | 734 | | if (apiVersion == null) |
| | 735 | | { |
| 0 | 736 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 737 | | } |
| 24 | 738 | | if (parameters == null) |
| | 739 | | { |
| 0 | 740 | | throw new ArgumentNullException(nameof(parameters)); |
| | 741 | | } |
| | 742 | |
|
| 24 | 743 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, resourceProviderNamespace, parentResource |
| 24 | 744 | | _pipeline.Send(message, cancellationToken); |
| 24 | 745 | | switch (message.Response.Status) |
| | 746 | | { |
| | 747 | | case 200: |
| | 748 | | case 201: |
| | 749 | | case 202: |
| 24 | 750 | | return message.Response; |
| | 751 | | default: |
| 0 | 752 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 753 | | } |
| 24 | 754 | | } |
| | 755 | |
|
| | 756 | | internal Core.HttpMessage CreateUpdateRequest(string resourceGroupName, string resourceProviderNamespace, string |
| | 757 | | { |
| 0 | 758 | | var message = _pipeline.CreateMessage(); |
| 0 | 759 | | var request = message.Request; |
| 0 | 760 | | request.Method = RequestMethod.Patch; |
| 0 | 761 | | var uri = new RawRequestUriBuilder(); |
| 0 | 762 | | uri.Reset(endpoint); |
| 0 | 763 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 764 | | uri.AppendPath(subscriptionId, true); |
| 0 | 765 | | uri.AppendPath("/resourcegroups/", false); |
| 0 | 766 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 767 | | uri.AppendPath("/providers/", false); |
| 0 | 768 | | uri.AppendPath(resourceProviderNamespace, true); |
| 0 | 769 | | uri.AppendPath("/", false); |
| 0 | 770 | | uri.AppendPath(parentResourcePath, false); |
| 0 | 771 | | uri.AppendPath("/", false); |
| 0 | 772 | | uri.AppendPath(resourceType, false); |
| 0 | 773 | | uri.AppendPath("/", false); |
| 0 | 774 | | uri.AppendPath(resourceName, true); |
| 0 | 775 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 776 | | request.Uri = uri; |
| 0 | 777 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 778 | | var content = new Utf8JsonRequestContent(); |
| 0 | 779 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 780 | | request.Content = content; |
| 0 | 781 | | return message; |
| | 782 | | } |
| | 783 | |
|
| | 784 | | /// <summary> Updates a resource. </summary> |
| | 785 | | /// <param name="resourceGroupName"> The name of the resource group for the resource. The name is case insensiti |
| | 786 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 787 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 788 | | /// <param name="resourceType"> The resource type of the resource to update. </param> |
| | 789 | | /// <param name="resourceName"> The name of the resource to update. </param> |
| | 790 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 791 | | /// <param name="parameters"> Parameters for updating the resource. </param> |
| | 792 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 793 | | public async Task<Response> UpdateAsync(string resourceGroupName, string resourceProviderNamespace, string paren |
| | 794 | | { |
| 0 | 795 | | if (resourceGroupName == null) |
| | 796 | | { |
| 0 | 797 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 798 | | } |
| 0 | 799 | | if (resourceProviderNamespace == null) |
| | 800 | | { |
| 0 | 801 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 802 | | } |
| 0 | 803 | | if (parentResourcePath == null) |
| | 804 | | { |
| 0 | 805 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 806 | | } |
| 0 | 807 | | if (resourceType == null) |
| | 808 | | { |
| 0 | 809 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 810 | | } |
| 0 | 811 | | if (resourceName == null) |
| | 812 | | { |
| 0 | 813 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 814 | | } |
| 0 | 815 | | if (apiVersion == null) |
| | 816 | | { |
| 0 | 817 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 818 | | } |
| 0 | 819 | | if (parameters == null) |
| | 820 | | { |
| 0 | 821 | | throw new ArgumentNullException(nameof(parameters)); |
| | 822 | | } |
| | 823 | |
|
| 0 | 824 | | using var message = CreateUpdateRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, re |
| 0 | 825 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 826 | | switch (message.Response.Status) |
| | 827 | | { |
| | 828 | | case 200: |
| | 829 | | case 202: |
| 0 | 830 | | return message.Response; |
| | 831 | | default: |
| 0 | 832 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 833 | | } |
| 0 | 834 | | } |
| | 835 | |
|
| | 836 | | /// <summary> Updates a resource. </summary> |
| | 837 | | /// <param name="resourceGroupName"> The name of the resource group for the resource. The name is case insensiti |
| | 838 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 839 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 840 | | /// <param name="resourceType"> The resource type of the resource to update. </param> |
| | 841 | | /// <param name="resourceName"> The name of the resource to update. </param> |
| | 842 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 843 | | /// <param name="parameters"> Parameters for updating the resource. </param> |
| | 844 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 845 | | public Response Update(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, st |
| | 846 | | { |
| 0 | 847 | | if (resourceGroupName == null) |
| | 848 | | { |
| 0 | 849 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 850 | | } |
| 0 | 851 | | if (resourceProviderNamespace == null) |
| | 852 | | { |
| 0 | 853 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 854 | | } |
| 0 | 855 | | if (parentResourcePath == null) |
| | 856 | | { |
| 0 | 857 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 858 | | } |
| 0 | 859 | | if (resourceType == null) |
| | 860 | | { |
| 0 | 861 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 862 | | } |
| 0 | 863 | | if (resourceName == null) |
| | 864 | | { |
| 0 | 865 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 866 | | } |
| 0 | 867 | | if (apiVersion == null) |
| | 868 | | { |
| 0 | 869 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 870 | | } |
| 0 | 871 | | if (parameters == null) |
| | 872 | | { |
| 0 | 873 | | throw new ArgumentNullException(nameof(parameters)); |
| | 874 | | } |
| | 875 | |
|
| 0 | 876 | | using var message = CreateUpdateRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, re |
| 0 | 877 | | _pipeline.Send(message, cancellationToken); |
| 0 | 878 | | switch (message.Response.Status) |
| | 879 | | { |
| | 880 | | case 200: |
| | 881 | | case 202: |
| 0 | 882 | | return message.Response; |
| | 883 | | default: |
| 0 | 884 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 885 | | } |
| 0 | 886 | | } |
| | 887 | |
|
| | 888 | | internal Core.HttpMessage CreateGetRequest(string resourceGroupName, string resourceProviderNamespace, string pa |
| | 889 | | { |
| 20 | 890 | | var message = _pipeline.CreateMessage(); |
| 20 | 891 | | var request = message.Request; |
| 20 | 892 | | request.Method = RequestMethod.Get; |
| 20 | 893 | | var uri = new RawRequestUriBuilder(); |
| 20 | 894 | | uri.Reset(endpoint); |
| 20 | 895 | | uri.AppendPath("/subscriptions/", false); |
| 20 | 896 | | uri.AppendPath(subscriptionId, true); |
| 20 | 897 | | uri.AppendPath("/resourcegroups/", false); |
| 20 | 898 | | uri.AppendPath(resourceGroupName, true); |
| 20 | 899 | | uri.AppendPath("/providers/", false); |
| 20 | 900 | | uri.AppendPath(resourceProviderNamespace, true); |
| 20 | 901 | | uri.AppendPath("/", false); |
| 20 | 902 | | uri.AppendPath(parentResourcePath, false); |
| 20 | 903 | | uri.AppendPath("/", false); |
| 20 | 904 | | uri.AppendPath(resourceType, false); |
| 20 | 905 | | uri.AppendPath("/", false); |
| 20 | 906 | | uri.AppendPath(resourceName, true); |
| 20 | 907 | | uri.AppendQuery("api-version", apiVersion, true); |
| 20 | 908 | | request.Uri = uri; |
| 20 | 909 | | return message; |
| | 910 | | } |
| | 911 | |
|
| | 912 | | /// <summary> Gets a resource. </summary> |
| | 913 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource to get. The name is |
| | 914 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 915 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 916 | | /// <param name="resourceType"> The resource type of the resource. </param> |
| | 917 | | /// <param name="resourceName"> The name of the resource to get. </param> |
| | 918 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 919 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 920 | | public async Task<Response<GenericResource>> GetAsync(string resourceGroupName, string resourceProviderNamespace |
| | 921 | | { |
| 14 | 922 | | if (resourceGroupName == null) |
| | 923 | | { |
| 2 | 924 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 925 | | } |
| 12 | 926 | | if (resourceProviderNamespace == null) |
| | 927 | | { |
| 0 | 928 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 929 | | } |
| 12 | 930 | | if (parentResourcePath == null) |
| | 931 | | { |
| 0 | 932 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 933 | | } |
| 12 | 934 | | if (resourceType == null) |
| | 935 | | { |
| 0 | 936 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 937 | | } |
| 12 | 938 | | if (resourceName == null) |
| | 939 | | { |
| 0 | 940 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 941 | | } |
| 12 | 942 | | if (apiVersion == null) |
| | 943 | | { |
| 2 | 944 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 945 | | } |
| | 946 | |
|
| 10 | 947 | | using var message = CreateGetRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, resou |
| 10 | 948 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 10 | 949 | | switch (message.Response.Status) |
| | 950 | | { |
| | 951 | | case 200: |
| | 952 | | { |
| 10 | 953 | | GenericResource value = default; |
| 10 | 954 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 10 | 955 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 956 | | { |
| 0 | 957 | | value = null; |
| | 958 | | } |
| | 959 | | else |
| | 960 | | { |
| 10 | 961 | | value = GenericResource.DeserializeGenericResource(document.RootElement); |
| | 962 | | } |
| 10 | 963 | | return Response.FromValue(value, message.Response); |
| | 964 | | } |
| | 965 | | default: |
| 0 | 966 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 967 | | } |
| 10 | 968 | | } |
| | 969 | |
|
| | 970 | | /// <summary> Gets a resource. </summary> |
| | 971 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource to get. The name is |
| | 972 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 973 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 974 | | /// <param name="resourceType"> The resource type of the resource. </param> |
| | 975 | | /// <param name="resourceName"> The name of the resource to get. </param> |
| | 976 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 977 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 978 | | public Response<GenericResource> Get(string resourceGroupName, string resourceProviderNamespace, string parentRe |
| | 979 | | { |
| 14 | 980 | | if (resourceGroupName == null) |
| | 981 | | { |
| 2 | 982 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 983 | | } |
| 12 | 984 | | if (resourceProviderNamespace == null) |
| | 985 | | { |
| 0 | 986 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 987 | | } |
| 12 | 988 | | if (parentResourcePath == null) |
| | 989 | | { |
| 0 | 990 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 991 | | } |
| 12 | 992 | | if (resourceType == null) |
| | 993 | | { |
| 0 | 994 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 995 | | } |
| 12 | 996 | | if (resourceName == null) |
| | 997 | | { |
| 0 | 998 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 999 | | } |
| 12 | 1000 | | if (apiVersion == null) |
| | 1001 | | { |
| 2 | 1002 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1003 | | } |
| | 1004 | |
|
| 10 | 1005 | | using var message = CreateGetRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, resou |
| 10 | 1006 | | _pipeline.Send(message, cancellationToken); |
| 10 | 1007 | | switch (message.Response.Status) |
| | 1008 | | { |
| | 1009 | | case 200: |
| | 1010 | | { |
| 10 | 1011 | | GenericResource value = default; |
| 10 | 1012 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 10 | 1013 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1014 | | { |
| 0 | 1015 | | value = null; |
| | 1016 | | } |
| | 1017 | | else |
| | 1018 | | { |
| 10 | 1019 | | value = GenericResource.DeserializeGenericResource(document.RootElement); |
| | 1020 | | } |
| 10 | 1021 | | return Response.FromValue(value, message.Response); |
| | 1022 | | } |
| | 1023 | | default: |
| 0 | 1024 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1025 | | } |
| 10 | 1026 | | } |
| | 1027 | |
|
| | 1028 | | internal Core.HttpMessage CreateCheckExistenceByIdRequest(string resourceId, string apiVersion) |
| | 1029 | | { |
| 0 | 1030 | | var message = _pipeline.CreateMessage(); |
| 0 | 1031 | | var request = message.Request; |
| 0 | 1032 | | request.Method = RequestMethod.Head; |
| 0 | 1033 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1034 | | uri.Reset(endpoint); |
| 0 | 1035 | | uri.AppendPath("/", false); |
| 0 | 1036 | | uri.AppendPath(resourceId, false); |
| 0 | 1037 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 1038 | | request.Uri = uri; |
| 0 | 1039 | | return message; |
| | 1040 | | } |
| | 1041 | |
|
| | 1042 | | /// <summary> Checks by ID whether a resource exists. </summary> |
| | 1043 | | /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t |
| | 1044 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 1045 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1046 | | public async Task<Response> CheckExistenceByIdAsync(string resourceId, string apiVersion, CancellationToken canc |
| | 1047 | | { |
| 0 | 1048 | | if (resourceId == null) |
| | 1049 | | { |
| 0 | 1050 | | throw new ArgumentNullException(nameof(resourceId)); |
| | 1051 | | } |
| 0 | 1052 | | if (apiVersion == null) |
| | 1053 | | { |
| 0 | 1054 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1055 | | } |
| | 1056 | |
|
| 0 | 1057 | | using var message = CreateCheckExistenceByIdRequest(resourceId, apiVersion); |
| 0 | 1058 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1059 | | switch (message.Response.Status) |
| | 1060 | | { |
| | 1061 | | case 204: |
| | 1062 | | case 404: |
| 0 | 1063 | | return message.Response; |
| | 1064 | | default: |
| 0 | 1065 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1066 | | } |
| 0 | 1067 | | } |
| | 1068 | |
|
| | 1069 | | /// <summary> Checks by ID whether a resource exists. </summary> |
| | 1070 | | /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t |
| | 1071 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 1072 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1073 | | public Response CheckExistenceById(string resourceId, string apiVersion, CancellationToken cancellationToken = d |
| | 1074 | | { |
| 0 | 1075 | | if (resourceId == null) |
| | 1076 | | { |
| 0 | 1077 | | throw new ArgumentNullException(nameof(resourceId)); |
| | 1078 | | } |
| 0 | 1079 | | if (apiVersion == null) |
| | 1080 | | { |
| 0 | 1081 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1082 | | } |
| | 1083 | |
|
| 0 | 1084 | | using var message = CreateCheckExistenceByIdRequest(resourceId, apiVersion); |
| 0 | 1085 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1086 | | switch (message.Response.Status) |
| | 1087 | | { |
| | 1088 | | case 204: |
| | 1089 | | case 404: |
| 0 | 1090 | | return message.Response; |
| | 1091 | | default: |
| 0 | 1092 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1093 | | } |
| 0 | 1094 | | } |
| | 1095 | |
|
| | 1096 | | internal Core.HttpMessage CreateDeleteByIdRequest(string resourceId, string apiVersion) |
| | 1097 | | { |
| 16 | 1098 | | var message = _pipeline.CreateMessage(); |
| 16 | 1099 | | var request = message.Request; |
| 16 | 1100 | | request.Method = RequestMethod.Delete; |
| 16 | 1101 | | var uri = new RawRequestUriBuilder(); |
| 16 | 1102 | | uri.Reset(endpoint); |
| 16 | 1103 | | uri.AppendPath("/", false); |
| 16 | 1104 | | uri.AppendPath(resourceId, false); |
| 16 | 1105 | | uri.AppendQuery("api-version", apiVersion, true); |
| 16 | 1106 | | request.Uri = uri; |
| 16 | 1107 | | return message; |
| | 1108 | | } |
| | 1109 | |
|
| | 1110 | | /// <summary> Deletes a resource by ID. </summary> |
| | 1111 | | /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t |
| | 1112 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 1113 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1114 | | public async Task<Response> DeleteByIdAsync(string resourceId, string apiVersion, CancellationToken cancellation |
| | 1115 | | { |
| 4 | 1116 | | if (resourceId == null) |
| | 1117 | | { |
| 0 | 1118 | | throw new ArgumentNullException(nameof(resourceId)); |
| | 1119 | | } |
| 4 | 1120 | | if (apiVersion == null) |
| | 1121 | | { |
| 0 | 1122 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1123 | | } |
| | 1124 | |
|
| 4 | 1125 | | using var message = CreateDeleteByIdRequest(resourceId, apiVersion); |
| 4 | 1126 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 1127 | | switch (message.Response.Status) |
| | 1128 | | { |
| | 1129 | | case 200: |
| | 1130 | | case 202: |
| | 1131 | | case 204: |
| 4 | 1132 | | return message.Response; |
| | 1133 | | default: |
| 0 | 1134 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1135 | | } |
| 4 | 1136 | | } |
| | 1137 | |
|
| | 1138 | | /// <summary> Deletes a resource by ID. </summary> |
| | 1139 | | /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t |
| | 1140 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 1141 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1142 | | public Response DeleteById(string resourceId, string apiVersion, CancellationToken cancellationToken = default) |
| | 1143 | | { |
| 4 | 1144 | | if (resourceId == null) |
| | 1145 | | { |
| 0 | 1146 | | throw new ArgumentNullException(nameof(resourceId)); |
| | 1147 | | } |
| 4 | 1148 | | if (apiVersion == null) |
| | 1149 | | { |
| 0 | 1150 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1151 | | } |
| | 1152 | |
|
| 4 | 1153 | | using var message = CreateDeleteByIdRequest(resourceId, apiVersion); |
| 4 | 1154 | | _pipeline.Send(message, cancellationToken); |
| 4 | 1155 | | switch (message.Response.Status) |
| | 1156 | | { |
| | 1157 | | case 200: |
| | 1158 | | case 202: |
| | 1159 | | case 204: |
| 4 | 1160 | | return message.Response; |
| | 1161 | | default: |
| 0 | 1162 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1163 | | } |
| 4 | 1164 | | } |
| | 1165 | |
|
| | 1166 | | internal Core.HttpMessage CreateCreateOrUpdateByIdRequest(string resourceId, string apiVersion, GenericResource |
| | 1167 | | { |
| 16 | 1168 | | var message = _pipeline.CreateMessage(); |
| 16 | 1169 | | var request = message.Request; |
| 16 | 1170 | | request.Method = RequestMethod.Put; |
| 16 | 1171 | | var uri = new RawRequestUriBuilder(); |
| 16 | 1172 | | uri.Reset(endpoint); |
| 16 | 1173 | | uri.AppendPath("/", false); |
| 16 | 1174 | | uri.AppendPath(resourceId, false); |
| 16 | 1175 | | uri.AppendQuery("api-version", apiVersion, true); |
| 16 | 1176 | | request.Uri = uri; |
| 16 | 1177 | | request.Headers.Add("Content-Type", "application/json"); |
| 16 | 1178 | | var content = new Utf8JsonRequestContent(); |
| 16 | 1179 | | content.JsonWriter.WriteObjectValue(parameters); |
| 16 | 1180 | | request.Content = content; |
| 16 | 1181 | | return message; |
| | 1182 | | } |
| | 1183 | |
|
| | 1184 | | /// <summary> Create a resource by ID. </summary> |
| | 1185 | | /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t |
| | 1186 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 1187 | | /// <param name="parameters"> Create or update resource parameters. </param> |
| | 1188 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1189 | | public async Task<Response> CreateOrUpdateByIdAsync(string resourceId, string apiVersion, GenericResource parame |
| | 1190 | | { |
| 4 | 1191 | | if (resourceId == null) |
| | 1192 | | { |
| 0 | 1193 | | throw new ArgumentNullException(nameof(resourceId)); |
| | 1194 | | } |
| 4 | 1195 | | if (apiVersion == null) |
| | 1196 | | { |
| 0 | 1197 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1198 | | } |
| 4 | 1199 | | if (parameters == null) |
| | 1200 | | { |
| 0 | 1201 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1202 | | } |
| | 1203 | |
|
| 4 | 1204 | | using var message = CreateCreateOrUpdateByIdRequest(resourceId, apiVersion, parameters); |
| 4 | 1205 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 1206 | | switch (message.Response.Status) |
| | 1207 | | { |
| | 1208 | | case 200: |
| | 1209 | | case 201: |
| | 1210 | | case 202: |
| 4 | 1211 | | return message.Response; |
| | 1212 | | default: |
| 0 | 1213 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1214 | | } |
| 4 | 1215 | | } |
| | 1216 | |
|
| | 1217 | | /// <summary> Create a resource by ID. </summary> |
| | 1218 | | /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t |
| | 1219 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 1220 | | /// <param name="parameters"> Create or update resource parameters. </param> |
| | 1221 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1222 | | public Response CreateOrUpdateById(string resourceId, string apiVersion, GenericResource parameters, Cancellatio |
| | 1223 | | { |
| 4 | 1224 | | if (resourceId == null) |
| | 1225 | | { |
| 0 | 1226 | | throw new ArgumentNullException(nameof(resourceId)); |
| | 1227 | | } |
| 4 | 1228 | | if (apiVersion == null) |
| | 1229 | | { |
| 0 | 1230 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1231 | | } |
| 4 | 1232 | | if (parameters == null) |
| | 1233 | | { |
| 0 | 1234 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1235 | | } |
| | 1236 | |
|
| 4 | 1237 | | using var message = CreateCreateOrUpdateByIdRequest(resourceId, apiVersion, parameters); |
| 4 | 1238 | | _pipeline.Send(message, cancellationToken); |
| 4 | 1239 | | switch (message.Response.Status) |
| | 1240 | | { |
| | 1241 | | case 200: |
| | 1242 | | case 201: |
| | 1243 | | case 202: |
| 4 | 1244 | | return message.Response; |
| | 1245 | | default: |
| 0 | 1246 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1247 | | } |
| 4 | 1248 | | } |
| | 1249 | |
|
| | 1250 | | internal Core.HttpMessage CreateUpdateByIdRequest(string resourceId, string apiVersion, GenericResource paramete |
| | 1251 | | { |
| 0 | 1252 | | var message = _pipeline.CreateMessage(); |
| 0 | 1253 | | var request = message.Request; |
| 0 | 1254 | | request.Method = RequestMethod.Patch; |
| 0 | 1255 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1256 | | uri.Reset(endpoint); |
| 0 | 1257 | | uri.AppendPath("/", false); |
| 0 | 1258 | | uri.AppendPath(resourceId, false); |
| 0 | 1259 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 1260 | | request.Uri = uri; |
| 0 | 1261 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1262 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1263 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1264 | | request.Content = content; |
| 0 | 1265 | | return message; |
| | 1266 | | } |
| | 1267 | |
|
| | 1268 | | /// <summary> Updates a resource by ID. </summary> |
| | 1269 | | /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t |
| | 1270 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 1271 | | /// <param name="parameters"> Update resource parameters. </param> |
| | 1272 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1273 | | public async Task<Response> UpdateByIdAsync(string resourceId, string apiVersion, GenericResource parameters, Ca |
| | 1274 | | { |
| 0 | 1275 | | if (resourceId == null) |
| | 1276 | | { |
| 0 | 1277 | | throw new ArgumentNullException(nameof(resourceId)); |
| | 1278 | | } |
| 0 | 1279 | | if (apiVersion == null) |
| | 1280 | | { |
| 0 | 1281 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1282 | | } |
| 0 | 1283 | | if (parameters == null) |
| | 1284 | | { |
| 0 | 1285 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1286 | | } |
| | 1287 | |
|
| 0 | 1288 | | using var message = CreateUpdateByIdRequest(resourceId, apiVersion, parameters); |
| 0 | 1289 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1290 | | switch (message.Response.Status) |
| | 1291 | | { |
| | 1292 | | case 200: |
| | 1293 | | case 202: |
| 0 | 1294 | | return message.Response; |
| | 1295 | | default: |
| 0 | 1296 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1297 | | } |
| 0 | 1298 | | } |
| | 1299 | |
|
| | 1300 | | /// <summary> Updates a resource by ID. </summary> |
| | 1301 | | /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t |
| | 1302 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 1303 | | /// <param name="parameters"> Update resource parameters. </param> |
| | 1304 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1305 | | public Response UpdateById(string resourceId, string apiVersion, GenericResource parameters, CancellationToken c |
| | 1306 | | { |
| 0 | 1307 | | if (resourceId == null) |
| | 1308 | | { |
| 0 | 1309 | | throw new ArgumentNullException(nameof(resourceId)); |
| | 1310 | | } |
| 0 | 1311 | | if (apiVersion == null) |
| | 1312 | | { |
| 0 | 1313 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1314 | | } |
| 0 | 1315 | | if (parameters == null) |
| | 1316 | | { |
| 0 | 1317 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1318 | | } |
| | 1319 | |
|
| 0 | 1320 | | using var message = CreateUpdateByIdRequest(resourceId, apiVersion, parameters); |
| 0 | 1321 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1322 | | switch (message.Response.Status) |
| | 1323 | | { |
| | 1324 | | case 200: |
| | 1325 | | case 202: |
| 0 | 1326 | | return message.Response; |
| | 1327 | | default: |
| 0 | 1328 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1329 | | } |
| 0 | 1330 | | } |
| | 1331 | |
|
| | 1332 | | internal Core.HttpMessage CreateGetByIdRequest(string resourceId, string apiVersion) |
| | 1333 | | { |
| 4 | 1334 | | var message = _pipeline.CreateMessage(); |
| 4 | 1335 | | var request = message.Request; |
| 4 | 1336 | | request.Method = RequestMethod.Get; |
| 4 | 1337 | | var uri = new RawRequestUriBuilder(); |
| 4 | 1338 | | uri.Reset(endpoint); |
| 4 | 1339 | | uri.AppendPath("/", false); |
| 4 | 1340 | | uri.AppendPath(resourceId, false); |
| 4 | 1341 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 1342 | | request.Uri = uri; |
| 4 | 1343 | | return message; |
| | 1344 | | } |
| | 1345 | |
|
| | 1346 | | /// <summary> Gets a resource by ID. </summary> |
| | 1347 | | /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t |
| | 1348 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 1349 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1350 | | public async Task<Response<GenericResource>> GetByIdAsync(string resourceId, string apiVersion, CancellationToke |
| | 1351 | | { |
| 2 | 1352 | | if (resourceId == null) |
| | 1353 | | { |
| 0 | 1354 | | throw new ArgumentNullException(nameof(resourceId)); |
| | 1355 | | } |
| 2 | 1356 | | if (apiVersion == null) |
| | 1357 | | { |
| 0 | 1358 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1359 | | } |
| | 1360 | |
|
| 2 | 1361 | | using var message = CreateGetByIdRequest(resourceId, apiVersion); |
| 2 | 1362 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1363 | | switch (message.Response.Status) |
| | 1364 | | { |
| | 1365 | | case 200: |
| | 1366 | | { |
| 2 | 1367 | | GenericResource value = default; |
| 2 | 1368 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 1369 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1370 | | { |
| 0 | 1371 | | value = null; |
| | 1372 | | } |
| | 1373 | | else |
| | 1374 | | { |
| 2 | 1375 | | value = GenericResource.DeserializeGenericResource(document.RootElement); |
| | 1376 | | } |
| 2 | 1377 | | return Response.FromValue(value, message.Response); |
| | 1378 | | } |
| | 1379 | | default: |
| 0 | 1380 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1381 | | } |
| 2 | 1382 | | } |
| | 1383 | |
|
| | 1384 | | /// <summary> Gets a resource by ID. </summary> |
| | 1385 | | /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t |
| | 1386 | | /// <param name="apiVersion"> The API version to use for the operation. </param> |
| | 1387 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1388 | | public Response<GenericResource> GetById(string resourceId, string apiVersion, CancellationToken cancellationTok |
| | 1389 | | { |
| 2 | 1390 | | if (resourceId == null) |
| | 1391 | | { |
| 0 | 1392 | | throw new ArgumentNullException(nameof(resourceId)); |
| | 1393 | | } |
| 2 | 1394 | | if (apiVersion == null) |
| | 1395 | | { |
| 0 | 1396 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 1397 | | } |
| | 1398 | |
|
| 2 | 1399 | | using var message = CreateGetByIdRequest(resourceId, apiVersion); |
| 2 | 1400 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1401 | | switch (message.Response.Status) |
| | 1402 | | { |
| | 1403 | | case 200: |
| | 1404 | | { |
| 2 | 1405 | | GenericResource value = default; |
| 2 | 1406 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 1407 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1408 | | { |
| 0 | 1409 | | value = null; |
| | 1410 | | } |
| | 1411 | | else |
| | 1412 | | { |
| 2 | 1413 | | value = GenericResource.DeserializeGenericResource(document.RootElement); |
| | 1414 | | } |
| 2 | 1415 | | return Response.FromValue(value, message.Response); |
| | 1416 | | } |
| | 1417 | | default: |
| 0 | 1418 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1419 | | } |
| 2 | 1420 | | } |
| | 1421 | |
|
| | 1422 | | internal Core.HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName, st |
| | 1423 | | { |
| 0 | 1424 | | var message = _pipeline.CreateMessage(); |
| 0 | 1425 | | var request = message.Request; |
| 0 | 1426 | | request.Method = RequestMethod.Get; |
| 0 | 1427 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1428 | | uri.Reset(endpoint); |
| 0 | 1429 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 1430 | | request.Uri = uri; |
| 0 | 1431 | | return message; |
| | 1432 | | } |
| | 1433 | |
|
| | 1434 | | /// <summary> Get all the resources for a resource group. </summary> |
| | 1435 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1436 | | /// <param name="resourceGroupName"> The resource group with the resources to get. </param> |
| | 1437 | | /// <param name="filter"> The filter to apply on the operation.<br><br>The properties you can use fo |
| | 1438 | | /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va |
| | 1439 | | /// <param name="top"> The number of results to return. If null is passed, returns all resources. </param> |
| | 1440 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1441 | | public async Task<Response<ResourceListResult>> ListByResourceGroupNextPageAsync(string nextLink, string resourc |
| | 1442 | | { |
| 0 | 1443 | | if (nextLink == null) |
| | 1444 | | { |
| 0 | 1445 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1446 | | } |
| 0 | 1447 | | if (resourceGroupName == null) |
| | 1448 | | { |
| 0 | 1449 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1450 | | } |
| | 1451 | |
|
| 0 | 1452 | | using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName, filter, expand, to |
| 0 | 1453 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1454 | | switch (message.Response.Status) |
| | 1455 | | { |
| | 1456 | | case 200: |
| | 1457 | | { |
| 0 | 1458 | | ResourceListResult value = default; |
| 0 | 1459 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1460 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1461 | | { |
| 0 | 1462 | | value = null; |
| | 1463 | | } |
| | 1464 | | else |
| | 1465 | | { |
| 0 | 1466 | | value = ResourceListResult.DeserializeResourceListResult(document.RootElement); |
| | 1467 | | } |
| 0 | 1468 | | return Response.FromValue(value, message.Response); |
| | 1469 | | } |
| | 1470 | | default: |
| 0 | 1471 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1472 | | } |
| 0 | 1473 | | } |
| | 1474 | |
|
| | 1475 | | /// <summary> Get all the resources for a resource group. </summary> |
| | 1476 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1477 | | /// <param name="resourceGroupName"> The resource group with the resources to get. </param> |
| | 1478 | | /// <param name="filter"> The filter to apply on the operation.<br><br>The properties you can use fo |
| | 1479 | | /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va |
| | 1480 | | /// <param name="top"> The number of results to return. If null is passed, returns all resources. </param> |
| | 1481 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1482 | | public Response<ResourceListResult> ListByResourceGroupNextPage(string nextLink, string resourceGroupName, strin |
| | 1483 | | { |
| 0 | 1484 | | if (nextLink == null) |
| | 1485 | | { |
| 0 | 1486 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1487 | | } |
| 0 | 1488 | | if (resourceGroupName == null) |
| | 1489 | | { |
| 0 | 1490 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1491 | | } |
| | 1492 | |
|
| 0 | 1493 | | using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName, filter, expand, to |
| 0 | 1494 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1495 | | switch (message.Response.Status) |
| | 1496 | | { |
| | 1497 | | case 200: |
| | 1498 | | { |
| 0 | 1499 | | ResourceListResult value = default; |
| 0 | 1500 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1501 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1502 | | { |
| 0 | 1503 | | value = null; |
| | 1504 | | } |
| | 1505 | | else |
| | 1506 | | { |
| 0 | 1507 | | value = ResourceListResult.DeserializeResourceListResult(document.RootElement); |
| | 1508 | | } |
| 0 | 1509 | | return Response.FromValue(value, message.Response); |
| | 1510 | | } |
| | 1511 | | default: |
| 0 | 1512 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1513 | | } |
| 0 | 1514 | | } |
| | 1515 | |
|
| | 1516 | | internal Core.HttpMessage CreateListNextPageRequest(string nextLink, string filter, string expand, int? top) |
| | 1517 | | { |
| 0 | 1518 | | var message = _pipeline.CreateMessage(); |
| 0 | 1519 | | var request = message.Request; |
| 0 | 1520 | | request.Method = RequestMethod.Get; |
| 0 | 1521 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1522 | | uri.Reset(endpoint); |
| 0 | 1523 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 1524 | | request.Uri = uri; |
| 0 | 1525 | | return message; |
| | 1526 | | } |
| | 1527 | |
|
| | 1528 | | /// <summary> Get all the resources in a subscription. </summary> |
| | 1529 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1530 | | /// <param name="filter"> The filter to apply on the operation.<br><br>The properties you can use fo |
| | 1531 | | /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va |
| | 1532 | | /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param> |
| | 1533 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1534 | | public async Task<Response<ResourceListResult>> ListNextPageAsync(string nextLink, string filter = null, string |
| | 1535 | | { |
| 0 | 1536 | | if (nextLink == null) |
| | 1537 | | { |
| 0 | 1538 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1539 | | } |
| | 1540 | |
|
| 0 | 1541 | | using var message = CreateListNextPageRequest(nextLink, filter, expand, top); |
| 0 | 1542 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1543 | | switch (message.Response.Status) |
| | 1544 | | { |
| | 1545 | | case 200: |
| | 1546 | | { |
| 0 | 1547 | | ResourceListResult value = default; |
| 0 | 1548 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1549 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1550 | | { |
| 0 | 1551 | | value = null; |
| | 1552 | | } |
| | 1553 | | else |
| | 1554 | | { |
| 0 | 1555 | | value = ResourceListResult.DeserializeResourceListResult(document.RootElement); |
| | 1556 | | } |
| 0 | 1557 | | return Response.FromValue(value, message.Response); |
| | 1558 | | } |
| | 1559 | | default: |
| 0 | 1560 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1561 | | } |
| 0 | 1562 | | } |
| | 1563 | |
|
| | 1564 | | /// <summary> Get all the resources in a subscription. </summary> |
| | 1565 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1566 | | /// <param name="filter"> The filter to apply on the operation.<br><br>The properties you can use fo |
| | 1567 | | /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va |
| | 1568 | | /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param> |
| | 1569 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1570 | | public Response<ResourceListResult> ListNextPage(string nextLink, string filter = null, string expand = null, in |
| | 1571 | | { |
| 0 | 1572 | | if (nextLink == null) |
| | 1573 | | { |
| 0 | 1574 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1575 | | } |
| | 1576 | |
|
| 0 | 1577 | | using var message = CreateListNextPageRequest(nextLink, filter, expand, top); |
| 0 | 1578 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1579 | | switch (message.Response.Status) |
| | 1580 | | { |
| | 1581 | | case 200: |
| | 1582 | | { |
| 0 | 1583 | | ResourceListResult value = default; |
| 0 | 1584 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1585 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1586 | | { |
| 0 | 1587 | | value = null; |
| | 1588 | | } |
| | 1589 | | else |
| | 1590 | | { |
| 0 | 1591 | | value = ResourceListResult.DeserializeResourceListResult(document.RootElement); |
| | 1592 | | } |
| 0 | 1593 | | return Response.FromValue(value, message.Response); |
| | 1594 | | } |
| | 1595 | | default: |
| 0 | 1596 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1597 | | } |
| 0 | 1598 | | } |
| | 1599 | | } |
| | 1600 | | } |