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

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

            switch (message.Response.Status)
            {
            case 200:
            {
                NetworkVirtualAppliance 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 = NetworkVirtualAppliance.DeserializeNetworkVirtualAppliance(document.RootElement);
                }
                return(Response.FromValue(value, message.Response));
            }
Beispiel #2
0
        public virtual NetworkVirtualAppliancesCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string networkVirtualApplianceName, NetworkVirtualAppliance parameters, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (networkVirtualApplianceName == null)
            {
                throw new ArgumentNullException(nameof(networkVirtualApplianceName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

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