Esempio n. 1
0
        public async Task <Response <RouteFilter> > GetAsync(string resourceGroupName, string routeFilterName, string expand = null, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (routeFilterName == null)
            {
                throw new ArgumentNullException(nameof(routeFilterName));
            }

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

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

                if (document.RootElement.ValueKind == JsonValueKind.Null)
                {
                    value = null;
                }
                else
                {
                    value = RouteFilter.DeserializeRouteFilter(document.RootElement);
                }
                return(Response.FromValue(value, message.Response));
            }
Esempio n. 2
0
        public virtual RouteFiltersCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string routeFilterName, RouteFilter routeFilterParameters, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (routeFilterName == null)
            {
                throw new ArgumentNullException(nameof(routeFilterName));
            }
            if (routeFilterParameters == null)
            {
                throw new ArgumentNullException(nameof(routeFilterParameters));
            }

            using var scope = _clientDiagnostics.CreateScope("RouteFiltersOperations.StartCreateOrUpdate");
            scope.Start();
            try
            {
                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, routeFilterName, routeFilterParameters, cancellationToken);
                return(new RouteFiltersCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, routeFilterName, routeFilterParameters).Request, originalResponse));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }