Ejemplo n.º 1
0
 internal UpdateDomain(ArmResource options, UpdateDomainData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _restClient        = new CloudServicesUpdateDomainRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
 }
Ejemplo n.º 2
0
        public async Task <Response <UpdateDomainData> > GetUpdateDomainAsync(string resourceGroupName, string cloudServiceName, string updateDomain, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (cloudServiceName == null)
            {
                throw new ArgumentNullException(nameof(cloudServiceName));
            }
            if (updateDomain == null)
            {
                throw new ArgumentNullException(nameof(updateDomain));
            }

            using var message = CreateGetUpdateDomainRequest(resourceGroupName, cloudServiceName, updateDomain);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

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

                value = UpdateDomainData.DeserializeUpdateDomainData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Ejemplo n.º 3
0
        public async Task <Response> WalkUpdateDomainAsync(string resourceGroupName, string cloudServiceName, string updateDomain, UpdateDomainData parameters = null, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (cloudServiceName == null)
            {
                throw new ArgumentNullException(nameof(cloudServiceName));
            }
            if (updateDomain == null)
            {
                throw new ArgumentNullException(nameof(updateDomain));
            }

            using var message = CreateWalkUpdateDomainRequest(resourceGroupName, cloudServiceName, updateDomain, parameters);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            case 202:
                return(message.Response);

            default:
                throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }
Ejemplo n.º 4
0
        internal HttpMessage CreateWalkUpdateDomainRequest(string resourceGroupName, string cloudServiceName, string updateDomain, UpdateDomainData parameters)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();

            uri.Reset(endpoint);
            uri.AppendPath("/subscriptions/", false);
            uri.AppendPath(subscriptionId, true);
            uri.AppendPath("/resourceGroups/", false);
            uri.AppendPath(resourceGroupName, true);
            uri.AppendPath("/providers/Microsoft.Compute/cloudServices/", false);
            uri.AppendPath(cloudServiceName, true);
            uri.AppendPath("/updateDomains/", false);
            uri.AppendPath(updateDomain, true);
            uri.AppendQuery("api-version", "2021-03-01", true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            if (parameters != null)
            {
                request.Headers.Add("Content-Type", "application/json");
                var content = new Utf8JsonRequestContent();
                content.JsonWriter.WriteObjectValue(parameters);
                request.Content = content;
            }
            message.SetProperty("UserAgentOverride", _userAgent);
            return(message);
        }
Ejemplo n.º 5
0
 public virtual CloudServicesUpdateDomainWalkUpdateDomainOperation WalkUpdateDomain(UpdateDomainData parameters = null, bool waitForCompletion = true, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("UpdateDomain.WalkUpdateDomain");
     scope.Start();
     try
     {
         var response  = _restClient.WalkUpdateDomain(Id.ResourceGroupName, Id.Parent.Name, Id.Name, parameters, cancellationToken);
         var operation = new CloudServicesUpdateDomainWalkUpdateDomainOperation(_clientDiagnostics, Pipeline, _restClient.CreateWalkUpdateDomainRequest(Id.ResourceGroupName, Id.Parent.Name, Id.Name, parameters).Request, response);
         if (waitForCompletion)
         {
             operation.WaitForCompletion(cancellationToken);
         }
         return(operation);
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }