public async Task <Response <ScalingPlanData> > GetAsync(string subscriptionId, string resourceGroupName, string scalingPlanName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (scalingPlanName == null)
            {
                throw new ArgumentNullException(nameof(scalingPlanName));
            }

            using var message = CreateGetRequest(subscriptionId, resourceGroupName, scalingPlanName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                ScalingPlanData value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = ScalingPlanData.DeserializeScalingPlanData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
예제 #2
0
 internal ScalingPlan(ArmClient client, ScalingPlanData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
예제 #3
0
        public virtual async Task <ArmOperation <ScalingPlanResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string scalingPlanName, ScalingPlanData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(scalingPlanName, nameof(scalingPlanName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _scalingPlanClientDiagnostics.CreateScope("ScalingPlanCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _scalingPlanRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, scalingPlanName, data, cancellationToken).ConfigureAwait(false);

                var operation = new DesktopVirtualizationArmOperation <ScalingPlanResource>(Response.FromValue(new ScalingPlanResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
예제 #4
0
        public virtual ArmOperation <ScalingPlan> CreateOrUpdate(bool waitForCompletion, string scalingPlanName, ScalingPlanData scalingPlan, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(scalingPlanName, nameof(scalingPlanName));
            Argument.AssertNotNull(scalingPlan, nameof(scalingPlan));

            using var scope = _scalingPlanClientDiagnostics.CreateScope("ScalingPlanCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _scalingPlanRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, scalingPlanName, scalingPlan, cancellationToken);
                var operation = new DesktopVirtualizationArmOperation <ScalingPlan>(Response.FromValue(new ScalingPlan(Client, response), response.GetRawResponse()));
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }