Exemplo n.º 1
0
        public override void ExecuteCmdlet()
        {
            var             skuN            = new SkuName(Sku);
            PurchaseRequest PurchaseRequest = new PurchaseRequest();
            PurchaseRequestPropertiesReservedResourceProperties resourceProperties = new PurchaseRequestPropertiesReservedResourceProperties(InstanceFlexibility);

            PurchaseRequest.Location         = Location;
            PurchaseRequest.Quantity         = Quantity;
            PurchaseRequest.Renew            = Renew;
            PurchaseRequest.Term             = Term;
            PurchaseRequest.AppliedScopeType = AppliedScopeType;

            if (AppliedScope != null)
            {
                PurchaseRequest.AppliedScopes = new List <string>()
                {
                    AppliedScope
                };
            }
            PurchaseRequest.BillingScopeId             = BillingScopeId;
            PurchaseRequest.BillingPlan                = BillingPlan;
            PurchaseRequest.DisplayName                = DisplayName;
            PurchaseRequest.Sku                        = skuN;
            PurchaseRequest.ReservedResourceProperties = resourceProperties;
            PurchaseRequest.ReservedResourceType       = ReservedResourceType;

            var resourceInfo = $"Reservation order {ReservationOrderId}";

            if (ShouldProcess(resourceInfo, "Purchase"))
            {
                var response = AzureReservationAPIClient.ReservationOrder.Purchase(ReservationOrderId, PurchaseRequest);
                WriteObject(response);
            }
        }
Exemplo n.º 2
0
        public override void ExecuteCmdlet()
        {
            var skuN = new SkuName(Sku);
            PurchaseRequestPropertiesReservedResourceProperties resourceProperties = new PurchaseRequestPropertiesReservedResourceProperties(InstanceFlexibility);
            PurchaseRequest PurchaseRequest = new PurchaseRequest();

            PurchaseRequest.Location         = Location;
            PurchaseRequest.Quantity         = Quantity;
            PurchaseRequest.Renew            = Renew;
            PurchaseRequest.Term             = Term;
            PurchaseRequest.AppliedScopeType = AppliedScopeType;

            if (AppliedScope != null)
            {
                PurchaseRequest.AppliedScopes = new List <string>()
                {
                    AppliedScope
                };
            }
            PurchaseRequest.BillingScopeId             = BillingScopeId;
            PurchaseRequest.BillingPlan                = BillingPlan;
            PurchaseRequest.DisplayName                = DisplayName;
            PurchaseRequest.Sku                        = skuN;
            PurchaseRequest.ReservedResourceProperties = resourceProperties;
            PurchaseRequest.ReservedResourceType       = ReservedResourceType;

            var response = AzureReservationAPIClient.ReservationOrder.Calculate(PurchaseRequest);
            var prop     = new PSCalculatePriceResponseProperties(response.Properties);

            WriteObject(prop);
        }