public async Task <Response <CapacityReservationData> > GetAsync(string subscriptionId, string resourceGroupName, string capacityReservationGroupName, string capacityReservationName, CapacityReservationInstanceViewTypes?expand = null, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (capacityReservationGroupName == null)
            {
                throw new ArgumentNullException(nameof(capacityReservationGroupName));
            }
            if (capacityReservationName == null)
            {
                throw new ArgumentNullException(nameof(capacityReservationName));
            }

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

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

                value = CapacityReservationData.DeserializeCapacityReservationData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Пример #2
0
        CapacityReservation IOperationSource <CapacityReservation> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = CapacityReservationData.DeserializeCapacityReservationData(document.RootElement);

            return(new CapacityReservation(_client, data));
        }