< Summary

Class:Azure.ResourceManager.Compute.SnapshotsRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\SnapshotsRestOperations.cs
Covered lines:268
Uncovered lines:125
Coverable lines:393
Total lines:864
Line coverage:68.1% (268 of 393)
Covered branches:78
Total branches:164
Branch coverage:47.5% (78 of 164)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-66.67%60%
CreateOrUpdate(...)-66.67%60%
CreateUpdateRequest(...)-100%100%
UpdateAsync()-66.67%60%
Update(...)-66.67%60%
CreateGetRequest(...)-100%100%
GetAsync()-80%62.5%
Get(...)-80%62.5%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-70%50%
Delete(...)-70%50%
CreateListByResourceGroupRequest(...)-100%100%
ListByResourceGroupAsync()-76.92%50%
ListByResourceGroup(...)-76.92%50%
CreateListRequest()-100%100%
ListAsync()-81.82%50%
List(...)-81.82%50%
CreateGrantAccessRequest(...)-100%100%
GrantAccessAsync()-66.67%60%
GrantAccess(...)-66.67%60%
CreateRevokeAccessRequest(...)-100%100%
RevokeAccessAsync()-70%62.5%
RevokeAccess(...)-70%62.5%
CreateListByResourceGroupNextPageRequest(...)-0%100%
ListByResourceGroupNextPageAsync()-0%0%
ListByResourceGroupNextPage(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\SnapshotsRestOperations.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Text.Json;
 10using System.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Core;
 14using Azure.Core.Pipeline;
 15using Azure.ResourceManager.Compute.Models;
 16
 17namespace Azure.ResourceManager.Compute
 18{
 19    internal partial class SnapshotsRestOperations
 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 SnapshotsRestOperations. </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"> Subscription credentials which uniquely identify Microsoft Azure subscription.
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 39632        public SnapshotsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId
 33        {
 39634            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 39638            endpoint ??= new Uri("https://management.azure.com");
 39
 39640            this.subscriptionId = subscriptionId;
 39641            this.endpoint = endpoint;
 39642            _clientDiagnostics = clientDiagnostics;
 39643            _pipeline = pipeline;
 39644        }
 45
 46        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string snapshotName, Snapshot snapsho
 47        {
 4848            var message = _pipeline.CreateMessage();
 4849            var request = message.Request;
 4850            request.Method = RequestMethod.Put;
 4851            var uri = new RawRequestUriBuilder();
 4852            uri.Reset(endpoint);
 4853            uri.AppendPath("/subscriptions/", false);
 4854            uri.AppendPath(subscriptionId, true);
 4855            uri.AppendPath("/resourceGroups/", false);
 4856            uri.AppendPath(resourceGroupName, true);
 4857            uri.AppendPath("/providers/Microsoft.Compute/snapshots/", false);
 4858            uri.AppendPath(snapshotName, true);
 4859            uri.AppendQuery("api-version", "2019-11-01", true);
 4860            request.Uri = uri;
 4861            request.Headers.Add("Content-Type", "application/json");
 4862            var content = new Utf8JsonRequestContent();
 4863            content.JsonWriter.WriteObjectValue(snapshot);
 4864            request.Content = content;
 4865            return message;
 66        }
 67
 68        /// <summary> Creates or updates a snapshot. </summary>
 69        /// <param name="resourceGroupName"> The name of the resource group. </param>
 70        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 71        /// <param name="snapshot"> Snapshot object supplied in the body of the Put disk operation. </param>
 72        /// <param name="cancellationToken"> The cancellation token to use. </param>
 73        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string snapshotName, Snapshot snapshot
 74        {
 1275            if (resourceGroupName == null)
 76            {
 077                throw new ArgumentNullException(nameof(resourceGroupName));
 78            }
 1279            if (snapshotName == null)
 80            {
 081                throw new ArgumentNullException(nameof(snapshotName));
 82            }
 1283            if (snapshot == null)
 84            {
 085                throw new ArgumentNullException(nameof(snapshot));
 86            }
 87
 1288            using var message = CreateCreateOrUpdateRequest(resourceGroupName, snapshotName, snapshot);
 1289            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 1290            switch (message.Response.Status)
 91            {
 92                case 200:
 93                case 202:
 1294                    return message.Response;
 95                default:
 096                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 97            }
 1298        }
 99
 100        /// <summary> Creates or updates a snapshot. </summary>
 101        /// <param name="resourceGroupName"> The name of the resource group. </param>
 102        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 103        /// <param name="snapshot"> Snapshot object supplied in the body of the Put disk operation. </param>
 104        /// <param name="cancellationToken"> The cancellation token to use. </param>
 105        public Response CreateOrUpdate(string resourceGroupName, string snapshotName, Snapshot snapshot, CancellationTok
 106        {
 12107            if (resourceGroupName == null)
 108            {
 0109                throw new ArgumentNullException(nameof(resourceGroupName));
 110            }
 12111            if (snapshotName == null)
 112            {
 0113                throw new ArgumentNullException(nameof(snapshotName));
 114            }
 12115            if (snapshot == null)
 116            {
 0117                throw new ArgumentNullException(nameof(snapshot));
 118            }
 119
 12120            using var message = CreateCreateOrUpdateRequest(resourceGroupName, snapshotName, snapshot);
 12121            _pipeline.Send(message, cancellationToken);
 12122            switch (message.Response.Status)
 123            {
 124                case 200:
 125                case 202:
 12126                    return message.Response;
 127                default:
 0128                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 129            }
 12130        }
 131
 132        internal HttpMessage CreateUpdateRequest(string resourceGroupName, string snapshotName, SnapshotUpdate snapshot)
 133        {
 16134            var message = _pipeline.CreateMessage();
 16135            var request = message.Request;
 16136            request.Method = RequestMethod.Patch;
 16137            var uri = new RawRequestUriBuilder();
 16138            uri.Reset(endpoint);
 16139            uri.AppendPath("/subscriptions/", false);
 16140            uri.AppendPath(subscriptionId, true);
 16141            uri.AppendPath("/resourceGroups/", false);
 16142            uri.AppendPath(resourceGroupName, true);
 16143            uri.AppendPath("/providers/Microsoft.Compute/snapshots/", false);
 16144            uri.AppendPath(snapshotName, true);
 16145            uri.AppendQuery("api-version", "2019-11-01", true);
 16146            request.Uri = uri;
 16147            request.Headers.Add("Content-Type", "application/json");
 16148            var content = new Utf8JsonRequestContent();
 16149            content.JsonWriter.WriteObjectValue(snapshot);
 16150            request.Content = content;
 16151            return message;
 152        }
 153
 154        /// <summary> Updates (patches) a snapshot. </summary>
 155        /// <param name="resourceGroupName"> The name of the resource group. </param>
 156        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 157        /// <param name="snapshot"> Snapshot object supplied in the body of the Patch snapshot operation. </param>
 158        /// <param name="cancellationToken"> The cancellation token to use. </param>
 159        public async Task<Response> UpdateAsync(string resourceGroupName, string snapshotName, SnapshotUpdate snapshot, 
 160        {
 4161            if (resourceGroupName == null)
 162            {
 0163                throw new ArgumentNullException(nameof(resourceGroupName));
 164            }
 4165            if (snapshotName == null)
 166            {
 0167                throw new ArgumentNullException(nameof(snapshotName));
 168            }
 4169            if (snapshot == null)
 170            {
 0171                throw new ArgumentNullException(nameof(snapshot));
 172            }
 173
 4174            using var message = CreateUpdateRequest(resourceGroupName, snapshotName, snapshot);
 4175            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4176            switch (message.Response.Status)
 177            {
 178                case 200:
 179                case 202:
 4180                    return message.Response;
 181                default:
 0182                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 183            }
 4184        }
 185
 186        /// <summary> Updates (patches) a snapshot. </summary>
 187        /// <param name="resourceGroupName"> The name of the resource group. </param>
 188        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 189        /// <param name="snapshot"> Snapshot object supplied in the body of the Patch snapshot operation. </param>
 190        /// <param name="cancellationToken"> The cancellation token to use. </param>
 191        public Response Update(string resourceGroupName, string snapshotName, SnapshotUpdate snapshot, CancellationToken
 192        {
 4193            if (resourceGroupName == null)
 194            {
 0195                throw new ArgumentNullException(nameof(resourceGroupName));
 196            }
 4197            if (snapshotName == null)
 198            {
 0199                throw new ArgumentNullException(nameof(snapshotName));
 200            }
 4201            if (snapshot == null)
 202            {
 0203                throw new ArgumentNullException(nameof(snapshot));
 204            }
 205
 4206            using var message = CreateUpdateRequest(resourceGroupName, snapshotName, snapshot);
 4207            _pipeline.Send(message, cancellationToken);
 4208            switch (message.Response.Status)
 209            {
 210                case 200:
 211                case 202:
 4212                    return message.Response;
 213                default:
 0214                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 215            }
 4216        }
 217
 218        internal HttpMessage CreateGetRequest(string resourceGroupName, string snapshotName)
 219        {
 32220            var message = _pipeline.CreateMessage();
 32221            var request = message.Request;
 32222            request.Method = RequestMethod.Get;
 32223            var uri = new RawRequestUriBuilder();
 32224            uri.Reset(endpoint);
 32225            uri.AppendPath("/subscriptions/", false);
 32226            uri.AppendPath(subscriptionId, true);
 32227            uri.AppendPath("/resourceGroups/", false);
 32228            uri.AppendPath(resourceGroupName, true);
 32229            uri.AppendPath("/providers/Microsoft.Compute/snapshots/", false);
 32230            uri.AppendPath(snapshotName, true);
 32231            uri.AppendQuery("api-version", "2019-11-01", true);
 32232            request.Uri = uri;
 32233            return message;
 234        }
 235
 236        /// <summary> Gets information about a snapshot. </summary>
 237        /// <param name="resourceGroupName"> The name of the resource group. </param>
 238        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 239        /// <param name="cancellationToken"> The cancellation token to use. </param>
 240        public async Task<Response<Snapshot>> GetAsync(string resourceGroupName, string snapshotName, CancellationToken 
 241        {
 16242            if (resourceGroupName == null)
 243            {
 0244                throw new ArgumentNullException(nameof(resourceGroupName));
 245            }
 16246            if (snapshotName == null)
 247            {
 0248                throw new ArgumentNullException(nameof(snapshotName));
 249            }
 250
 16251            using var message = CreateGetRequest(resourceGroupName, snapshotName);
 16252            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 16253            switch (message.Response.Status)
 254            {
 255                case 200:
 256                    {
 12257                        Snapshot value = default;
 12258                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 12259                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 260                        {
 0261                            value = null;
 262                        }
 263                        else
 264                        {
 12265                            value = Snapshot.DeserializeSnapshot(document.RootElement);
 266                        }
 12267                        return Response.FromValue(value, message.Response);
 268                    }
 269                default:
 4270                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 271            }
 12272        }
 273
 274        /// <summary> Gets information about a snapshot. </summary>
 275        /// <param name="resourceGroupName"> The name of the resource group. </param>
 276        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 277        /// <param name="cancellationToken"> The cancellation token to use. </param>
 278        public Response<Snapshot> Get(string resourceGroupName, string snapshotName, CancellationToken cancellationToken
 279        {
 16280            if (resourceGroupName == null)
 281            {
 0282                throw new ArgumentNullException(nameof(resourceGroupName));
 283            }
 16284            if (snapshotName == null)
 285            {
 0286                throw new ArgumentNullException(nameof(snapshotName));
 287            }
 288
 16289            using var message = CreateGetRequest(resourceGroupName, snapshotName);
 16290            _pipeline.Send(message, cancellationToken);
 16291            switch (message.Response.Status)
 292            {
 293                case 200:
 294                    {
 12295                        Snapshot value = default;
 12296                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 12297                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 298                        {
 0299                            value = null;
 300                        }
 301                        else
 302                        {
 12303                            value = Snapshot.DeserializeSnapshot(document.RootElement);
 304                        }
 12305                        return Response.FromValue(value, message.Response);
 306                    }
 307                default:
 4308                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 309            }
 12310        }
 311
 312        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string snapshotName)
 313        {
 16314            var message = _pipeline.CreateMessage();
 16315            var request = message.Request;
 16316            request.Method = RequestMethod.Delete;
 16317            var uri = new RawRequestUriBuilder();
 16318            uri.Reset(endpoint);
 16319            uri.AppendPath("/subscriptions/", false);
 16320            uri.AppendPath(subscriptionId, true);
 16321            uri.AppendPath("/resourceGroups/", false);
 16322            uri.AppendPath(resourceGroupName, true);
 16323            uri.AppendPath("/providers/Microsoft.Compute/snapshots/", false);
 16324            uri.AppendPath(snapshotName, true);
 16325            uri.AppendQuery("api-version", "2019-11-01", true);
 16326            request.Uri = uri;
 16327            return message;
 328        }
 329
 330        /// <summary> Deletes a snapshot. </summary>
 331        /// <param name="resourceGroupName"> The name of the resource group. </param>
 332        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 333        /// <param name="cancellationToken"> The cancellation token to use. </param>
 334        public async Task<Response> DeleteAsync(string resourceGroupName, string snapshotName, CancellationToken cancell
 335        {
 4336            if (resourceGroupName == null)
 337            {
 0338                throw new ArgumentNullException(nameof(resourceGroupName));
 339            }
 4340            if (snapshotName == null)
 341            {
 0342                throw new ArgumentNullException(nameof(snapshotName));
 343            }
 344
 4345            using var message = CreateDeleteRequest(resourceGroupName, snapshotName);
 4346            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4347            switch (message.Response.Status)
 348            {
 349                case 200:
 350                case 202:
 351                case 204:
 4352                    return message.Response;
 353                default:
 0354                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 355            }
 4356        }
 357
 358        /// <summary> Deletes a snapshot. </summary>
 359        /// <param name="resourceGroupName"> The name of the resource group. </param>
 360        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 361        /// <param name="cancellationToken"> The cancellation token to use. </param>
 362        public Response Delete(string resourceGroupName, string snapshotName, CancellationToken cancellationToken = defa
 363        {
 4364            if (resourceGroupName == null)
 365            {
 0366                throw new ArgumentNullException(nameof(resourceGroupName));
 367            }
 4368            if (snapshotName == null)
 369            {
 0370                throw new ArgumentNullException(nameof(snapshotName));
 371            }
 372
 4373            using var message = CreateDeleteRequest(resourceGroupName, snapshotName);
 4374            _pipeline.Send(message, cancellationToken);
 4375            switch (message.Response.Status)
 376            {
 377                case 200:
 378                case 202:
 379                case 204:
 4380                    return message.Response;
 381                default:
 0382                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 383            }
 4384        }
 385
 386        internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName)
 387        {
 8388            var message = _pipeline.CreateMessage();
 8389            var request = message.Request;
 8390            request.Method = RequestMethod.Get;
 8391            var uri = new RawRequestUriBuilder();
 8392            uri.Reset(endpoint);
 8393            uri.AppendPath("/subscriptions/", false);
 8394            uri.AppendPath(subscriptionId, true);
 8395            uri.AppendPath("/resourceGroups/", false);
 8396            uri.AppendPath(resourceGroupName, true);
 8397            uri.AppendPath("/providers/Microsoft.Compute/snapshots", false);
 8398            uri.AppendQuery("api-version", "2019-11-01", true);
 8399            request.Uri = uri;
 8400            return message;
 401        }
 402
 403        /// <summary> Lists snapshots under a resource group. </summary>
 404        /// <param name="resourceGroupName"> The name of the resource group. </param>
 405        /// <param name="cancellationToken"> The cancellation token to use. </param>
 406        public async Task<Response<SnapshotList>> ListByResourceGroupAsync(string resourceGroupName, CancellationToken c
 407        {
 4408            if (resourceGroupName == null)
 409            {
 0410                throw new ArgumentNullException(nameof(resourceGroupName));
 411            }
 412
 4413            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 4414            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4415            switch (message.Response.Status)
 416            {
 417                case 200:
 418                    {
 4419                        SnapshotList value = default;
 4420                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4421                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 422                        {
 0423                            value = null;
 424                        }
 425                        else
 426                        {
 4427                            value = SnapshotList.DeserializeSnapshotList(document.RootElement);
 428                        }
 4429                        return Response.FromValue(value, message.Response);
 430                    }
 431                default:
 0432                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 433            }
 4434        }
 435
 436        /// <summary> Lists snapshots under a resource group. </summary>
 437        /// <param name="resourceGroupName"> The name of the resource group. </param>
 438        /// <param name="cancellationToken"> The cancellation token to use. </param>
 439        public Response<SnapshotList> ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken 
 440        {
 4441            if (resourceGroupName == null)
 442            {
 0443                throw new ArgumentNullException(nameof(resourceGroupName));
 444            }
 445
 4446            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 4447            _pipeline.Send(message, cancellationToken);
 4448            switch (message.Response.Status)
 449            {
 450                case 200:
 451                    {
 4452                        SnapshotList value = default;
 4453                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4454                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 455                        {
 0456                            value = null;
 457                        }
 458                        else
 459                        {
 4460                            value = SnapshotList.DeserializeSnapshotList(document.RootElement);
 461                        }
 4462                        return Response.FromValue(value, message.Response);
 463                    }
 464                default:
 0465                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 466            }
 4467        }
 468
 469        internal HttpMessage CreateListRequest()
 470        {
 4471            var message = _pipeline.CreateMessage();
 4472            var request = message.Request;
 4473            request.Method = RequestMethod.Get;
 4474            var uri = new RawRequestUriBuilder();
 4475            uri.Reset(endpoint);
 4476            uri.AppendPath("/subscriptions/", false);
 4477            uri.AppendPath(subscriptionId, true);
 4478            uri.AppendPath("/providers/Microsoft.Compute/snapshots", false);
 4479            uri.AppendQuery("api-version", "2019-11-01", true);
 4480            request.Uri = uri;
 4481            return message;
 482        }
 483
 484        /// <summary> Lists snapshots under a subscription. </summary>
 485        /// <param name="cancellationToken"> The cancellation token to use. </param>
 486        public async Task<Response<SnapshotList>> ListAsync(CancellationToken cancellationToken = default)
 487        {
 2488            using var message = CreateListRequest();
 2489            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2490            switch (message.Response.Status)
 491            {
 492                case 200:
 493                    {
 2494                        SnapshotList value = default;
 2495                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2496                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 497                        {
 0498                            value = null;
 499                        }
 500                        else
 501                        {
 2502                            value = SnapshotList.DeserializeSnapshotList(document.RootElement);
 503                        }
 2504                        return Response.FromValue(value, message.Response);
 505                    }
 506                default:
 0507                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 508            }
 2509        }
 510
 511        /// <summary> Lists snapshots under a subscription. </summary>
 512        /// <param name="cancellationToken"> The cancellation token to use. </param>
 513        public Response<SnapshotList> List(CancellationToken cancellationToken = default)
 514        {
 2515            using var message = CreateListRequest();
 2516            _pipeline.Send(message, cancellationToken);
 2517            switch (message.Response.Status)
 518            {
 519                case 200:
 520                    {
 2521                        SnapshotList value = default;
 2522                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2523                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 524                        {
 0525                            value = null;
 526                        }
 527                        else
 528                        {
 2529                            value = SnapshotList.DeserializeSnapshotList(document.RootElement);
 530                        }
 2531                        return Response.FromValue(value, message.Response);
 532                    }
 533                default:
 0534                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 535            }
 2536        }
 537
 538        internal HttpMessage CreateGrantAccessRequest(string resourceGroupName, string snapshotName, GrantAccessData gra
 539        {
 16540            var message = _pipeline.CreateMessage();
 16541            var request = message.Request;
 16542            request.Method = RequestMethod.Post;
 16543            var uri = new RawRequestUriBuilder();
 16544            uri.Reset(endpoint);
 16545            uri.AppendPath("/subscriptions/", false);
 16546            uri.AppendPath(subscriptionId, true);
 16547            uri.AppendPath("/resourceGroups/", false);
 16548            uri.AppendPath(resourceGroupName, true);
 16549            uri.AppendPath("/providers/Microsoft.Compute/snapshots/", false);
 16550            uri.AppendPath(snapshotName, true);
 16551            uri.AppendPath("/beginGetAccess", false);
 16552            uri.AppendQuery("api-version", "2019-11-01", true);
 16553            request.Uri = uri;
 16554            request.Headers.Add("Content-Type", "application/json");
 16555            var content = new Utf8JsonRequestContent();
 16556            content.JsonWriter.WriteObjectValue(grantAccessData);
 16557            request.Content = content;
 16558            return message;
 559        }
 560
 561        /// <summary> Grants access to a snapshot. </summary>
 562        /// <param name="resourceGroupName"> The name of the resource group. </param>
 563        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 564        /// <param name="grantAccessData"> Access data object supplied in the body of the get snapshot access operation.
 565        /// <param name="cancellationToken"> The cancellation token to use. </param>
 566        public async Task<Response> GrantAccessAsync(string resourceGroupName, string snapshotName, GrantAccessData gran
 567        {
 4568            if (resourceGroupName == null)
 569            {
 0570                throw new ArgumentNullException(nameof(resourceGroupName));
 571            }
 4572            if (snapshotName == null)
 573            {
 0574                throw new ArgumentNullException(nameof(snapshotName));
 575            }
 4576            if (grantAccessData == null)
 577            {
 0578                throw new ArgumentNullException(nameof(grantAccessData));
 579            }
 580
 4581            using var message = CreateGrantAccessRequest(resourceGroupName, snapshotName, grantAccessData);
 4582            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4583            switch (message.Response.Status)
 584            {
 585                case 200:
 586                case 202:
 4587                    return message.Response;
 588                default:
 0589                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 590            }
 4591        }
 592
 593        /// <summary> Grants access to a snapshot. </summary>
 594        /// <param name="resourceGroupName"> The name of the resource group. </param>
 595        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 596        /// <param name="grantAccessData"> Access data object supplied in the body of the get snapshot access operation.
 597        /// <param name="cancellationToken"> The cancellation token to use. </param>
 598        public Response GrantAccess(string resourceGroupName, string snapshotName, GrantAccessData grantAccessData, Canc
 599        {
 4600            if (resourceGroupName == null)
 601            {
 0602                throw new ArgumentNullException(nameof(resourceGroupName));
 603            }
 4604            if (snapshotName == null)
 605            {
 0606                throw new ArgumentNullException(nameof(snapshotName));
 607            }
 4608            if (grantAccessData == null)
 609            {
 0610                throw new ArgumentNullException(nameof(grantAccessData));
 611            }
 612
 4613            using var message = CreateGrantAccessRequest(resourceGroupName, snapshotName, grantAccessData);
 4614            _pipeline.Send(message, cancellationToken);
 4615            switch (message.Response.Status)
 616            {
 617                case 200:
 618                case 202:
 4619                    return message.Response;
 620                default:
 0621                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 622            }
 4623        }
 624
 625        internal HttpMessage CreateRevokeAccessRequest(string resourceGroupName, string snapshotName)
 626        {
 16627            var message = _pipeline.CreateMessage();
 16628            var request = message.Request;
 16629            request.Method = RequestMethod.Post;
 16630            var uri = new RawRequestUriBuilder();
 16631            uri.Reset(endpoint);
 16632            uri.AppendPath("/subscriptions/", false);
 16633            uri.AppendPath(subscriptionId, true);
 16634            uri.AppendPath("/resourceGroups/", false);
 16635            uri.AppendPath(resourceGroupName, true);
 16636            uri.AppendPath("/providers/Microsoft.Compute/snapshots/", false);
 16637            uri.AppendPath(snapshotName, true);
 16638            uri.AppendPath("/endGetAccess", false);
 16639            uri.AppendQuery("api-version", "2019-11-01", true);
 16640            request.Uri = uri;
 16641            return message;
 642        }
 643
 644        /// <summary> Revokes access to a snapshot. </summary>
 645        /// <param name="resourceGroupName"> The name of the resource group. </param>
 646        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 647        /// <param name="cancellationToken"> The cancellation token to use. </param>
 648        public async Task<Response> RevokeAccessAsync(string resourceGroupName, string snapshotName, CancellationToken c
 649        {
 4650            if (resourceGroupName == null)
 651            {
 0652                throw new ArgumentNullException(nameof(resourceGroupName));
 653            }
 4654            if (snapshotName == null)
 655            {
 0656                throw new ArgumentNullException(nameof(snapshotName));
 657            }
 658
 4659            using var message = CreateRevokeAccessRequest(resourceGroupName, snapshotName);
 4660            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4661            switch (message.Response.Status)
 662            {
 663                case 200:
 664                case 202:
 4665                    return message.Response;
 666                default:
 0667                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 668            }
 4669        }
 670
 671        /// <summary> Revokes access to a snapshot. </summary>
 672        /// <param name="resourceGroupName"> The name of the resource group. </param>
 673        /// <param name="snapshotName"> The name of the snapshot that is being created. The name can&apos;t be changed a
 674        /// <param name="cancellationToken"> The cancellation token to use. </param>
 675        public Response RevokeAccess(string resourceGroupName, string snapshotName, CancellationToken cancellationToken 
 676        {
 4677            if (resourceGroupName == null)
 678            {
 0679                throw new ArgumentNullException(nameof(resourceGroupName));
 680            }
 4681            if (snapshotName == null)
 682            {
 0683                throw new ArgumentNullException(nameof(snapshotName));
 684            }
 685
 4686            using var message = CreateRevokeAccessRequest(resourceGroupName, snapshotName);
 4687            _pipeline.Send(message, cancellationToken);
 4688            switch (message.Response.Status)
 689            {
 690                case 200:
 691                case 202:
 4692                    return message.Response;
 693                default:
 0694                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 695            }
 4696        }
 697
 698        internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName)
 699        {
 0700            var message = _pipeline.CreateMessage();
 0701            var request = message.Request;
 0702            request.Method = RequestMethod.Get;
 0703            var uri = new RawRequestUriBuilder();
 0704            uri.Reset(endpoint);
 0705            uri.AppendRawNextLink(nextLink, false);
 0706            request.Uri = uri;
 0707            return message;
 708        }
 709
 710        /// <summary> Lists snapshots under a resource group. </summary>
 711        /// <param name="nextLink"> The URL to the next page of results. </param>
 712        /// <param name="resourceGroupName"> The name of the resource group. </param>
 713        /// <param name="cancellationToken"> The cancellation token to use. </param>
 714        public async Task<Response<SnapshotList>> ListByResourceGroupNextPageAsync(string nextLink, string resourceGroup
 715        {
 0716            if (nextLink == null)
 717            {
 0718                throw new ArgumentNullException(nameof(nextLink));
 719            }
 0720            if (resourceGroupName == null)
 721            {
 0722                throw new ArgumentNullException(nameof(resourceGroupName));
 723            }
 724
 0725            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName);
 0726            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0727            switch (message.Response.Status)
 728            {
 729                case 200:
 730                    {
 0731                        SnapshotList value = default;
 0732                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0733                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 734                        {
 0735                            value = null;
 736                        }
 737                        else
 738                        {
 0739                            value = SnapshotList.DeserializeSnapshotList(document.RootElement);
 740                        }
 0741                        return Response.FromValue(value, message.Response);
 742                    }
 743                default:
 0744                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 745            }
 0746        }
 747
 748        /// <summary> Lists snapshots under a resource group. </summary>
 749        /// <param name="nextLink"> The URL to the next page of results. </param>
 750        /// <param name="resourceGroupName"> The name of the resource group. </param>
 751        /// <param name="cancellationToken"> The cancellation token to use. </param>
 752        public Response<SnapshotList> ListByResourceGroupNextPage(string nextLink, string resourceGroupName, Cancellatio
 753        {
 0754            if (nextLink == null)
 755            {
 0756                throw new ArgumentNullException(nameof(nextLink));
 757            }
 0758            if (resourceGroupName == null)
 759            {
 0760                throw new ArgumentNullException(nameof(resourceGroupName));
 761            }
 762
 0763            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName);
 0764            _pipeline.Send(message, cancellationToken);
 0765            switch (message.Response.Status)
 766            {
 767                case 200:
 768                    {
 0769                        SnapshotList value = default;
 0770                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0771                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 772                        {
 0773                            value = null;
 774                        }
 775                        else
 776                        {
 0777                            value = SnapshotList.DeserializeSnapshotList(document.RootElement);
 778                        }
 0779                        return Response.FromValue(value, message.Response);
 780                    }
 781                default:
 0782                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 783            }
 0784        }
 785
 786        internal HttpMessage CreateListNextPageRequest(string nextLink)
 787        {
 0788            var message = _pipeline.CreateMessage();
 0789            var request = message.Request;
 0790            request.Method = RequestMethod.Get;
 0791            var uri = new RawRequestUriBuilder();
 0792            uri.Reset(endpoint);
 0793            uri.AppendRawNextLink(nextLink, false);
 0794            request.Uri = uri;
 0795            return message;
 796        }
 797
 798        /// <summary> Lists snapshots under a subscription. </summary>
 799        /// <param name="nextLink"> The URL to the next page of results. </param>
 800        /// <param name="cancellationToken"> The cancellation token to use. </param>
 801        public async Task<Response<SnapshotList>> ListNextPageAsync(string nextLink, CancellationToken cancellationToken
 802        {
 0803            if (nextLink == null)
 804            {
 0805                throw new ArgumentNullException(nameof(nextLink));
 806            }
 807
 0808            using var message = CreateListNextPageRequest(nextLink);
 0809            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0810            switch (message.Response.Status)
 811            {
 812                case 200:
 813                    {
 0814                        SnapshotList value = default;
 0815                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0816                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 817                        {
 0818                            value = null;
 819                        }
 820                        else
 821                        {
 0822                            value = SnapshotList.DeserializeSnapshotList(document.RootElement);
 823                        }
 0824                        return Response.FromValue(value, message.Response);
 825                    }
 826                default:
 0827                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 828            }
 0829        }
 830
 831        /// <summary> Lists snapshots under a subscription. </summary>
 832        /// <param name="nextLink"> The URL to the next page of results. </param>
 833        /// <param name="cancellationToken"> The cancellation token to use. </param>
 834        public Response<SnapshotList> ListNextPage(string nextLink, CancellationToken cancellationToken = default)
 835        {
 0836            if (nextLink == null)
 837            {
 0838                throw new ArgumentNullException(nameof(nextLink));
 839            }
 840
 0841            using var message = CreateListNextPageRequest(nextLink);
 0842            _pipeline.Send(message, cancellationToken);
 0843            switch (message.Response.Status)
 844            {
 845                case 200:
 846                    {
 0847                        SnapshotList value = default;
 0848                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0849                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 850                        {
 0851                            value = null;
 852                        }
 853                        else
 854                        {
 0855                            value = SnapshotList.DeserializeSnapshotList(document.RootElement);
 856                        }
 0857                        return Response.FromValue(value, message.Response);
 858                    }
 859                default:
 0860                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 861            }
 0862        }
 863    }
 864}