コード例 #1
0
        public override void ExecuteCmdlet()
        {
            StoreClient = StoreClient ?? new StoreClient(
                CurrentSubscription.SubscriptionId,
                ServiceEndpoint,
                CurrentSubscription.Certificate,
                text => this.WriteDebug(text),
                Channel);
            CustomConfirmation = CustomConfirmation ?? new PowerShellCustomConfirmation(Host);
            WindowsAzureAddOn addon;

            if (StoreClient.TryGetAddOn(Name, out addon))
            {
                string message  = StoreClient.GetConfirmationMessage(OperationType.Set, addon.AddOn, Plan);
                bool   purchase = CustomConfirmation.ShouldProcess(Resources.SetAddOnConformation, message);

                if (purchase)
                {
                    StoreClient.UpdateAddOn(Name, Plan, PromotionCode);
                    WriteVerbose(string.Format(Resources.AddOnUpdatedMessage, Name));

                    if (PassThru.IsPresent)
                    {
                        WriteObject(true);
                    }
                }
            }
        }
コード例 #2
0
        public override void ExecuteCmdlet()
        {
            StoreClient = StoreClient ?? new StoreClient(
                CurrentSubscription.SubscriptionId,
                ServiceEndpoint,
                CurrentSubscription.Certificate,
                text => this.WriteDebug(text),
                Channel);
            WindowsAzureAddOn addon;

            CustomConfirmation = CustomConfirmation ?? new PowerShellCustomConfirmation(Host);

            if (!StoreClient.TryGetAddOn(Name, out addon))
            {
                string message  = StoreClient.GetConfirmationMessage(OperationType.New, AddOn, Plan);
                bool   purchase = CustomConfirmation.ShouldProcess(Resources.NewAddOnConformation, message);

                if (purchase)
                {
                    StoreClient.NewAddOn(Name, AddOn, Plan, Location, PromotionCode);
                    WriteVerbose(string.Format(Resources.AddOnCreatedMessage, Name));
                    WriteObject(true);
                }
            }
            else
            {
                throw new Exception(string.Format(Resources.AddOnNameAlreadyUsed, Name));
            }
        }
コード例 #3
0
        private void DeleteServer()
        {
            bool shouldUnregister = true;

            if (!Force.IsPresent)
            {
                customerConfirmation = customerConfirmation ?? new PowerShellCustomConfirmation(Host);
                shouldUnregister     = customerConfirmation.ShouldProcess(Resources.UnregisterServerCaption, Resources.UnregisterServerMessage);
            }

            if (shouldUnregister)
            {
                AzureBackupClient.UnregisterMachineContainer(Container.ResourceGroupName, Container.ResourceName, Container.Id);
            }
        }
コード例 #4
0
 protected override void ProcessRecord()
 {
     if (this.Force.IsPresent)
     {
         this.RemoveDnsServer();
     }
     else
     {
         CustomConfirmation = CustomConfirmation ?? new PowerShellCustomConfirmation(Host);
         bool remove = CustomConfirmation.ShouldProcess(Resources.RemoveAzureDnsServerCaption, this.GetWarningMessage());
         if (remove)
         {
             this.RemoveDnsServer();
         }
     }
 }
コード例 #5
0
        public override void ExecuteCmdlet()
        {
            StoreClient = StoreClient ?? new StoreClient(CurrentSubscription);
            CustomConfirmation = CustomConfirmation ?? new PowerShellCustomConfirmation(Host);

            string message = StoreClient.GetConfirmationMessage(OperationType.Remove);
            bool remove = CustomConfirmation.ShouldProcess(Resources.RemoveAddOnConformation, message);
            if (remove)
            {
                StoreClient.RemoveAddOn(Name);
                WriteVerbose(string.Format(Resources.AddOnRemovedMessage, Name));
                if (PassThru.IsPresent)
                {
                    WriteObject(true);
                }
            }
        }
コード例 #6
0
        public override void ExecuteCmdlet()
        {
            StoreClient        = StoreClient ?? new StoreClient(CurrentContext.Subscription);
            CustomConfirmation = CustomConfirmation ?? new PowerShellCustomConfirmation(Host);

            string message = StoreClient.GetConfirmationMessage(OperationType.Remove);
            bool   remove  = CustomConfirmation.ShouldProcess(Resources.RemoveAddOnConformation, message);

            if (remove)
            {
                StoreClient.RemoveAddOn(Name);
                WriteVerbose(string.Format(Resources.AddOnRemovedMessage, Name));
                if (PassThru.IsPresent)
                {
                    WriteObject(true);
                }
            }
        }
コード例 #7
0
        public override void ExecuteCmdlet()
        {
            StoreClient = StoreClient ?? new StoreClient(CurrentSubscription);
            CustomConfirmation = CustomConfirmation ?? new PowerShellCustomConfirmation(Host);
            WindowsAzureAddOn addon;

            if (StoreClient.TryGetAddOn(Name, out addon))
            {
                string message = StoreClient.GetConfirmationMessage(OperationType.Set, addon.AddOn, Plan);
                bool purchase = CustomConfirmation.ShouldProcess(Resources.SetAddOnConformation, message);

                if (purchase)
                {
                    StoreClient.UpdateAddOn(Name, Plan, PromotionCode);
                    WriteVerbose(string.Format(Resources.AddOnUpdatedMessage, Name));

                    if (PassThru.IsPresent)
                    {
                        WriteObject(true);
                    }
                }
            }
        }
コード例 #8
0
        public override void ExecuteCmdlet()
        {
            StoreClient = StoreClient ?? new StoreClient(CurrentSubscription);
            WindowsAzureAddOn addon;
            CustomConfirmation = CustomConfirmation ?? new PowerShellCustomConfirmation(Host);

            if (!StoreClient.TryGetAddOn(Name, out addon))
            {
                string message = StoreClient.GetConfirmationMessage(OperationType.New, AddOn, Plan);
                bool purchase = CustomConfirmation.ShouldProcess(Resources.NewAddOnConformation, message);

                if (purchase)
                {
                    StoreClient.NewAddOn(Name, AddOn, Plan, Location, PromotionCode);
                    WriteVerbose(string.Format(Resources.AddOnCreatedMessage, Name));
                    WriteObject(true);
                }
            }
            else
            {
                throw new Exception(string.Format(Resources.AddOnNameAlreadyUsed, Name));
            }
        }
コード例 #9
0
        public override void ExecuteCmdlet()
        {
            StoreClient = StoreClient ?? new StoreClient(
                CurrentSubscription.SubscriptionId,
                ServiceEndpoint,
                CurrentSubscription.Certificate,
                text => this.WriteDebug(text),
                Channel);
            CustomConfirmation = CustomConfirmation ?? new PowerShellCustomConfirmation(Host);

            string message = StoreClient.GetConfirmationMessage(OperationType.Remove);
            bool   remove  = CustomConfirmation.ShouldProcess(Resources.RemoveAddOnConformation, message);

            if (remove)
            {
                StoreClient.RemoveAddOn(Name);
                WriteVerbose(string.Format(Resources.AddOnRemovedMessage, Name));
                if (PassThru.IsPresent)
                {
                    WriteObject(true);
                }
            }
        }