Beispiel #1
0
 /// <summary>
 /// Executes the API call(s) against Azure Resource Management API(s).
 /// </summary>
 protected override object ExecuteCore()
 {
     using (var client = this.GetAzureStackClient(this.SubscriptionId))
     {
         this.WriteVerbose(Resources.UpdatingOffer.FormatArgs(this.Offer.Name, this.ResourceGroup));
         var parameters = new ManagedOfferCreateOrUpdateParameters(this.Offer);
         return(client.ManagedOffers.CreateOrUpdate(this.ResourceGroup, parameters).Offer);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Executes the API call(s) against Azure Resource Management API(s).
        /// </summary>
        protected override void ExecuteCore()
        {
            if (this.MyInvocation.InvocationName.Equals("Set-AzureRmOffer", StringComparison.OrdinalIgnoreCase))
            {
                this.WriteWarning("Alias Set-AzureRmOffer will be deprecated in a future release. Please use the cmdlet name Set-AzsOffer instead");
            }

            if (ShouldProcess(this.Offer.Name, VerbsCommon.Set))
            {
                using (var client = this.GetAzureStackClient())
                {
                    this.WriteVerbose(Resources.UpdatingOffer.FormatArgs(this.Offer.Name, this.ResourceGroupName));
                    var parameters = new ManagedOfferCreateOrUpdateParameters(this.Offer);
                    var result     = client.ManagedOffers.CreateOrUpdate(this.ResourceGroupName, parameters).Offer;
                    WriteObject(result);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Executes the API call(s) against Azure Resource Management API(s).
        /// </summary>
        protected override object ExecuteCore()
        {
            this.WriteVerbose(Resources.CreatingNewOffer.FormatArgs(this.Name, this.ResourceGroup));
            using (var client = this.GetAzureStackClient(this.SubscriptionId))
            {
                // Ensure the resource group is created
                client.ResourceGroups.CreateOrUpdate(new ResourceGroupCreateOrUpdateParameters()
                {
                    ResourceGroup = new ResourceGroupDefinition()
                    {
                        Location = this.ArmLocation,
                        Name     = this.ResourceGroup,
                    }
                });

                var parameters = new ManagedOfferCreateOrUpdateParameters()
                {
                    Offer = new AdminOfferModel()
                    {
                        Name       = this.Name,
                        Location   = this.ArmLocation,
                        Properties = new AdminOfferDefinition()
                        {
                            Name        = this.Name,
                            DisplayName = this.DisplayName,
                            State       = this.State,
                        }
                    }
                };

                if (this.BasePlans != null && this.BasePlans.Length > 0)
                {
                    parameters.Offer.Properties.BasePlans = this.BasePlans.Select(plan => plan.Properties).ToArray();
                }

                if (client.ManagedOffers.List(this.ResourceGroup, includeDetails: false).Offers
                    .Any(offer => string.Equals(offer.Properties.Name, parameters.Offer.Properties.Name, StringComparison.OrdinalIgnoreCase)))
                {
                    throw new PSInvalidOperationException(Resources.ManagedOfferAlreadyExists.FormatArgs(parameters.Offer.Properties.Name, this.ResourceGroup));
                }

                return(client.ManagedOffers.CreateOrUpdate(this.ResourceGroup, parameters).Offer);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Your documentation here.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.AzureStack.Management.IManagedOfferOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. Your documentation here.
 /// </param>
 /// <param name='parameters'>
 /// Required. Your documentation here.
 /// </param>
 /// <returns>
 /// Your documentation here.
 /// </returns>
 public static Task <ManagedOfferCreateOrUpdateResult> CreateOrUpdateAsync(this IManagedOfferOperations operations, string resourceGroupName, ManagedOfferCreateOrUpdateParameters parameters)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, parameters, CancellationToken.None));
 }
Beispiel #5
0
 /// <summary>
 /// Your documentation here.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.AzureStack.Management.IManagedOfferOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. Your documentation here.
 /// </param>
 /// <param name='parameters'>
 /// Required. Your documentation here.
 /// </param>
 /// <returns>
 /// Your documentation here.
 /// </returns>
 public static ManagedOfferCreateOrUpdateResult CreateOrUpdate(this IManagedOfferOperations operations, string resourceGroupName, ManagedOfferCreateOrUpdateParameters parameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IManagedOfferOperations)s).CreateOrUpdateAsync(resourceGroupName, parameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
        /// <summary>
        /// Executes the API call(s) against Azure Resource Management API(s).
        /// </summary>
        protected override void ExecuteCore()
        {
            if (this.MyInvocation.InvocationName.Equals("New-AzureRmOffer", StringComparison.OrdinalIgnoreCase))
            {
                this.WriteWarning("Alias New-AzureRmOffer will be deprecated in a future release. Please use the cmdlet name New-AzsOffer instead");
            }

            if (ShouldProcess(this.Name, VerbsCommon.New))
            {
                this.WriteVerbose(Resources.CreatingNewOffer.FormatArgs(this.Name, this.ResourceGroupName));
                using (var client = this.GetAzureStackClient())
                {
                    // Ensure the resource group is created
                    client.ResourceGroups.CreateOrUpdate(new ResourceGroupCreateOrUpdateParameters()
                    {
                        ResourceGroup = new ResourceGroupDefinition()
                        {
                            Location = this.ArmLocation,
                            Name     = this.ResourceGroupName,
                        }
                    });

                    var parameters = new ManagedOfferCreateOrUpdateParameters()
                    {
                        Offer = new AdminOfferModel()
                        {
                            Name       = this.Name,
                            Location   = this.ArmLocation,
                            Properties = new AdminOfferPropertiesDefinition()
                            {
                                Name        = this.Name,
                                DisplayName = this.DisplayName,
                                State       = this.State,
                            }
                        }
                    };

                    if (this.BasePlanIds != null && this.BasePlanIds.Length > 0)
                    {
                        parameters.Offer.Properties.BasePlanIds = this.BasePlanIds;
                    }

                    if (this.AddOnPlans != null && this.AddOnPlans.Length > 0)
                    {
                        parameters.Offer.Properties.AddonPlans = this.AddOnPlans.ToList();
                    }

                    if (client.ManagedOffers.List(this.ResourceGroupName, includeDetails: false).Offers
                        .Any(
                            offer =>
                            string.Equals(offer.Properties.Name, parameters.Offer.Properties.Name,
                                          StringComparison.OrdinalIgnoreCase)))
                    {
                        throw new PSInvalidOperationException(
                                  Resources.ManagedOfferAlreadyExists.FormatArgs(parameters.Offer.Properties.Name,
                                                                                 this.ResourceGroupName));
                    }

                    var result = client.ManagedOffers.CreateOrUpdate(this.ResourceGroupName, parameters).Offer;
                    WriteObject(result);
                }
            }
        }