Exemplo n.º 1
0
        GatewayResource IOperationSource <GatewayResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = GatewayResourceData.DeserializeGatewayResourceData(document.RootElement);

            return(new GatewayResource(_client, data));
        }
Exemplo n.º 2
0
        public async Task <Response <GatewayResourceData> > GetAsync(string subscriptionId, string resourceGroupName, string serviceName, string gatewayName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName));
            Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName));

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

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

                value = GatewayResourceData.DeserializeGatewayResourceData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }