public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.SnapshotName, VerbsCommon.Remove) &&
                    (this.Force.IsPresent ||
                     this.ShouldContinue(Properties.Resources.ResourceRemovalConfirmation,
                                         "Remove-AzSnapshot operation")))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;

                    var result = SnapshotsClient.DeleteWithHttpMessagesAsync(resourceGroupName, snapshotName).GetAwaiter().GetResult();
                    PSOperationStatusResponse output = new PSOperationStatusResponse
                    {
                        StartTime = this.StartTime,
                        EndTime   = DateTime.Now
                    };

                    if (result != null && result.Request != null && result.Request.RequestUri != null)
                    {
                        output.Name = GetOperationIdFromUrlString(result.Request.RequestUri.ToString());
                    }

                    WriteObject(output);
                }
            });
        }
        /// <summary>Snippet for SetLabelsAsync</summary>
        public async Task SetLabelsAsync()
        {
            // Snippet: SetLabelsAsync(string, string, GlobalSetLabelsRequest, CallSettings)
            // Additional: SetLabelsAsync(string, string, GlobalSetLabelsRequest, CancellationToken)
            // Create client
            SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync();

            // Initialize request argument(s)
            string project  = "";
            string resource = "";
            GlobalSetLabelsRequest globalSetLabelsRequestResource = new GlobalSetLabelsRequest();
            // Make the request
            lro::Operation <Operation, Operation> response = await snapshotsClient.SetLabelsAsync(project, resource, globalSetLabelsRequestResource);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Operation result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            lro::Operation <Operation, Operation> retrievedResponse = await snapshotsClient.PollOnceSetLabelsAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
        protected void ExecuteSnapshotRevokeAccessMethod(object[] invokeMethodInputParameters)
        {
            string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string snapshotName      = (string)ParseParameter(invokeMethodInputParameters[1]);

            SnapshotsClient.RevokeAccess(resourceGroupName, snapshotName);
        }
        protected override void ProcessRecord()
        {
            ComputeAutomationAutoMapperProfile.Initialize();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;

                    Snapshot snapshotObj = new Snapshot();
                    Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshotObj);

                    SnapshotUpdate snapshotUpdateObj = new SnapshotUpdate();
                    Mapper.Map <PSSnapshotUpdate, SnapshotUpdate>(this.SnapshotUpdate, snapshotUpdateObj);

                    var result = (this.SnapshotUpdate == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotObj)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotUpdateObj);

                    var psObject = new PSSnapshot();
                    Mapper.Map <Snapshot, PSSnapshot>(result, psObject);

                    WriteObject(psObject);
                }
            });
        }
        /// <summary>Snippet for Delete</summary>
        public void Delete()
        {
            // Snippet: Delete(string, string, CallSettings)
            // Create client
            SnapshotsClient snapshotsClient = SnapshotsClient.Create();
            // Initialize request argument(s)
            string project  = "";
            string snapshot = "";
            // Make the request
            lro::Operation <Operation, Operation> response = snapshotsClient.Delete(project, snapshot);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Operation result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            lro::Operation <Operation, Operation> retrievedResponse = snapshotsClient.PollOnceDelete(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.SnapshotName, VerbsSecurity.Revoke))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;

                    var result = SnapshotsClient.RevokeAccessWithHttpMessagesAsync(resourceGroupName, snapshotName).GetAwaiter().GetResult();
                    PSOperationStatusResponse output = new PSOperationStatusResponse
                    {
                        StartTime = this.StartTime,
                        EndTime   = DateTime.Now
                    };

                    if (result != null && result.Request != null && result.Request.RequestUri != null)
                    {
                        output.Name = GetOperationIdFromUrlString(result.Request.RequestUri.ToString());
                    }

                    WriteObject(output);
                }
            });
        }
        public override void ExecuteCmdlet()
        {
            ExecuteClientAction(() =>
            {
                WriteWarning("Update-AzureRmSnapshot: A property of the output of this cmdlet will change in an upcoming breaking change release. " +
                             "The Name property for a Sku will return Standard_LRS and Premium_LRS");

                if (ShouldProcess(this.SnapshotName, VerbsData.Update))
                {
                    string resourceGroupName      = this.ResourceGroupName;
                    string snapshotName           = this.SnapshotName;
                    SnapshotUpdate snapshotupdate = new SnapshotUpdate();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshotUpdate, SnapshotUpdate>(this.SnapshotUpdate, snapshotupdate);
                    Snapshot snapshot = new Snapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshot);

                    var result = (this.SnapshotUpdate == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotupdate);
                    var psObject = new PSSnapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
Exemple #8
0
        public DigitalOceanClient(string token)
        {
            var client = new RestClient(DigitalOceanApiUrl)
            {
                UserAgent = "digitalocean-api-dotnet"
            };

            client.AddDefaultHeader("Authorization", $"Bearer {token}");

            _connection = new Connection(client);

            Actions           = new ActionsClient(_connection);
            DomainRecords     = new DomainRecordsClient(_connection);
            Domains           = new DomainsClient(_connection);
            DropletActions    = new DropletActionsClient(_connection);
            Droplets          = new DropletsClient(_connection);
            FloatingIps       = new FloatingIpsClient(_connection);
            FloatingIpActions = new FloatingIpActionsClient(_connection);
            ImageActions      = new ImageActionsClient(_connection);
            Images            = new ImagesClient(_connection);
            Keys      = new KeysClient(_connection);
            Regions   = new RegionsClient(_connection);
            Sizes     = new SizesClient(_connection);
            Snapshots = new SnapshotsClient(_connection);
            Tags      = new TagsClient(_connection);
            Volumes   = new VolumesClient(_connection);
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                Snapshot existingResource;
                try
                {
                    existingResource = SnapshotsClient.Get(this.ResourceGroupName, this.SnapshotName);
                }
                catch
                {
                    existingResource = null;
                }

                if (existingResource != null)
                {
                    throw new Exception(string.Format("A Snapshot with name '{0}' in resource group '{1}' already exists. Please use Update-AzSnapshot to update an existing Snapshot.", this.SnapshotName, this.ResourceGroupName));
                }

                if (ShouldProcess(this.SnapshotName, VerbsCommon.New))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;
                    Snapshot snapshot        = new Snapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshot);

                    var result   = SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot);
                    var psObject = new PSSnapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
        /// <summary>Snippet for SetLabels</summary>
        public void SetLabelsRequestObject()
        {
            // Snippet: SetLabels(SetLabelsSnapshotRequest, CallSettings)
            // Create client
            SnapshotsClient snapshotsClient = SnapshotsClient.Create();
            // Initialize request argument(s)
            SetLabelsSnapshotRequest request = new SetLabelsSnapshotRequest
            {
                Resource = "",
                Project  = "",
                GlobalSetLabelsRequestResource = new GlobalSetLabelsRequest(),
            };
            // Make the request
            lro::Operation <Operation, Operation> response = snapshotsClient.SetLabels(request);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Operation result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            lro::Operation <Operation, Operation> retrievedResponse = snapshotsClient.PollOnceSetLabels(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                string resourceGroupName = this.ResourceGroupName;
                string snapshotName      = this.SnapshotName;

                if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(snapshotName))
                {
                    var result   = SnapshotsClient.Get(resourceGroupName, snapshotName);
                    var psObject = new PSSnapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject);
                    WriteObject(psObject);
                }
                else if (!string.IsNullOrEmpty(resourceGroupName))
                {
                    var result       = SnapshotsClient.ListByResourceGroup(resourceGroupName);
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = SnapshotsClient.ListByResourceGroupNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSSnapshotList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshotList>(r));
                    }
                    WriteObject(psObject, true);
                }
                else
                {
                    var result       = SnapshotsClient.List();
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = SnapshotsClient.ListNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSSnapshotList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshotList>(r));
                    }
                    WriteObject(psObject, true);
                }
            });
        }
        protected void ExecuteSnapshotListNextMethod(object[] invokeMethodInputParameters)
        {
            string nextPageLink = (string)ParseParameter(invokeMethodInputParameters[0]);

            var result = SnapshotsClient.ListNext(nextPageLink);

            WriteObject(result);
        }
Exemple #13
0
        protected void ExecuteSnapshotDeleteMethod(object[] invokeMethodInputParameters)
        {
            string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string snapshotName      = (string)ParseParameter(invokeMethodInputParameters[1]);

            var result = SnapshotsClient.Delete(resourceGroupName, snapshotName);

            WriteObject(result);
        }
        protected void ExecuteSnapshotGetMethod(object[] invokeMethodInputParameters)
        {
            string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string snapshotName      = (string)ParseParameter(invokeMethodInputParameters[1]);

            if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(snapshotName))
            {
                var result   = SnapshotsClient.Get(resourceGroupName, snapshotName);
                var psObject = new PSSnapshot();
                Mapper.Map <Snapshot, PSSnapshot>(result, psObject);
                WriteObject(psObject);
            }
            else if (!string.IsNullOrEmpty(resourceGroupName))
            {
                var result       = SnapshotsClient.ListByResourceGroup(resourceGroupName);
                var resultList   = result.ToList();
                var nextPageLink = result.NextPageLink;
                while (!string.IsNullOrEmpty(nextPageLink))
                {
                    var pageResult = SnapshotsClient.ListByResourceGroupNext(nextPageLink);
                    foreach (var pageItem in pageResult)
                    {
                        resultList.Add(pageItem);
                    }
                    nextPageLink = pageResult.NextPageLink;
                }
                var psObject = new List <PSSnapshotList>();
                foreach (var r in resultList)
                {
                    psObject.Add(Mapper.Map <Snapshot, PSSnapshotList>(r));
                }
                WriteObject(psObject, true);
            }
            else
            {
                var result       = SnapshotsClient.List();
                var resultList   = result.ToList();
                var nextPageLink = result.NextPageLink;
                while (!string.IsNullOrEmpty(nextPageLink))
                {
                    var pageResult = SnapshotsClient.ListNext(nextPageLink);
                    foreach (var pageItem in pageResult)
                    {
                        resultList.Add(pageItem);
                    }
                    nextPageLink = pageResult.NextPageLink;
                }
                var psObject = new List <PSSnapshotList>();
                foreach (var r in resultList)
                {
                    psObject.Add(Mapper.Map <Snapshot, PSSnapshotList>(r));
                }
                WriteObject(psObject, true);
            }
        }
Exemple #15
0
        public void CorrectRequestForDelete()
        {
            var factory = Substitute.For <IConnection>();
            var client  = new SnapshotsClient(factory);

            client.Delete("snapshot:abc123");

            var parameters = Arg.Is <List <Parameter> >(list => (string)list[0].Value == "snapshot:abc123");

            factory.Received().ExecuteRaw("snapshots/{snapshot_id}", parameters, null, Method.DELETE);
        }
Exemple #16
0
 /// <summary>Snippet for List</summary>
 public void List()
 {
     // Snippet: List(string, CallSettings)
     // Create client
     SnapshotsClient snapshotsClient = SnapshotsClient.Create();
     // Initialize request argument(s)
     string project = "";
     // Make the request
     SnapshotList response = snapshotsClient.List(project);
     // End snippet
 }
 /// <summary>Snippet for Delete</summary>
 public void Delete()
 {
     // Snippet: Delete(string, string, CallSettings)
     // Create client
     SnapshotsClient snapshotsClient = SnapshotsClient.Create();
     // Initialize request argument(s)
     string project  = "";
     string snapshot = "";
     // Make the request
     Operation response = snapshotsClient.Delete(project, snapshot);
     // End snippet
 }
 /// <summary>Snippet for GetIamPolicy</summary>
 public void GetIamPolicy()
 {
     // Snippet: GetIamPolicy(string, string, CallSettings)
     // Create client
     SnapshotsClient snapshotsClient = SnapshotsClient.Create();
     // Initialize request argument(s)
     string project  = "";
     string resource = "";
     // Make the request
     Policy response = snapshotsClient.GetIamPolicy(project, resource);
     // End snippet
 }
 /// <summary>Snippet for SetIamPolicy</summary>
 public void SetIamPolicy()
 {
     // Snippet: SetIamPolicy(string, string, GlobalSetPolicyRequest, CallSettings)
     // Create client
     SnapshotsClient snapshotsClient = SnapshotsClient.Create();
     // Initialize request argument(s)
     string project  = "";
     string resource = "";
     GlobalSetPolicyRequest globalSetPolicyRequestResource = new GlobalSetPolicyRequest();
     // Make the request
     Policy response = snapshotsClient.SetIamPolicy(project, resource, globalSetPolicyRequestResource);
     // End snippet
 }
        protected void ExecuteSnapshotUpdateMethod(object[] invokeMethodInputParameters)
        {
            string           resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string           snapshotName      = (string)ParseParameter(invokeMethodInputParameters[1]);
            PSSnapshotUpdate snapshot          = (PSSnapshotUpdate)ParseParameter(invokeMethodInputParameters[2]);
            PSSnapshot       snapshotOrg       = (PSSnapshot)ParseParameter(invokeMethodInputParameters[3]);

            var result = (snapshot == null)
                         ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotOrg)
                         : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshot);

            WriteObject(result);
        }
 /// <summary>Snippet for TestIamPermissions</summary>
 public void TestIamPermissions()
 {
     // Snippet: TestIamPermissions(string, string, TestPermissionsRequest, CallSettings)
     // Create client
     SnapshotsClient snapshotsClient = SnapshotsClient.Create();
     // Initialize request argument(s)
     string project  = "";
     string resource = "";
     TestPermissionsRequest testPermissionsRequestResource = new TestPermissionsRequest();
     // Make the request
     TestPermissionsResponse response = snapshotsClient.TestIamPermissions(project, resource, testPermissionsRequestResource);
     // End snippet
 }
        /// <summary>Snippet for ListAsync</summary>
        public async Task ListRequestObjectAsync()
        {
            // Snippet: ListAsync(ListSnapshotsRequest, CallSettings)
            // Create client
            SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync();

            // Initialize request argument(s)
            ListSnapshotsRequest request = new ListSnapshotsRequest
            {
                OrderBy = "",
                Project = "",
                Filter  = "",
                ReturnPartialSuccess = false,
            };
            // Make the request
            PagedAsyncEnumerable <SnapshotList, Snapshot> response = snapshotsClient.ListAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Snapshot item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((SnapshotList page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Snapshot item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int             pageSize   = 10;
            Page <Snapshot> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Snapshot item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Exemple #23
0
        public void CorrectRequestForGetAll()
        {
            var factory = Substitute.For <IConnection>();
            var client  = new SnapshotsClient(factory);

            client.GetAll();
            factory.Received().GetPaginated <Snapshot>("snapshots", null, "snapshots");

            client.GetAll(SnapshotType.Droplet);
            factory.Received().GetPaginated <Snapshot>("snapshots?resource_type=droplet", null, "snapshots");

            client.GetAll(SnapshotType.Volume);
            factory.Received().GetPaginated <Snapshot>("snapshots?resource_type=volume", null, "snapshots");
        }
Exemple #24
0
        protected override void ProcessRecord()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsSecurity.Revoke))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;

                    var result = SnapshotsClient.RevokeAccess(resourceGroupName, snapshotName);
                    WriteObject(result);
                }
            });
        }
