AfdEndpoint IOperationSource <AfdEndpoint> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = AfdEndpointData.DeserializeAfdEndpointData(document.RootElement);

            return(new AfdEndpoint(_operationBase, data));
        }
Exemple #2
0
        protected async Task <AfdEndpoint> CreateAfdEndpoint(Profile profile, string endpointName)
        {
            AfdEndpointData input = ResourceDataHelper.CreateAfdEndpointData();
            var             lro   = await profile.GetAfdEndpoints().CreateOrUpdateAsync(true, endpointName, input);

            return(lro.Value);
        }
        internal static AfdEndpointListResult DeserializeAfdEndpointListResult(JsonElement element)
        {
            Optional <IReadOnlyList <AfdEndpointData> > value = default;
            Optional <string> nextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <AfdEndpointData> array = new List <AfdEndpointData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(AfdEndpointData.DeserializeAfdEndpointData(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new AfdEndpointListResult(Optional.ToList(value), nextLink.Value));
        }