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

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

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

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