public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(Constants.ParameterSetNames.ObjectParameterSet))
            {
                ReservationOrderId = new Guid(Reservation[0].Name.Split('/')[0]);
                ReservationId      = Reservation.Select(x => x.Name.Split('/')[1]).Select(x => new Guid(x)).ToArray();
            }

            var resourceInfo = $"Reservation {ReservationId[0]} and {ReservationId[1]} in order {ReservationOrderId}";

            if (ShouldProcess(resourceInfo, "Merge"))
            {
                MergeRequest Merge    = new MergeRequest(ListOfResourceId());
                var          response = AzureReservationAPIClient.Reservation.Merge(ReservationOrderId.ToString(), Merge).Select(x => new PSReservation(x));
                WriteObject(response, true);
            }
        }
Exemplo n.º 2
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(Constants.ParameterSetNames.ObjectParameterSet))
            {
                string[] name = Reservation.Name.Split('/');
                ReservationOrderId = new Guid(name[0]);
                ReservationId      = new Guid(name[1]);
            }

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

            if (ShouldProcess(resourceInfo, "Split"))
            {
                var          quantityParameter = Quantity.Select(q => (int?)q).ToList();
                SplitRequest Split             = new SplitRequest(
                    quantityParameter,
                    CreateResourceId(ReservationOrderId, ReservationId)
                    );
                var response = AzureReservationAPIClient.Reservation.Split(ReservationOrderId.ToString(), Split).Select(x => new PSReservation(x)).ToList();
                WriteObject(response, true);
            }
        }
Exemplo n.º 3
0
 public override void ExecuteCmdlet()
 {
     if (ParameterSetName.Equals(Constants.ParameterSetNames.CommandParameterSet))
     {
         if (ReservationId != default(Guid))
         {
             var response = new PSReservation(AzureReservationAPIClient.Reservation.Get(ReservationId.ToString(), ReservationOrderId.ToString()));
             WriteObject(response);
         }
         else
         {
             PageResults();
         }
     }
     else if (ParameterSetName.Equals(Constants.ParameterSetNames.ObjectParameterSet))
     {
         if (ReservationOrder != null)
         {
             ReservationOrderId = new Guid(ReservationOrder.Name);
             PageResults();
         }
     }
     else if (ParameterSetName.Equals(Constants.ParameterSetNames.PageObjectParameterSet))
     {
         if (ReservationOrderPage != null)
         {
             foreach (PSReservationOrder reservationOrder in ReservationOrderPage)
             {
                 ReservationOrderId = new Guid(reservationOrder.Name);
                 PageResults();
             }
             while (ReservationOrderPage.NextPageLink != null)
             {
                 ReservationOrderPage =
                     new PSReservationOrderPage(
                         AzureReservationAPIClient.ReservationOrder.ListNext(ReservationOrderPage.NextPageLink));
                 foreach (PSReservationOrder reservationOrder in ReservationOrderPage)
                 {
                     ReservationOrderId = new Guid(reservationOrder.Name);
                     PageResults();
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
        private void PageResults()
        {
            var response = new PSReservationPage(AzureReservationAPIClient.Reservation.List(ReservationOrderId.ToString()));

            WriteObject(response, true);
            while (response.NextPageLink != null)
            {
                response = new PSReservationPage(AzureReservationAPIClient.Reservation.ListNext(response.NextPageLink));
                WriteObject(response, true);
            }
        }
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(Constants.ParameterSetNames.ObjectParameterSet))
            {
                string[] name = Reservation.Name.Split('/');
                ReservationOrderId = new Guid(name[0]);
                ReservationId      = new Guid(name[1]);
            }

            var response = new PSReservationPage(AzureReservationAPIClient.Reservation.ListRevisions(ReservationId.ToString(), ReservationOrderId.ToString()));

            WriteObject(response, true);
            while (response.NextPageLink != null)
            {
                response = new PSReservationPage(AzureReservationAPIClient.Reservation.ListNext(response.NextPageLink));
                WriteObject(response, true);
            }
        }
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(Constants.ParameterSetNames.ObjectParameterSet))
            {
                string[] name = Reservation.Name.Split('/');
                ReservationOrderId = new Guid(name[0]);
                ReservationId      = new Guid(name[1]);
            }

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

            if (ShouldProcess(resourceInfo, "Update"))
            {
                Patch Patch;
                if (AppliedScope != null)
                {
                    //Pre-register for Microsoft.Compute
                    string subscriptionId = ValidateAndGetAppliedSubscription();
                    PreRegister(subscriptionId);

                    Patch = new Patch(AppliedScopeType, new List <string>()
                    {
                        AppliedScope
                    }, InstanceFlexibility);
                }
                else
                {
                    Patch = new Patch(AppliedScopeType, instanceFlexibility: InstanceFlexibility);
                }
                var response = new PSReservation(AzureReservationAPIClient.Reservation.Update(ReservationOrderId.ToString(), ReservationId.ToString(), Patch));
                WriteObject(response);
            }
        }