private StorageAccountCredentialResponse ConvertToSACResponse(StorageAccountCredential cred)
        {
            StorageAccountCredentialResponse sac = new StorageAccountCredentialResponse();

            sac.CloudType           = cred.CloudType;
            sac.Hostname            = cred.Hostname;
            sac.InstanceId          = cred.InstanceId;
            sac.IsDefault           = cred.IsDefault;
            sac.Location            = cred.Location;
            sac.Login               = cred.Login;
            sac.Name                = cred.Name;
            sac.OperationInProgress = cred.OperationInProgress;
            sac.PasswordEncryptionCertThumbprint = cred.PasswordEncryptionCertThumbprint;
            sac.Password    = cred.Password;
            sac.UseSSL      = cred.UseSSL;
            sac.VolumeCount = 0;
            return(sac);
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                string endpoint = string.IsNullOrEmpty(Endpoint) ? StorSimpleConstants.DefaultStorageAccountEndpoint : Endpoint;

                var sac = new StorageAccountCredentialResponse()
                {
                    CloudType = CloudType.Azure,
                    Hostname  = GetHostnameFromEndpoint(endpoint),
                    Login     = StorageAccountName,
                    Password  = StorageAccountKey,
                    UseSSL    = true,
                    Name      = StorageAccountName
                };

                WriteObject(sac);
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
        public override void ExecuteCmdlet()
        {
            ConfirmAction(Force.IsPresent,
                          Resources.RemoveWarningACR,
                          Resources.RemoveConfirmationACR,
                          string.Empty,
                          () =>
            {
                try
                {
                    StorageAccountCredentialResponse existingSac = null;
                    string sacName = null;

                    switch (ParameterSetName)
                    {
                    case StorSimpleCmdletParameterSet.IdentifyByName:
                        var allSACs = StorSimpleClient.GetAllStorageAccountCredentials();
                        existingSac = allSACs.Where(x => x.Name.Equals(StorageAccountName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                        sacName     = StorageAccountName;
                        break;

                    case StorSimpleCmdletParameterSet.IdentifyByObject:
                        existingSac = SAC;
                        sacName     = SAC.Name;
                        break;
                    }
                    if (existingSac == null)
                    {
                        WriteObject(null);
                        WriteVerbose(string.Format(Resources.SACNotFoundWithName, sacName));
                        return;
                    }

                    var serviceConfig = new ServiceConfiguration()
                    {
                        AcrChangeList        = new AcrChangeList(),
                        CredentialChangeList = new SacChangeList()
                        {
                            Added   = new List <StorageAccountCredential>(),
                            Deleted = new[] { existingSac.InstanceId },
                            Updated = new List <StorageAccountCredential>()
                        }
                    };

                    if (WaitForComplete.IsPresent)
                    {
                        WriteVerbose("About to run a task to remove your Storage Access Credential!");
                        var taskStatus = StorSimpleClient.ConfigureService(serviceConfig);
                        HandleSyncTaskResponse(taskStatus, "delete");
                    }
                    else
                    {
                        WriteVerbose("About to create a task to remove your Storage Access Credential!");
                        var taskResponse = StorSimpleClient.ConfigureServiceAsync(serviceConfig);
                        HandleAsyncTaskResponse(taskResponse, "delete");
                    }
                }
                catch (Exception exception)
                {
                    this.HandleException(exception);
                }
            });
        }