Exemple #25
0
        /// <summary>Snippet for ListAsync</summary>
        public async Task ListAsync()
        {
            // Snippet: ListAsync(string, CallSettings)
            // Additional: ListAsync(string, CancellationToken)
            // Create client
            SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync();

            // Initialize request argument(s)
            string project = "";
            // Make the request
            SnapshotList response = await snapshotsClient.ListAsync(project);

            // End snippet
        }
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetSnapshotRequest, CallSettings)
     // Create client
     SnapshotsClient snapshotsClient = SnapshotsClient.Create();
     // Initialize request argument(s)
     GetSnapshotRequest request = new GetSnapshotRequest
     {
         Project  = "",
         Snapshot = "",
     };
     // Make the request
     Snapshot response = snapshotsClient.Get(request);
     // End snippet
 }
Exemple #27
0
        protected override void ProcessRecord()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsCommon.New))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;
                    PSSnapshot snapshot      = this.Snapshot;

                    var result = SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot);
                    WriteObject(result);
                }
            });
        }
        /// <summary>Snippet for GetIamPolicyAsync</summary>
        public async Task GetIamPolicyAsync()
        {
            // Snippet: GetIamPolicyAsync(string, string, CallSettings)
            // Additional: GetIamPolicyAsync(string, string, CancellationToken)
            // Create client
            SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync();

            // Initialize request argument(s)
            string project  = "";
            string resource = "";
            // Make the request
            Policy response = await snapshotsClient.GetIamPolicyAsync(project, resource);

            // End snippet
        }
        public override void ExecuteCmdlet()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.SnapshotName, VerbsSecurity.Revoke))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;

                    var result   = SnapshotsClient.RevokeAccess(resourceGroupName, snapshotName);
                    var psObject = new PSOperationStatusResponse();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Azure.Management.Compute.Models.OperationStatusResponse, PSOperationStatusResponse>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
Exemple #30
0
        protected void ExecuteSnapshotGrantAccessMethod(object[] invokeMethodInputParameters)
        {
            string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string snapshotName      = (string)ParseParameter(invokeMethodInputParameters[1]);
            var    grantAccessData   = new GrantAccessData();
            var    pAccess           = (string)ParseParameter(invokeMethodInputParameters[2]);

            grantAccessData.Access = pAccess;
            var pDurationInSeconds = (int)ParseParameter(invokeMethodInputParameters[3]);

            grantAccessData.DurationInSeconds = pDurationInSeconds;

            var result = SnapshotsClient.GrantAccess(resourceGroupName, snapshotName, grantAccessData);

            WriteObject(result);
        }