示例#1
0
        public async Task <Response <ServerCommunicationLink> > GetAsync(string resourceGroupName, string serverName, string communicationLinkName, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (serverName == null)
            {
                throw new ArgumentNullException(nameof(serverName));
            }
            if (communicationLinkName == null)
            {
                throw new ArgumentNullException(nameof(communicationLinkName));
            }

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

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

                value = ServerCommunicationLink.DeserializeServerCommunicationLink(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
        public virtual ServerCommunicationLinksCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string serverName, string communicationLinkName, ServerCommunicationLink parameters, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (serverName == null)
            {
                throw new ArgumentNullException(nameof(serverName));
            }
            if (communicationLinkName == null)
            {
                throw new ArgumentNullException(nameof(communicationLinkName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

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