VirtualNetworkRuleResource IOperationSource <VirtualNetworkRuleResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = VirtualNetworkRuleData.DeserializeVirtualNetworkRuleData(document.RootElement);

            return(new VirtualNetworkRuleResource(_client, data));
        }
Exemplo n.º 2
0
        public async Task <Response <VirtualNetworkRuleData> > GetAsync(string subscriptionId, string resourceGroupName, string serverName, string virtualNetworkRuleName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (serverName == null)
            {
                throw new ArgumentNullException(nameof(serverName));
            }
            if (virtualNetworkRuleName == null)
            {
                throw new ArgumentNullException(nameof(virtualNetworkRuleName));
            }

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

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

                value = VirtualNetworkRuleData.DeserializeVirtualNetworkRuleData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }