| | 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 ResourceLinksRestOperations |
| | 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 ResourceLinksRestOperations. </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 |
| 28 | 32 | | public ResourceLinksRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscripti |
| | 33 | | { |
| 28 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 28 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 28 | 40 | | this.subscriptionId = subscriptionId; |
| 28 | 41 | | this.endpoint = endpoint; |
| 28 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 28 | 43 | | _pipeline = pipeline; |
| 28 | 44 | | } |
| | 45 | |
|
| | 46 | | internal Core.HttpMessage CreateDeleteRequest(string linkId) |
| | 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("/", false); |
| 4 | 54 | | uri.AppendPath(linkId, false); |
| 4 | 55 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 4 | 56 | | request.Uri = uri; |
| 4 | 57 | | return message; |
| | 58 | | } |
| | 59 | |
|
| | 60 | | /// <summary> Deletes a resource link with the specified ID. </summary> |
| | 61 | | /// <param name="linkId"> The fully qualified ID of the resource link. Use the format, /subscriptions/{subscript |
| | 62 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 63 | | public async Task<Response> DeleteAsync(string linkId, CancellationToken cancellationToken = default) |
| | 64 | | { |
| 2 | 65 | | if (linkId == null) |
| | 66 | | { |
| 0 | 67 | | throw new ArgumentNullException(nameof(linkId)); |
| | 68 | | } |
| | 69 | |
|
| 2 | 70 | | using var message = CreateDeleteRequest(linkId); |
| 2 | 71 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 72 | | switch (message.Response.Status) |
| | 73 | | { |
| | 74 | | case 200: |
| | 75 | | case 204: |
| 2 | 76 | | return message.Response; |
| | 77 | | default: |
| 0 | 78 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 79 | | } |
| 2 | 80 | | } |
| | 81 | |
|
| | 82 | | /// <summary> Deletes a resource link with the specified ID. </summary> |
| | 83 | | /// <param name="linkId"> The fully qualified ID of the resource link. Use the format, /subscriptions/{subscript |
| | 84 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 85 | | public Response Delete(string linkId, CancellationToken cancellationToken = default) |
| | 86 | | { |
| 2 | 87 | | if (linkId == null) |
| | 88 | | { |
| 0 | 89 | | throw new ArgumentNullException(nameof(linkId)); |
| | 90 | | } |
| | 91 | |
|
| 2 | 92 | | using var message = CreateDeleteRequest(linkId); |
| 2 | 93 | | _pipeline.Send(message, cancellationToken); |
| 2 | 94 | | switch (message.Response.Status) |
| | 95 | | { |
| | 96 | | case 200: |
| | 97 | | case 204: |
| 2 | 98 | | return message.Response; |
| | 99 | | default: |
| 0 | 100 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 101 | | } |
| 2 | 102 | | } |
| | 103 | |
|
| | 104 | | internal Core.HttpMessage CreateCreateOrUpdateRequest(string linkId, ResourceLink parameters) |
| | 105 | | { |
| 4 | 106 | | var message = _pipeline.CreateMessage(); |
| 4 | 107 | | var request = message.Request; |
| 4 | 108 | | request.Method = RequestMethod.Put; |
| 4 | 109 | | var uri = new RawRequestUriBuilder(); |
| 4 | 110 | | uri.Reset(endpoint); |
| 4 | 111 | | uri.AppendPath("/", false); |
| 4 | 112 | | uri.AppendPath(linkId, false); |
| 4 | 113 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 4 | 114 | | request.Uri = uri; |
| 4 | 115 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 116 | | var content = new Utf8JsonRequestContent(); |
| 4 | 117 | | content.JsonWriter.WriteObjectValue(parameters); |
| 4 | 118 | | request.Content = content; |
| 4 | 119 | | return message; |
| | 120 | | } |
| | 121 | |
|
| | 122 | | /// <summary> Creates or updates a resource link between the specified resources. </summary> |
| | 123 | | /// <param name="linkId"> The fully qualified ID of the resource link. Use the format, /subscriptions/{subscript |
| | 124 | | /// <param name="parameters"> Parameters for creating or updating a resource link. </param> |
| | 125 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 126 | | public async Task<Response<ResourceLink>> CreateOrUpdateAsync(string linkId, ResourceLink parameters, Cancellati |
| | 127 | | { |
| 2 | 128 | | if (linkId == null) |
| | 129 | | { |
| 0 | 130 | | throw new ArgumentNullException(nameof(linkId)); |
| | 131 | | } |
| 2 | 132 | | if (parameters == null) |
| | 133 | | { |
| 0 | 134 | | throw new ArgumentNullException(nameof(parameters)); |
| | 135 | | } |
| | 136 | |
|
| 2 | 137 | | using var message = CreateCreateOrUpdateRequest(linkId, parameters); |
| 2 | 138 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 139 | | switch (message.Response.Status) |
| | 140 | | { |
| | 141 | | case 200: |
| | 142 | | case 201: |
| | 143 | | { |
| 2 | 144 | | ResourceLink value = default; |
| 2 | 145 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 146 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 147 | | { |
| 0 | 148 | | value = null; |
| | 149 | | } |
| | 150 | | else |
| | 151 | | { |
| 2 | 152 | | value = ResourceLink.DeserializeResourceLink(document.RootElement); |
| | 153 | | } |
| 2 | 154 | | return Response.FromValue(value, message.Response); |
| | 155 | | } |
| | 156 | | default: |
| 0 | 157 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 158 | | } |
| 2 | 159 | | } |
| | 160 | |
|
| | 161 | | /// <summary> Creates or updates a resource link between the specified resources. </summary> |
| | 162 | | /// <param name="linkId"> The fully qualified ID of the resource link. Use the format, /subscriptions/{subscript |
| | 163 | | /// <param name="parameters"> Parameters for creating or updating a resource link. </param> |
| | 164 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 165 | | public Response<ResourceLink> CreateOrUpdate(string linkId, ResourceLink parameters, CancellationToken cancellat |
| | 166 | | { |
| 2 | 167 | | if (linkId == null) |
| | 168 | | { |
| 0 | 169 | | throw new ArgumentNullException(nameof(linkId)); |
| | 170 | | } |
| 2 | 171 | | if (parameters == null) |
| | 172 | | { |
| 0 | 173 | | throw new ArgumentNullException(nameof(parameters)); |
| | 174 | | } |
| | 175 | |
|
| 2 | 176 | | using var message = CreateCreateOrUpdateRequest(linkId, parameters); |
| 2 | 177 | | _pipeline.Send(message, cancellationToken); |
| 2 | 178 | | switch (message.Response.Status) |
| | 179 | | { |
| | 180 | | case 200: |
| | 181 | | case 201: |
| | 182 | | { |
| 2 | 183 | | ResourceLink value = default; |
| 2 | 184 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 185 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 186 | | { |
| 0 | 187 | | value = null; |
| | 188 | | } |
| | 189 | | else |
| | 190 | | { |
| 2 | 191 | | value = ResourceLink.DeserializeResourceLink(document.RootElement); |
| | 192 | | } |
| 2 | 193 | | return Response.FromValue(value, message.Response); |
| | 194 | | } |
| | 195 | | default: |
| 0 | 196 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 197 | | } |
| 2 | 198 | | } |
| | 199 | |
|
| | 200 | | internal Core.HttpMessage CreateGetRequest(string linkId) |
| | 201 | | { |
| 8 | 202 | | var message = _pipeline.CreateMessage(); |
| 8 | 203 | | var request = message.Request; |
| 8 | 204 | | request.Method = RequestMethod.Get; |
| 8 | 205 | | var uri = new RawRequestUriBuilder(); |
| 8 | 206 | | uri.Reset(endpoint); |
| 8 | 207 | | uri.AppendPath("/", false); |
| 8 | 208 | | uri.AppendPath(linkId, false); |
| 8 | 209 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 8 | 210 | | request.Uri = uri; |
| 8 | 211 | | return message; |
| | 212 | | } |
| | 213 | |
|
| | 214 | | /// <summary> Gets a resource link with the specified ID. </summary> |
| | 215 | | /// <param name="linkId"> The fully qualified Id of the resource link. For example, /subscriptions/00000000-0000 |
| | 216 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 217 | | public async Task<Response<ResourceLink>> GetAsync(string linkId, CancellationToken cancellationToken = default) |
| | 218 | | { |
| 4 | 219 | | if (linkId == null) |
| | 220 | | { |
| 0 | 221 | | throw new ArgumentNullException(nameof(linkId)); |
| | 222 | | } |
| | 223 | |
|
| 4 | 224 | | using var message = CreateGetRequest(linkId); |
| 4 | 225 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 226 | | switch (message.Response.Status) |
| | 227 | | { |
| | 228 | | case 200: |
| | 229 | | { |
| 2 | 230 | | ResourceLink value = default; |
| 2 | 231 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 232 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 233 | | { |
| 0 | 234 | | value = null; |
| | 235 | | } |
| | 236 | | else |
| | 237 | | { |
| 2 | 238 | | value = ResourceLink.DeserializeResourceLink(document.RootElement); |
| | 239 | | } |
| 2 | 240 | | return Response.FromValue(value, message.Response); |
| | 241 | | } |
| | 242 | | default: |
| 0 | 243 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 244 | | } |
| 2 | 245 | | } |
| | 246 | |
|
| | 247 | | /// <summary> Gets a resource link with the specified ID. </summary> |
| | 248 | | /// <param name="linkId"> The fully qualified Id of the resource link. For example, /subscriptions/00000000-0000 |
| | 249 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 250 | | public Response<ResourceLink> Get(string linkId, CancellationToken cancellationToken = default) |
| | 251 | | { |
| 4 | 252 | | if (linkId == null) |
| | 253 | | { |
| 0 | 254 | | throw new ArgumentNullException(nameof(linkId)); |
| | 255 | | } |
| | 256 | |
|
| 4 | 257 | | using var message = CreateGetRequest(linkId); |
| 4 | 258 | | _pipeline.Send(message, cancellationToken); |
| 2 | 259 | | switch (message.Response.Status) |
| | 260 | | { |
| | 261 | | case 200: |
| | 262 | | { |
| 2 | 263 | | ResourceLink value = default; |
| 2 | 264 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 265 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 266 | | { |
| 0 | 267 | | value = null; |
| | 268 | | } |
| | 269 | | else |
| | 270 | | { |
| 2 | 271 | | value = ResourceLink.DeserializeResourceLink(document.RootElement); |
| | 272 | | } |
| 2 | 273 | | return Response.FromValue(value, message.Response); |
| | 274 | | } |
| | 275 | | default: |
| 0 | 276 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 277 | | } |
| 2 | 278 | | } |
| | 279 | |
|
| | 280 | | internal Core.HttpMessage CreateListAtSubscriptionRequest(string filter) |
| | 281 | | { |
| 8 | 282 | | var message = _pipeline.CreateMessage(); |
| 8 | 283 | | var request = message.Request; |
| 8 | 284 | | request.Method = RequestMethod.Get; |
| 8 | 285 | | var uri = new RawRequestUriBuilder(); |
| 8 | 286 | | uri.Reset(endpoint); |
| 8 | 287 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 288 | | uri.AppendPath(subscriptionId, true); |
| 8 | 289 | | uri.AppendPath("/providers/Microsoft.Resources/links", false); |
| 8 | 290 | | if (filter != null) |
| | 291 | | { |
| 4 | 292 | | uri.AppendQuery("$filter", filter, true); |
| | 293 | | } |
| 8 | 294 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 8 | 295 | | request.Uri = uri; |
| 8 | 296 | | return message; |
| | 297 | | } |
| | 298 | |
|
| | 299 | | /// <summary> Gets all the linked resources for the subscription. </summary> |
| | 300 | | /// <param name="filter"> The filter to apply on the list resource links operation. The supported filter for lis |
| | 301 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 302 | | public async Task<Response<ResourceLinkResult>> ListAtSubscriptionAsync(string filter = null, CancellationToken |
| | 303 | | { |
| 4 | 304 | | using var message = CreateListAtSubscriptionRequest(filter); |
| 4 | 305 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 306 | | switch (message.Response.Status) |
| | 307 | | { |
| | 308 | | case 200: |
| | 309 | | { |
| 4 | 310 | | ResourceLinkResult value = default; |
| 4 | 311 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 312 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 313 | | { |
| 0 | 314 | | value = null; |
| | 315 | | } |
| | 316 | | else |
| | 317 | | { |
| 4 | 318 | | value = ResourceLinkResult.DeserializeResourceLinkResult(document.RootElement); |
| | 319 | | } |
| 4 | 320 | | return Response.FromValue(value, message.Response); |
| | 321 | | } |
| | 322 | | default: |
| 0 | 323 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 324 | | } |
| 4 | 325 | | } |
| | 326 | |
|
| | 327 | | /// <summary> Gets all the linked resources for the subscription. </summary> |
| | 328 | | /// <param name="filter"> The filter to apply on the list resource links operation. The supported filter for lis |
| | 329 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 330 | | public Response<ResourceLinkResult> ListAtSubscription(string filter = null, CancellationToken cancellationToken |
| | 331 | | { |
| 4 | 332 | | using var message = CreateListAtSubscriptionRequest(filter); |
| 4 | 333 | | _pipeline.Send(message, cancellationToken); |
| 4 | 334 | | switch (message.Response.Status) |
| | 335 | | { |
| | 336 | | case 200: |
| | 337 | | { |
| 4 | 338 | | ResourceLinkResult value = default; |
| 4 | 339 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 340 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 341 | | { |
| 0 | 342 | | value = null; |
| | 343 | | } |
| | 344 | | else |
| | 345 | | { |
| 4 | 346 | | value = ResourceLinkResult.DeserializeResourceLinkResult(document.RootElement); |
| | 347 | | } |
| 4 | 348 | | return Response.FromValue(value, message.Response); |
| | 349 | | } |
| | 350 | | default: |
| 0 | 351 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 352 | | } |
| 4 | 353 | | } |
| | 354 | |
|
| | 355 | | internal Core.HttpMessage CreateListAtSourceScopeRequest(string scope) |
| | 356 | | { |
| 4 | 357 | | var message = _pipeline.CreateMessage(); |
| 4 | 358 | | var request = message.Request; |
| 4 | 359 | | request.Method = RequestMethod.Get; |
| 4 | 360 | | var uri = new RawRequestUriBuilder(); |
| 4 | 361 | | uri.Reset(endpoint); |
| 4 | 362 | | uri.AppendPath("/", false); |
| 4 | 363 | | uri.AppendPath(scope, false); |
| 4 | 364 | | uri.AppendPath("/providers/Microsoft.Resources/links", false); |
| 4 | 365 | | uri.AppendQuery("$filter", "atScope()", true); |
| 4 | 366 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 4 | 367 | | request.Uri = uri; |
| 4 | 368 | | return message; |
| | 369 | | } |
| | 370 | |
|
| | 371 | | /// <summary> Gets a list of resource links at and below the specified source scope. </summary> |
| | 372 | | /// <param name="scope"> The fully qualified ID of the scope for getting the resource links. For example, to lis |
| | 373 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 374 | | public async Task<Response<ResourceLinkResult>> ListAtSourceScopeAsync(string scope, CancellationToken cancellat |
| | 375 | | { |
| 2 | 376 | | if (scope == null) |
| | 377 | | { |
| 0 | 378 | | throw new ArgumentNullException(nameof(scope)); |
| | 379 | | } |
| | 380 | |
|
| 2 | 381 | | using var message = CreateListAtSourceScopeRequest(scope); |
| 2 | 382 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 383 | | switch (message.Response.Status) |
| | 384 | | { |
| | 385 | | case 200: |
| | 386 | | { |
| 2 | 387 | | ResourceLinkResult value = default; |
| 2 | 388 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 389 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 390 | | { |
| 0 | 391 | | value = null; |
| | 392 | | } |
| | 393 | | else |
| | 394 | | { |
| 2 | 395 | | value = ResourceLinkResult.DeserializeResourceLinkResult(document.RootElement); |
| | 396 | | } |
| 2 | 397 | | return Response.FromValue(value, message.Response); |
| | 398 | | } |
| | 399 | | default: |
| 0 | 400 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 401 | | } |
| 2 | 402 | | } |
| | 403 | |
|
| | 404 | | /// <summary> Gets a list of resource links at and below the specified source scope. </summary> |
| | 405 | | /// <param name="scope"> The fully qualified ID of the scope for getting the resource links. For example, to lis |
| | 406 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 407 | | public Response<ResourceLinkResult> ListAtSourceScope(string scope, CancellationToken cancellationToken = defaul |
| | 408 | | { |
| 2 | 409 | | if (scope == null) |
| | 410 | | { |
| 0 | 411 | | throw new ArgumentNullException(nameof(scope)); |
| | 412 | | } |
| | 413 | |
|
| 2 | 414 | | using var message = CreateListAtSourceScopeRequest(scope); |
| 2 | 415 | | _pipeline.Send(message, cancellationToken); |
| 2 | 416 | | switch (message.Response.Status) |
| | 417 | | { |
| | 418 | | case 200: |
| | 419 | | { |
| 2 | 420 | | ResourceLinkResult value = default; |
| 2 | 421 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 422 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 423 | | { |
| 0 | 424 | | value = null; |
| | 425 | | } |
| | 426 | | else |
| | 427 | | { |
| 2 | 428 | | value = ResourceLinkResult.DeserializeResourceLinkResult(document.RootElement); |
| | 429 | | } |
| 2 | 430 | | return Response.FromValue(value, message.Response); |
| | 431 | | } |
| | 432 | | default: |
| 0 | 433 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 434 | | } |
| 2 | 435 | | } |
| | 436 | |
|
| | 437 | | internal Core.HttpMessage CreateListAtSubscriptionNextPageRequest(string nextLink, string filter) |
| | 438 | | { |
| 0 | 439 | | var message = _pipeline.CreateMessage(); |
| 0 | 440 | | var request = message.Request; |
| 0 | 441 | | request.Method = RequestMethod.Get; |
| 0 | 442 | | var uri = new RawRequestUriBuilder(); |
| 0 | 443 | | uri.Reset(endpoint); |
| 0 | 444 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 445 | | request.Uri = uri; |
| 0 | 446 | | return message; |
| | 447 | | } |
| | 448 | |
|
| | 449 | | /// <summary> Gets all the linked resources for the subscription. </summary> |
| | 450 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 451 | | /// <param name="filter"> The filter to apply on the list resource links operation. The supported filter for lis |
| | 452 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 453 | | public async Task<Response<ResourceLinkResult>> ListAtSubscriptionNextPageAsync(string nextLink, string filter = |
| | 454 | | { |
| 0 | 455 | | if (nextLink == null) |
| | 456 | | { |
| 0 | 457 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 458 | | } |
| | 459 | |
|
| 0 | 460 | | using var message = CreateListAtSubscriptionNextPageRequest(nextLink, filter); |
| 0 | 461 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 462 | | switch (message.Response.Status) |
| | 463 | | { |
| | 464 | | case 200: |
| | 465 | | { |
| 0 | 466 | | ResourceLinkResult value = default; |
| 0 | 467 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 468 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 469 | | { |
| 0 | 470 | | value = null; |
| | 471 | | } |
| | 472 | | else |
| | 473 | | { |
| 0 | 474 | | value = ResourceLinkResult.DeserializeResourceLinkResult(document.RootElement); |
| | 475 | | } |
| 0 | 476 | | return Response.FromValue(value, message.Response); |
| | 477 | | } |
| | 478 | | default: |
| 0 | 479 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 480 | | } |
| 0 | 481 | | } |
| | 482 | |
|
| | 483 | | /// <summary> Gets all the linked resources for the subscription. </summary> |
| | 484 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 485 | | /// <param name="filter"> The filter to apply on the list resource links operation. The supported filter for lis |
| | 486 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 487 | | public Response<ResourceLinkResult> ListAtSubscriptionNextPage(string nextLink, string filter = null, Cancellati |
| | 488 | | { |
| 0 | 489 | | if (nextLink == null) |
| | 490 | | { |
| 0 | 491 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 492 | | } |
| | 493 | |
|
| 0 | 494 | | using var message = CreateListAtSubscriptionNextPageRequest(nextLink, filter); |
| 0 | 495 | | _pipeline.Send(message, cancellationToken); |
| 0 | 496 | | switch (message.Response.Status) |
| | 497 | | { |
| | 498 | | case 200: |
| | 499 | | { |
| 0 | 500 | | ResourceLinkResult value = default; |
| 0 | 501 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 502 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 503 | | { |
| 0 | 504 | | value = null; |
| | 505 | | } |
| | 506 | | else |
| | 507 | | { |
| 0 | 508 | | value = ResourceLinkResult.DeserializeResourceLinkResult(document.RootElement); |
| | 509 | | } |
| 0 | 510 | | return Response.FromValue(value, message.Response); |
| | 511 | | } |
| | 512 | | default: |
| 0 | 513 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 514 | | } |
| 0 | 515 | | } |
| | 516 | |
|
| | 517 | | internal Core.HttpMessage CreateListAtSourceScopeNextPageRequest(string nextLink, string scope) |
| | 518 | | { |
| 0 | 519 | | var message = _pipeline.CreateMessage(); |
| 0 | 520 | | var request = message.Request; |
| 0 | 521 | | request.Method = RequestMethod.Get; |
| 0 | 522 | | var uri = new RawRequestUriBuilder(); |
| 0 | 523 | | uri.Reset(endpoint); |
| 0 | 524 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 525 | | request.Uri = uri; |
| 0 | 526 | | return message; |
| | 527 | | } |
| | 528 | |
|
| | 529 | | /// <summary> Gets a list of resource links at and below the specified source scope. </summary> |
| | 530 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 531 | | /// <param name="scope"> The fully qualified ID of the scope for getting the resource links. For example, to lis |
| | 532 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 533 | | public async Task<Response<ResourceLinkResult>> ListAtSourceScopeNextPageAsync(string nextLink, string scope, Ca |
| | 534 | | { |
| 0 | 535 | | if (nextLink == null) |
| | 536 | | { |
| 0 | 537 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 538 | | } |
| 0 | 539 | | if (scope == null) |
| | 540 | | { |
| 0 | 541 | | throw new ArgumentNullException(nameof(scope)); |
| | 542 | | } |
| | 543 | |
|
| 0 | 544 | | using var message = CreateListAtSourceScopeNextPageRequest(nextLink, scope); |
| 0 | 545 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 546 | | switch (message.Response.Status) |
| | 547 | | { |
| | 548 | | case 200: |
| | 549 | | { |
| 0 | 550 | | ResourceLinkResult value = default; |
| 0 | 551 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 552 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 553 | | { |
| 0 | 554 | | value = null; |
| | 555 | | } |
| | 556 | | else |
| | 557 | | { |
| 0 | 558 | | value = ResourceLinkResult.DeserializeResourceLinkResult(document.RootElement); |
| | 559 | | } |
| 0 | 560 | | return Response.FromValue(value, message.Response); |
| | 561 | | } |
| | 562 | | default: |
| 0 | 563 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 564 | | } |
| 0 | 565 | | } |
| | 566 | |
|
| | 567 | | /// <summary> Gets a list of resource links at and below the specified source scope. </summary> |
| | 568 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 569 | | /// <param name="scope"> The fully qualified ID of the scope for getting the resource links. For example, to lis |
| | 570 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 571 | | public Response<ResourceLinkResult> ListAtSourceScopeNextPage(string nextLink, string scope, CancellationToken c |
| | 572 | | { |
| 0 | 573 | | if (nextLink == null) |
| | 574 | | { |
| 0 | 575 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 576 | | } |
| 0 | 577 | | if (scope == null) |
| | 578 | | { |
| 0 | 579 | | throw new ArgumentNullException(nameof(scope)); |
| | 580 | | } |
| | 581 | |
|
| 0 | 582 | | using var message = CreateListAtSourceScopeNextPageRequest(nextLink, scope); |
| 0 | 583 | | _pipeline.Send(message, cancellationToken); |
| 0 | 584 | | switch (message.Response.Status) |
| | 585 | | { |
| | 586 | | case 200: |
| | 587 | | { |
| 0 | 588 | | ResourceLinkResult value = default; |
| 0 | 589 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 590 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 591 | | { |
| 0 | 592 | | value = null; |
| | 593 | | } |
| | 594 | | else |
| | 595 | | { |
| 0 | 596 | | value = ResourceLinkResult.DeserializeResourceLinkResult(document.RootElement); |
| | 597 | | } |
| 0 | 598 | | return Response.FromValue(value, message.Response); |
| | 599 | | } |
| | 600 | | default: |
| 0 | 601 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 602 | | } |
| 0 | 603 | | } |
| | 604 | | } |
| | 605 | | } |