예제 #1
0
        ScVmmAvailabilitySetResource IOperationSource <ScVmmAvailabilitySetResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = ScVmmAvailabilitySetData.DeserializeScVmmAvailabilitySetData(document.RootElement);

            return(new ScVmmAvailabilitySetResource(_client, data));
        }
        public async Task <Response <ScVmmAvailabilitySetData> > GetAsync(string subscriptionId, string resourceGroupName, string availabilitySetName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(availabilitySetName, nameof(availabilitySetName));

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

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

                value = ScVmmAvailabilitySetData.DeserializeScVmmAvailabilitySetData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
예제 #3
0
        public virtual async Task <ArmOperation <ScVmmAvailabilitySetResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string availabilitySetName, ScVmmAvailabilitySetData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(availabilitySetName, nameof(availabilitySetName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _scVmmAvailabilitySetAvailabilitySetsClientDiagnostics.CreateScope("ScVmmAvailabilitySetCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _scVmmAvailabilitySetAvailabilitySetsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, availabilitySetName, data, cancellationToken).ConfigureAwait(false);

                var operation = new ArcScVmmArmOperation <ScVmmAvailabilitySetResource>(new ScVmmAvailabilitySetOperationSource(Client), _scVmmAvailabilitySetAvailabilitySetsClientDiagnostics, Pipeline, _scVmmAvailabilitySetAvailabilitySetsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, availabilitySetName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 internal ScVmmAvailabilitySetResource(ArmClient client, ScVmmAvailabilitySetData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }