| | 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 TagsRestOperations |
| | 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 TagsRestOperations. </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 |
| 256 | 32 | | public TagsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri |
| | 33 | | { |
| 256 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 256 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 256 | 40 | | this.subscriptionId = subscriptionId; |
| 256 | 41 | | this.endpoint = endpoint; |
| 256 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 256 | 43 | | _pipeline = pipeline; |
| 256 | 44 | | } |
| | 45 | |
|
| | 46 | | internal Core.HttpMessage CreateDeleteValueRequest(string tagName, string tagValue) |
| | 47 | | { |
| 4 | 48 | | var message = _pipeline.CreateMessage(); |
| 4 | 49 | | var request = message.Request; |
| 4 | 50 | | request.Method = RequestMethod.Delete; |
| 4 | 51 | | var uri = new RawRequestUriBuilder(); |
| 4 | 52 | | uri.Reset(endpoint); |
| 4 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 54 | | uri.AppendPath(subscriptionId, true); |
| 4 | 55 | | uri.AppendPath("/tagNames/", false); |
| 4 | 56 | | uri.AppendPath(tagName, true); |
| 4 | 57 | | uri.AppendPath("/tagValues/", false); |
| 4 | 58 | | uri.AppendPath(tagValue, true); |
| 4 | 59 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 4 | 60 | | request.Uri = uri; |
| 4 | 61 | | return message; |
| | 62 | | } |
| | 63 | |
|
| | 64 | | /// <summary> This operation allows deleting a value from the list of predefined values for an existing predefin |
| | 65 | | /// <param name="tagName"> The name of the tag. </param> |
| | 66 | | /// <param name="tagValue"> The value of the tag to delete. </param> |
| | 67 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 68 | | public async Task<Response> DeleteValueAsync(string tagName, string tagValue, CancellationToken cancellationToke |
| | 69 | | { |
| 2 | 70 | | if (tagName == null) |
| | 71 | | { |
| 0 | 72 | | throw new ArgumentNullException(nameof(tagName)); |
| | 73 | | } |
| 2 | 74 | | if (tagValue == null) |
| | 75 | | { |
| 0 | 76 | | throw new ArgumentNullException(nameof(tagValue)); |
| | 77 | | } |
| | 78 | |
|
| 2 | 79 | | using var message = CreateDeleteValueRequest(tagName, tagValue); |
| 2 | 80 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 81 | | switch (message.Response.Status) |
| | 82 | | { |
| | 83 | | case 200: |
| | 84 | | case 204: |
| 2 | 85 | | return message.Response; |
| | 86 | | default: |
| 0 | 87 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 88 | | } |
| 2 | 89 | | } |
| | 90 | |
|
| | 91 | | /// <summary> This operation allows deleting a value from the list of predefined values for an existing predefin |
| | 92 | | /// <param name="tagName"> The name of the tag. </param> |
| | 93 | | /// <param name="tagValue"> The value of the tag to delete. </param> |
| | 94 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 95 | | public Response DeleteValue(string tagName, string tagValue, CancellationToken cancellationToken = default) |
| | 96 | | { |
| 2 | 97 | | if (tagName == null) |
| | 98 | | { |
| 0 | 99 | | throw new ArgumentNullException(nameof(tagName)); |
| | 100 | | } |
| 2 | 101 | | if (tagValue == null) |
| | 102 | | { |
| 0 | 103 | | throw new ArgumentNullException(nameof(tagValue)); |
| | 104 | | } |
| | 105 | |
|
| 2 | 106 | | using var message = CreateDeleteValueRequest(tagName, tagValue); |
| 2 | 107 | | _pipeline.Send(message, cancellationToken); |
| 2 | 108 | | switch (message.Response.Status) |
| | 109 | | { |
| | 110 | | case 200: |
| | 111 | | case 204: |
| 2 | 112 | | return message.Response; |
| | 113 | | default: |
| 0 | 114 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 115 | | } |
| 2 | 116 | | } |
| | 117 | |
|
| | 118 | | internal Core.HttpMessage CreateCreateOrUpdateValueRequest(string tagName, string tagValue) |
| | 119 | | { |
| 8 | 120 | | var message = _pipeline.CreateMessage(); |
| 8 | 121 | | var request = message.Request; |
| 8 | 122 | | request.Method = RequestMethod.Put; |
| 8 | 123 | | var uri = new RawRequestUriBuilder(); |
| 8 | 124 | | uri.Reset(endpoint); |
| 8 | 125 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 126 | | uri.AppendPath(subscriptionId, true); |
| 8 | 127 | | uri.AppendPath("/tagNames/", false); |
| 8 | 128 | | uri.AppendPath(tagName, true); |
| 8 | 129 | | uri.AppendPath("/tagValues/", false); |
| 8 | 130 | | uri.AppendPath(tagValue, true); |
| 8 | 131 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 8 | 132 | | request.Uri = uri; |
| 8 | 133 | | return message; |
| | 134 | | } |
| | 135 | |
|
| | 136 | | /// <summary> This operation allows adding a value to the list of predefined values for an existing predefined t |
| | 137 | | /// <param name="tagName"> The name of the tag. </param> |
| | 138 | | /// <param name="tagValue"> The value of the tag to create. </param> |
| | 139 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 140 | | public async Task<Response<TagValue>> CreateOrUpdateValueAsync(string tagName, string tagValue, CancellationToke |
| | 141 | | { |
| 4 | 142 | | if (tagName == null) |
| | 143 | | { |
| 0 | 144 | | throw new ArgumentNullException(nameof(tagName)); |
| | 145 | | } |
| 4 | 146 | | if (tagValue == null) |
| | 147 | | { |
| 0 | 148 | | throw new ArgumentNullException(nameof(tagValue)); |
| | 149 | | } |
| | 150 | |
|
| 4 | 151 | | using var message = CreateCreateOrUpdateValueRequest(tagName, tagValue); |
| 4 | 152 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 153 | | switch (message.Response.Status) |
| | 154 | | { |
| | 155 | | case 200: |
| | 156 | | case 201: |
| | 157 | | { |
| 2 | 158 | | TagValue value = default; |
| 2 | 159 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 160 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 161 | | { |
| 0 | 162 | | value = null; |
| | 163 | | } |
| | 164 | | else |
| | 165 | | { |
| 2 | 166 | | value = TagValue.DeserializeTagValue(document.RootElement); |
| | 167 | | } |
| 2 | 168 | | return Response.FromValue(value, message.Response); |
| | 169 | | } |
| | 170 | | default: |
| 2 | 171 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 172 | | } |
| 2 | 173 | | } |
| | 174 | |
|
| | 175 | | /// <summary> This operation allows adding a value to the list of predefined values for an existing predefined t |
| | 176 | | /// <param name="tagName"> The name of the tag. </param> |
| | 177 | | /// <param name="tagValue"> The value of the tag to create. </param> |
| | 178 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 179 | | public Response<TagValue> CreateOrUpdateValue(string tagName, string tagValue, CancellationToken cancellationTok |
| | 180 | | { |
| 4 | 181 | | if (tagName == null) |
| | 182 | | { |
| 0 | 183 | | throw new ArgumentNullException(nameof(tagName)); |
| | 184 | | } |
| 4 | 185 | | if (tagValue == null) |
| | 186 | | { |
| 0 | 187 | | throw new ArgumentNullException(nameof(tagValue)); |
| | 188 | | } |
| | 189 | |
|
| 4 | 190 | | using var message = CreateCreateOrUpdateValueRequest(tagName, tagValue); |
| 4 | 191 | | _pipeline.Send(message, cancellationToken); |
| 4 | 192 | | switch (message.Response.Status) |
| | 193 | | { |
| | 194 | | case 200: |
| | 195 | | case 201: |
| | 196 | | { |
| 2 | 197 | | TagValue value = default; |
| 2 | 198 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 199 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 200 | | { |
| 0 | 201 | | value = null; |
| | 202 | | } |
| | 203 | | else |
| | 204 | | { |
| 2 | 205 | | value = TagValue.DeserializeTagValue(document.RootElement); |
| | 206 | | } |
| 2 | 207 | | return Response.FromValue(value, message.Response); |
| | 208 | | } |
| | 209 | | default: |
| 2 | 210 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 211 | | } |
| 2 | 212 | | } |
| | 213 | |
|
| | 214 | | internal Core.HttpMessage CreateCreateOrUpdateRequest(string tagName) |
| | 215 | | { |
| 8 | 216 | | var message = _pipeline.CreateMessage(); |
| 8 | 217 | | var request = message.Request; |
| 8 | 218 | | request.Method = RequestMethod.Put; |
| 8 | 219 | | var uri = new RawRequestUriBuilder(); |
| 8 | 220 | | uri.Reset(endpoint); |
| 8 | 221 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 222 | | uri.AppendPath(subscriptionId, true); |
| 8 | 223 | | uri.AppendPath("/tagNames/", false); |
| 8 | 224 | | uri.AppendPath(tagName, true); |
| 8 | 225 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 8 | 226 | | request.Uri = uri; |
| 8 | 227 | | return message; |
| | 228 | | } |
| | 229 | |
|
| | 230 | | /// <summary> This operation allows adding a name to the list of predefined tag names for the given subscription |
| | 231 | | /// <param name="tagName"> The name of the tag to create. </param> |
| | 232 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 233 | | public async Task<Response<TagDetails>> CreateOrUpdateAsync(string tagName, CancellationToken cancellationToken |
| | 234 | | { |
| 4 | 235 | | if (tagName == null) |
| | 236 | | { |
| 0 | 237 | | throw new ArgumentNullException(nameof(tagName)); |
| | 238 | | } |
| | 239 | |
|
| 4 | 240 | | using var message = CreateCreateOrUpdateRequest(tagName); |
| 4 | 241 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 242 | | switch (message.Response.Status) |
| | 243 | | { |
| | 244 | | case 200: |
| | 245 | | case 201: |
| | 246 | | { |
| 4 | 247 | | TagDetails value = default; |
| 4 | 248 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 249 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 250 | | { |
| 0 | 251 | | value = null; |
| | 252 | | } |
| | 253 | | else |
| | 254 | | { |
| 4 | 255 | | value = TagDetails.DeserializeTagDetails(document.RootElement); |
| | 256 | | } |
| 4 | 257 | | return Response.FromValue(value, message.Response); |
| | 258 | | } |
| | 259 | | default: |
| 0 | 260 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 261 | | } |
| 4 | 262 | | } |
| | 263 | |
|
| | 264 | | /// <summary> This operation allows adding a name to the list of predefined tag names for the given subscription |
| | 265 | | /// <param name="tagName"> The name of the tag to create. </param> |
| | 266 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 267 | | public Response<TagDetails> CreateOrUpdate(string tagName, CancellationToken cancellationToken = default) |
| | 268 | | { |
| 4 | 269 | | if (tagName == null) |
| | 270 | | { |
| 0 | 271 | | throw new ArgumentNullException(nameof(tagName)); |
| | 272 | | } |
| | 273 | |
|
| 4 | 274 | | using var message = CreateCreateOrUpdateRequest(tagName); |
| 4 | 275 | | _pipeline.Send(message, cancellationToken); |
| 4 | 276 | | switch (message.Response.Status) |
| | 277 | | { |
| | 278 | | case 200: |
| | 279 | | case 201: |
| | 280 | | { |
| 4 | 281 | | TagDetails value = default; |
| 4 | 282 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 283 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 284 | | { |
| 0 | 285 | | value = null; |
| | 286 | | } |
| | 287 | | else |
| | 288 | | { |
| 4 | 289 | | value = TagDetails.DeserializeTagDetails(document.RootElement); |
| | 290 | | } |
| 4 | 291 | | return Response.FromValue(value, message.Response); |
| | 292 | | } |
| | 293 | | default: |
| 0 | 294 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 295 | | } |
| 4 | 296 | | } |
| | 297 | |
|
| | 298 | | internal Core.HttpMessage CreateDeleteRequest(string tagName) |
| | 299 | | { |
| 8 | 300 | | var message = _pipeline.CreateMessage(); |
| 8 | 301 | | var request = message.Request; |
| 8 | 302 | | request.Method = RequestMethod.Delete; |
| 8 | 303 | | var uri = new RawRequestUriBuilder(); |
| 8 | 304 | | uri.Reset(endpoint); |
| 8 | 305 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 306 | | uri.AppendPath(subscriptionId, true); |
| 8 | 307 | | uri.AppendPath("/tagNames/", false); |
| 8 | 308 | | uri.AppendPath(tagName, true); |
| 8 | 309 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 8 | 310 | | request.Uri = uri; |
| 8 | 311 | | return message; |
| | 312 | | } |
| | 313 | |
|
| | 314 | | /// <summary> This operation allows deleting a name from the list of predefined tag names for the given subscrip |
| | 315 | | /// <param name="tagName"> The name of the tag. </param> |
| | 316 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 317 | | public async Task<Response> DeleteAsync(string tagName, CancellationToken cancellationToken = default) |
| | 318 | | { |
| 4 | 319 | | if (tagName == null) |
| | 320 | | { |
| 0 | 321 | | throw new ArgumentNullException(nameof(tagName)); |
| | 322 | | } |
| | 323 | |
|
| 4 | 324 | | using var message = CreateDeleteRequest(tagName); |
| 4 | 325 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 326 | | switch (message.Response.Status) |
| | 327 | | { |
| | 328 | | case 200: |
| | 329 | | case 204: |
| 4 | 330 | | return message.Response; |
| | 331 | | default: |
| 0 | 332 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 333 | | } |
| 4 | 334 | | } |
| | 335 | |
|
| | 336 | | /// <summary> This operation allows deleting a name from the list of predefined tag names for the given subscrip |
| | 337 | | /// <param name="tagName"> The name of the tag. </param> |
| | 338 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 339 | | public Response Delete(string tagName, CancellationToken cancellationToken = default) |
| | 340 | | { |
| 4 | 341 | | if (tagName == null) |
| | 342 | | { |
| 0 | 343 | | throw new ArgumentNullException(nameof(tagName)); |
| | 344 | | } |
| | 345 | |
|
| 4 | 346 | | using var message = CreateDeleteRequest(tagName); |
| 4 | 347 | | _pipeline.Send(message, cancellationToken); |
| 4 | 348 | | switch (message.Response.Status) |
| | 349 | | { |
| | 350 | | case 200: |
| | 351 | | case 204: |
| 4 | 352 | | return message.Response; |
| | 353 | | default: |
| 0 | 354 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 355 | | } |
| 4 | 356 | | } |
| | 357 | |
|
| | 358 | | internal Core.HttpMessage CreateListRequest() |
| | 359 | | { |
| 8 | 360 | | var message = _pipeline.CreateMessage(); |
| 8 | 361 | | var request = message.Request; |
| 8 | 362 | | request.Method = RequestMethod.Get; |
| 8 | 363 | | var uri = new RawRequestUriBuilder(); |
| 8 | 364 | | uri.Reset(endpoint); |
| 8 | 365 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 366 | | uri.AppendPath(subscriptionId, true); |
| 8 | 367 | | uri.AppendPath("/tagNames", false); |
| 8 | 368 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 8 | 369 | | request.Uri = uri; |
| 8 | 370 | | return message; |
| | 371 | | } |
| | 372 | |
|
| | 373 | | /// <summary> This operation performs a union of predefined tags, resource tags, resource group tags and subscri |
| | 374 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 375 | | public async Task<Response<TagsListResult>> ListAsync(CancellationToken cancellationToken = default) |
| | 376 | | { |
| 4 | 377 | | using var message = CreateListRequest(); |
| 4 | 378 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 379 | | switch (message.Response.Status) |
| | 380 | | { |
| | 381 | | case 200: |
| | 382 | | { |
| 4 | 383 | | TagsListResult value = default; |
| 4 | 384 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 385 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 386 | | { |
| 0 | 387 | | value = null; |
| | 388 | | } |
| | 389 | | else |
| | 390 | | { |
| 4 | 391 | | value = TagsListResult.DeserializeTagsListResult(document.RootElement); |
| | 392 | | } |
| 4 | 393 | | return Response.FromValue(value, message.Response); |
| | 394 | | } |
| | 395 | | default: |
| 0 | 396 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 397 | | } |
| 4 | 398 | | } |
| | 399 | |
|
| | 400 | | /// <summary> This operation performs a union of predefined tags, resource tags, resource group tags and subscri |
| | 401 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 402 | | public Response<TagsListResult> List(CancellationToken cancellationToken = default) |
| | 403 | | { |
| 4 | 404 | | using var message = CreateListRequest(); |
| 4 | 405 | | _pipeline.Send(message, cancellationToken); |
| 4 | 406 | | switch (message.Response.Status) |
| | 407 | | { |
| | 408 | | case 200: |
| | 409 | | { |
| 4 | 410 | | TagsListResult value = default; |
| 4 | 411 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 412 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 413 | | { |
| 0 | 414 | | value = null; |
| | 415 | | } |
| | 416 | | else |
| | 417 | | { |
| 4 | 418 | | value = TagsListResult.DeserializeTagsListResult(document.RootElement); |
| | 419 | | } |
| 4 | 420 | | return Response.FromValue(value, message.Response); |
| | 421 | | } |
| | 422 | | default: |
| 0 | 423 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 424 | | } |
| 4 | 425 | | } |
| | 426 | |
|
| | 427 | | internal Core.HttpMessage CreateCreateOrUpdateAtScopeRequest(string scope, TagsResource parameters) |
| | 428 | | { |
| 32 | 429 | | var message = _pipeline.CreateMessage(); |
| 32 | 430 | | var request = message.Request; |
| 32 | 431 | | request.Method = RequestMethod.Put; |
| 32 | 432 | | var uri = new RawRequestUriBuilder(); |
| 32 | 433 | | uri.Reset(endpoint); |
| 32 | 434 | | uri.AppendPath("/", false); |
| 32 | 435 | | uri.AppendPath(scope, false); |
| 32 | 436 | | uri.AppendPath("/providers/Microsoft.Resources/tags/default", false); |
| 32 | 437 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 32 | 438 | | request.Uri = uri; |
| 32 | 439 | | request.Headers.Add("Content-Type", "application/json"); |
| 32 | 440 | | var content = new Utf8JsonRequestContent(); |
| 32 | 441 | | content.JsonWriter.WriteObjectValue(parameters); |
| 32 | 442 | | request.Content = content; |
| 32 | 443 | | return message; |
| | 444 | | } |
| | 445 | |
|
| | 446 | | /// <summary> This operation allows adding or replacing the entire set of tags on the specified resource or subs |
| | 447 | | /// <param name="scope"> The resource scope. </param> |
| | 448 | | /// <param name="parameters"> The TagsResource to use. </param> |
| | 449 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 450 | | public async Task<Response<TagsResource>> CreateOrUpdateAtScopeAsync(string scope, TagsResource parameters, Canc |
| | 451 | | { |
| 16 | 452 | | if (scope == null) |
| | 453 | | { |
| 0 | 454 | | throw new ArgumentNullException(nameof(scope)); |
| | 455 | | } |
| 16 | 456 | | if (parameters == null) |
| | 457 | | { |
| 0 | 458 | | throw new ArgumentNullException(nameof(parameters)); |
| | 459 | | } |
| | 460 | |
|
| 16 | 461 | | using var message = CreateCreateOrUpdateAtScopeRequest(scope, parameters); |
| 16 | 462 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 16 | 463 | | switch (message.Response.Status) |
| | 464 | | { |
| | 465 | | case 200: |
| | 466 | | { |
| 16 | 467 | | TagsResource value = default; |
| 16 | 468 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 16 | 469 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 470 | | { |
| 0 | 471 | | value = null; |
| | 472 | | } |
| | 473 | | else |
| | 474 | | { |
| 16 | 475 | | value = TagsResource.DeserializeTagsResource(document.RootElement); |
| | 476 | | } |
| 16 | 477 | | return Response.FromValue(value, message.Response); |
| | 478 | | } |
| | 479 | | default: |
| 0 | 480 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 481 | | } |
| 16 | 482 | | } |
| | 483 | |
|
| | 484 | | /// <summary> This operation allows adding or replacing the entire set of tags on the specified resource or subs |
| | 485 | | /// <param name="scope"> The resource scope. </param> |
| | 486 | | /// <param name="parameters"> The TagsResource to use. </param> |
| | 487 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 488 | | public Response<TagsResource> CreateOrUpdateAtScope(string scope, TagsResource parameters, CancellationToken can |
| | 489 | | { |
| 16 | 490 | | if (scope == null) |
| | 491 | | { |
| 0 | 492 | | throw new ArgumentNullException(nameof(scope)); |
| | 493 | | } |
| 16 | 494 | | if (parameters == null) |
| | 495 | | { |
| 0 | 496 | | throw new ArgumentNullException(nameof(parameters)); |
| | 497 | | } |
| | 498 | |
|
| 16 | 499 | | using var message = CreateCreateOrUpdateAtScopeRequest(scope, parameters); |
| 16 | 500 | | _pipeline.Send(message, cancellationToken); |
| 16 | 501 | | switch (message.Response.Status) |
| | 502 | | { |
| | 503 | | case 200: |
| | 504 | | { |
| 16 | 505 | | TagsResource value = default; |
| 16 | 506 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 16 | 507 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 508 | | { |
| 0 | 509 | | value = null; |
| | 510 | | } |
| | 511 | | else |
| | 512 | | { |
| 16 | 513 | | value = TagsResource.DeserializeTagsResource(document.RootElement); |
| | 514 | | } |
| 16 | 515 | | return Response.FromValue(value, message.Response); |
| | 516 | | } |
| | 517 | | default: |
| 0 | 518 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 519 | | } |
| 16 | 520 | | } |
| | 521 | |
|
| | 522 | | internal Core.HttpMessage CreateUpdateAtScopeRequest(string scope, TagsPatchResource parameters) |
| | 523 | | { |
| 24 | 524 | | var message = _pipeline.CreateMessage(); |
| 24 | 525 | | var request = message.Request; |
| 24 | 526 | | request.Method = RequestMethod.Patch; |
| 24 | 527 | | var uri = new RawRequestUriBuilder(); |
| 24 | 528 | | uri.Reset(endpoint); |
| 24 | 529 | | uri.AppendPath("/", false); |
| 24 | 530 | | uri.AppendPath(scope, false); |
| 24 | 531 | | uri.AppendPath("/providers/Microsoft.Resources/tags/default", false); |
| 24 | 532 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 24 | 533 | | request.Uri = uri; |
| 24 | 534 | | request.Headers.Add("Content-Type", "application/json"); |
| 24 | 535 | | var content = new Utf8JsonRequestContent(); |
| 24 | 536 | | content.JsonWriter.WriteObjectValue(parameters); |
| 24 | 537 | | request.Content = content; |
| 24 | 538 | | return message; |
| | 539 | | } |
| | 540 | |
|
| | 541 | | /// <summary> This operation allows replacing, merging or selectively deleting tags on the specified resource or |
| | 542 | | /// <param name="scope"> The resource scope. </param> |
| | 543 | | /// <param name="parameters"> The TagsPatchResource to use. </param> |
| | 544 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 545 | | public async Task<Response<TagsResource>> UpdateAtScopeAsync(string scope, TagsPatchResource parameters, Cancell |
| | 546 | | { |
| 12 | 547 | | if (scope == null) |
| | 548 | | { |
| 0 | 549 | | throw new ArgumentNullException(nameof(scope)); |
| | 550 | | } |
| 12 | 551 | | if (parameters == null) |
| | 552 | | { |
| 0 | 553 | | throw new ArgumentNullException(nameof(parameters)); |
| | 554 | | } |
| | 555 | |
|
| 12 | 556 | | using var message = CreateUpdateAtScopeRequest(scope, parameters); |
| 12 | 557 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 12 | 558 | | switch (message.Response.Status) |
| | 559 | | { |
| | 560 | | case 200: |
| | 561 | | { |
| 12 | 562 | | TagsResource value = default; |
| 12 | 563 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 12 | 564 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 565 | | { |
| 0 | 566 | | value = null; |
| | 567 | | } |
| | 568 | | else |
| | 569 | | { |
| 12 | 570 | | value = TagsResource.DeserializeTagsResource(document.RootElement); |
| | 571 | | } |
| 12 | 572 | | return Response.FromValue(value, message.Response); |
| | 573 | | } |
| | 574 | | default: |
| 0 | 575 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 576 | | } |
| 12 | 577 | | } |
| | 578 | |
|
| | 579 | | /// <summary> This operation allows replacing, merging or selectively deleting tags on the specified resource or |
| | 580 | | /// <param name="scope"> The resource scope. </param> |
| | 581 | | /// <param name="parameters"> The TagsPatchResource to use. </param> |
| | 582 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 583 | | public Response<TagsResource> UpdateAtScope(string scope, TagsPatchResource parameters, CancellationToken cancel |
| | 584 | | { |
| 12 | 585 | | if (scope == null) |
| | 586 | | { |
| 0 | 587 | | throw new ArgumentNullException(nameof(scope)); |
| | 588 | | } |
| 12 | 589 | | if (parameters == null) |
| | 590 | | { |
| 0 | 591 | | throw new ArgumentNullException(nameof(parameters)); |
| | 592 | | } |
| | 593 | |
|
| 12 | 594 | | using var message = CreateUpdateAtScopeRequest(scope, parameters); |
| 12 | 595 | | _pipeline.Send(message, cancellationToken); |
| 12 | 596 | | switch (message.Response.Status) |
| | 597 | | { |
| | 598 | | case 200: |
| | 599 | | { |
| 12 | 600 | | TagsResource value = default; |
| 12 | 601 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 12 | 602 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 603 | | { |
| 0 | 604 | | value = null; |
| | 605 | | } |
| | 606 | | else |
| | 607 | | { |
| 12 | 608 | | value = TagsResource.DeserializeTagsResource(document.RootElement); |
| | 609 | | } |
| 12 | 610 | | return Response.FromValue(value, message.Response); |
| | 611 | | } |
| | 612 | | default: |
| 0 | 613 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 614 | | } |
| 12 | 615 | | } |
| | 616 | |
|
| | 617 | | internal Core.HttpMessage CreateGetAtScopeRequest(string scope) |
| | 618 | | { |
| 16 | 619 | | var message = _pipeline.CreateMessage(); |
| 16 | 620 | | var request = message.Request; |
| 16 | 621 | | request.Method = RequestMethod.Get; |
| 16 | 622 | | var uri = new RawRequestUriBuilder(); |
| 16 | 623 | | uri.Reset(endpoint); |
| 16 | 624 | | uri.AppendPath("/", false); |
| 16 | 625 | | uri.AppendPath(scope, false); |
| 16 | 626 | | uri.AppendPath("/providers/Microsoft.Resources/tags/default", false); |
| 16 | 627 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 16 | 628 | | request.Uri = uri; |
| 16 | 629 | | return message; |
| | 630 | | } |
| | 631 | |
|
| | 632 | | /// <summary> Gets the entire set of tags on a resource or subscription. </summary> |
| | 633 | | /// <param name="scope"> The resource scope. </param> |
| | 634 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 635 | | public async Task<Response<TagsResource>> GetAtScopeAsync(string scope, CancellationToken cancellationToken = de |
| | 636 | | { |
| 8 | 637 | | if (scope == null) |
| | 638 | | { |
| 0 | 639 | | throw new ArgumentNullException(nameof(scope)); |
| | 640 | | } |
| | 641 | |
|
| 8 | 642 | | using var message = CreateGetAtScopeRequest(scope); |
| 8 | 643 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 8 | 644 | | switch (message.Response.Status) |
| | 645 | | { |
| | 646 | | case 200: |
| | 647 | | { |
| 8 | 648 | | TagsResource value = default; |
| 8 | 649 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 8 | 650 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 651 | | { |
| 0 | 652 | | value = null; |
| | 653 | | } |
| | 654 | | else |
| | 655 | | { |
| 8 | 656 | | value = TagsResource.DeserializeTagsResource(document.RootElement); |
| | 657 | | } |
| 8 | 658 | | return Response.FromValue(value, message.Response); |
| | 659 | | } |
| | 660 | | default: |
| 0 | 661 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 662 | | } |
| 8 | 663 | | } |
| | 664 | |
|
| | 665 | | /// <summary> Gets the entire set of tags on a resource or subscription. </summary> |
| | 666 | | /// <param name="scope"> The resource scope. </param> |
| | 667 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 668 | | public Response<TagsResource> GetAtScope(string scope, CancellationToken cancellationToken = default) |
| | 669 | | { |
| 8 | 670 | | if (scope == null) |
| | 671 | | { |
| 0 | 672 | | throw new ArgumentNullException(nameof(scope)); |
| | 673 | | } |
| | 674 | |
|
| 8 | 675 | | using var message = CreateGetAtScopeRequest(scope); |
| 8 | 676 | | _pipeline.Send(message, cancellationToken); |
| 8 | 677 | | switch (message.Response.Status) |
| | 678 | | { |
| | 679 | | case 200: |
| | 680 | | { |
| 8 | 681 | | TagsResource value = default; |
| 8 | 682 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 8 | 683 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 684 | | { |
| 0 | 685 | | value = null; |
| | 686 | | } |
| | 687 | | else |
| | 688 | | { |
| 8 | 689 | | value = TagsResource.DeserializeTagsResource(document.RootElement); |
| | 690 | | } |
| 8 | 691 | | return Response.FromValue(value, message.Response); |
| | 692 | | } |
| | 693 | | default: |
| 0 | 694 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 695 | | } |
| 8 | 696 | | } |
| | 697 | |
|
| | 698 | | internal Core.HttpMessage CreateDeleteAtScopeRequest(string scope) |
| | 699 | | { |
| 8 | 700 | | var message = _pipeline.CreateMessage(); |
| 8 | 701 | | var request = message.Request; |
| 8 | 702 | | request.Method = RequestMethod.Delete; |
| 8 | 703 | | var uri = new RawRequestUriBuilder(); |
| 8 | 704 | | uri.Reset(endpoint); |
| 8 | 705 | | uri.AppendPath("/", false); |
| 8 | 706 | | uri.AppendPath(scope, false); |
| 8 | 707 | | uri.AppendPath("/providers/Microsoft.Resources/tags/default", false); |
| 8 | 708 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 8 | 709 | | request.Uri = uri; |
| 8 | 710 | | return message; |
| | 711 | | } |
| | 712 | |
|
| | 713 | | /// <summary> Deletes the entire set of tags on a resource or subscription. </summary> |
| | 714 | | /// <param name="scope"> The resource scope. </param> |
| | 715 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 716 | | public async Task<Response> DeleteAtScopeAsync(string scope, CancellationToken cancellationToken = default) |
| | 717 | | { |
| 4 | 718 | | if (scope == null) |
| | 719 | | { |
| 0 | 720 | | throw new ArgumentNullException(nameof(scope)); |
| | 721 | | } |
| | 722 | |
|
| 4 | 723 | | using var message = CreateDeleteAtScopeRequest(scope); |
| 4 | 724 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 725 | | switch (message.Response.Status) |
| | 726 | | { |
| | 727 | | case 200: |
| 4 | 728 | | return message.Response; |
| | 729 | | default: |
| 0 | 730 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 731 | | } |
| 4 | 732 | | } |
| | 733 | |
|
| | 734 | | /// <summary> Deletes the entire set of tags on a resource or subscription. </summary> |
| | 735 | | /// <param name="scope"> The resource scope. </param> |
| | 736 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 737 | | public Response DeleteAtScope(string scope, CancellationToken cancellationToken = default) |
| | 738 | | { |
| 4 | 739 | | if (scope == null) |
| | 740 | | { |
| 0 | 741 | | throw new ArgumentNullException(nameof(scope)); |
| | 742 | | } |
| | 743 | |
|
| 4 | 744 | | using var message = CreateDeleteAtScopeRequest(scope); |
| 4 | 745 | | _pipeline.Send(message, cancellationToken); |
| 4 | 746 | | switch (message.Response.Status) |
| | 747 | | { |
| | 748 | | case 200: |
| 4 | 749 | | return message.Response; |
| | 750 | | default: |
| 0 | 751 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 752 | | } |
| 4 | 753 | | } |
| | 754 | |
|
| | 755 | | internal Core.HttpMessage CreateListNextPageRequest(string nextLink) |
| | 756 | | { |
| 0 | 757 | | var message = _pipeline.CreateMessage(); |
| 0 | 758 | | var request = message.Request; |
| 0 | 759 | | request.Method = RequestMethod.Get; |
| 0 | 760 | | var uri = new RawRequestUriBuilder(); |
| 0 | 761 | | uri.Reset(endpoint); |
| 0 | 762 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 763 | | request.Uri = uri; |
| 0 | 764 | | return message; |
| | 765 | | } |
| | 766 | |
|
| | 767 | | /// <summary> This operation performs a union of predefined tags, resource tags, resource group tags and subscri |
| | 768 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 769 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 770 | | public async Task<Response<TagsListResult>> ListNextPageAsync(string nextLink, CancellationToken cancellationTok |
| | 771 | | { |
| 0 | 772 | | if (nextLink == null) |
| | 773 | | { |
| 0 | 774 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 775 | | } |
| | 776 | |
|
| 0 | 777 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 778 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 779 | | switch (message.Response.Status) |
| | 780 | | { |
| | 781 | | case 200: |
| | 782 | | { |
| 0 | 783 | | TagsListResult value = default; |
| 0 | 784 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 785 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 786 | | { |
| 0 | 787 | | value = null; |
| | 788 | | } |
| | 789 | | else |
| | 790 | | { |
| 0 | 791 | | value = TagsListResult.DeserializeTagsListResult(document.RootElement); |
| | 792 | | } |
| 0 | 793 | | return Response.FromValue(value, message.Response); |
| | 794 | | } |
| | 795 | | default: |
| 0 | 796 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 797 | | } |
| 0 | 798 | | } |
| | 799 | |
|
| | 800 | | /// <summary> This operation performs a union of predefined tags, resource tags, resource group tags and subscri |
| | 801 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 802 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 803 | | public Response<TagsListResult> ListNextPage(string nextLink, CancellationToken cancellationToken = default) |
| | 804 | | { |
| 0 | 805 | | if (nextLink == null) |
| | 806 | | { |
| 0 | 807 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 808 | | } |
| | 809 | |
|
| 0 | 810 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 811 | | _pipeline.Send(message, cancellationToken); |
| 0 | 812 | | switch (message.Response.Status) |
| | 813 | | { |
| | 814 | | case 200: |
| | 815 | | { |
| 0 | 816 | | TagsListResult value = default; |
| 0 | 817 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 818 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 819 | | { |
| 0 | 820 | | value = null; |
| | 821 | | } |
| | 822 | | else |
| | 823 | | { |
| 0 | 824 | | value = TagsListResult.DeserializeTagsListResult(document.RootElement); |
| | 825 | | } |
| 0 | 826 | | return Response.FromValue(value, message.Response); |
| | 827 | | } |
| | 828 | | default: |
| 0 | 829 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 830 | | } |
| 0 | 831 | | } |
| | 832 | | } |
| | 833 | | } |