public async Task <Response <VirtualRouter> > GetAsync(string resourceGroupName, string virtualRouterName, string expand = null, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (virtualRouterName == null)
            {
                throw new ArgumentNullException(nameof(virtualRouterName));
            }

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

            switch (message.Response.Status)
            {
            case 200:
            {
                VirtualRouter 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 = VirtualRouter.DeserializeVirtualRouter(document.RootElement);
                }
                return(Response.FromValue(value, message.Response));
            }
Exemplo n.º 2
0
        public virtual VirtualRoutersCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string virtualRouterName, VirtualRouter parameters, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (virtualRouterName == null)
            {
                throw new ArgumentNullException(nameof(virtualRouterName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

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