Пример #1
0
        /// <summary>
        /// Updates the domain.
        /// </summary>
        /// <param name="request">The request object containing the details to send. Required.</param>
        /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param>
        /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param>
        /// <returns>A response object containing details about the completed operation</returns>
        /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/tenantmanagercontrolplane/UpdateDomain.cs.html">here</a> to see an example of how to use UpdateDomain API.</example>
        public async Task <UpdateDomainResponse> UpdateDomain(UpdateDomainRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called updateDomain");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/domains/{domainId}".Trim('/')));
            HttpMethod         method         = new HttpMethod("PUT");
            HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request);

            requestMessage.Headers.Add("Accept", "application/json");
            GenericRetrier      retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration);
            HttpResponseMessage responseMessage;

            try
            {
                if (retryingClient != null)
                {
                    responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false);
                }
                this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage);

                return(Converter.FromHttpResponseMessage <UpdateDomainResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"UpdateDomain failed with error: {e.Message}");
                throw;
            }
        }
Пример #2
0
        public async Task Base_Domain()
        {
            await SyncContext.ClearAsync;

            // Exercise the Cadence domain operations.

            //-----------------------------------------------------------------
            // RegisterDomain:

            await Assert.ThrowsAsync <ArgumentNullException>(async() => await client.RegisterDomainAsync(name: null));

            await Assert.ThrowsAsync <ArgumentException>(async() => await client.RegisterDomainAsync(name: "domain-0", retentionDays: -1));

            await client.RegisterDomainAsync("domain-0", "this is domain-0", "*****@*****.**", retentionDays : 14);

            await Assert.ThrowsAsync <DomainAlreadyExistsException>(async() => await client.RegisterDomainAsync(name: "domain-0"));

            //-----------------------------------------------------------------
            // DescribeDomain:

            var domainDescribeReply = await client.DescribeDomainAsync("domain-0");

            Assert.False(domainDescribeReply.Configuration.EmitMetrics);
            Assert.Equal(14, domainDescribeReply.Configuration.RetentionDays);
            Assert.Equal("domain-0", domainDescribeReply.DomainInfo.Name);
            Assert.Equal("this is domain-0", domainDescribeReply.DomainInfo.Description);
            Assert.Equal("*****@*****.**", domainDescribeReply.DomainInfo.OwnerEmail);
            Assert.Equal(DomainStatus.Registered, domainDescribeReply.DomainInfo.Status);

            await Assert.ThrowsAsync <EntityNotExistsException>(async() => await client.DescribeDomainAsync("does-not-exist"));

            //-----------------------------------------------------------------
            // UpdateDomain:

            var updateDomainRequest = new UpdateDomainRequest();

            updateDomainRequest.Options.EmitMetrics    = true;
            updateDomainRequest.Options.RetentionDays  = 77;
            updateDomainRequest.DomainInfo.OwnerEmail  = "*****@*****.**";
            updateDomainRequest.DomainInfo.Description = "new description";

            await client.UpdateDomainAsync("domain-0", updateDomainRequest);

            domainDescribeReply = await client.DescribeDomainAsync("domain-0");

            Assert.True(domainDescribeReply.Configuration.EmitMetrics);
            Assert.Equal(77, domainDescribeReply.Configuration.RetentionDays);
            Assert.Equal("domain-0", domainDescribeReply.DomainInfo.Name);
            Assert.Equal("new description", domainDescribeReply.DomainInfo.Description);
            Assert.Equal("*****@*****.**", domainDescribeReply.DomainInfo.OwnerEmail);
            Assert.Equal(DomainStatus.Registered, domainDescribeReply.DomainInfo.Status);

            await Assert.ThrowsAsync <EntityNotExistsException>(async() => await client.UpdateDomainAsync("does-not-exist", updateDomainRequest));
        }
Пример #3
0
        /// <inheritdoc/>
        public Domain UpdateDomain(string domainId, string domainName = null, string email = null, int?ttl = null, string description = null, int?gslb = null, string region = null, CloudIdentity identity = null)
        {
            if (domainId == null)
            {
                throw new ArgumentNullException("domainId");
            }
            if (string.IsNullOrEmpty(domainId))
            {
                throw new ArgumentException("domainId cannot be empty");
            }
            if (!string.IsNullOrEmpty(domainName) && !domainName.EndsWith("."))
            {
                throw new ArgumentException("domainName must ends with period(.)");
            }
            if (ttl.HasValue && ttl < 3600)
            {
                throw new ArgumentOutOfRangeException("ttl must be 3600 and more");
            }
            if (gslb.HasValue && (gslb != 0 && gslb != 1))
            {
                throw new ArgumentException("gslb must be 0 or 1");
            }
            CheckIdentity(identity);

            var urlPath = new Uri(string.Format("{0}/v1/domains/{1}", GetServiceEndpoint(identity, region), domainId));

            var request = new UpdateDomainRequest(domainName, email, ttl, description, gslb);

            var response = ExecuteRESTRequest <Domain>(identity, urlPath, HttpMethod.PUT, request);

            if (response == null || response.Data == null)
            {
                return(null);
            }

            return(response.Data);
        }
Пример #4
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateDomainRequest request;

            try
            {
                request = new UpdateDomainRequest
                {
                    DomainId            = DomainId,
                    UpdateDomainDetails = UpdateDomainDetails,
                    IfMatch             = IfMatch,
                    OpcRequestId        = OpcRequestId
                };

                response = client.UpdateDomain(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Domain);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Пример #5
0
        public async Task Base_Domain()
        {
            await SyncContext.Clear;

            // Exercise the Cadence domain operations.

            //-----------------------------------------------------------------
            // RegisterDomain:

            await Assert.ThrowsAsync <ArgumentNullException>(async() => await client.RegisterDomainAsync(name: null));

            await Assert.ThrowsAsync <ArgumentException>(async() => await client.RegisterDomainAsync(name: "domain-0", retentionDays: -1));

            await client.RegisterDomainAsync("domain-0", "this is domain-0", "*****@*****.**", retentionDays : 14);

            await Assert.ThrowsAsync <DomainAlreadyExistsException>(async() => await client.RegisterDomainAsync(name: "domain-0"));

            //-----------------------------------------------------------------
            // DescribeDomain:

            var domainDescribeReply = await client.DescribeDomainAsync("domain-0");

            Assert.False(domainDescribeReply.Configuration.EmitMetrics);
            Assert.Equal(14, domainDescribeReply.Configuration.RetentionDays);
            Assert.Equal("domain-0", domainDescribeReply.DomainInfo.Name);
            Assert.Equal("this is domain-0", domainDescribeReply.DomainInfo.Description);
            Assert.Equal("*****@*****.**", domainDescribeReply.DomainInfo.OwnerEmail);
            Assert.Equal(DomainStatus.Registered, domainDescribeReply.DomainInfo.Status);

            await Assert.ThrowsAsync <EntityNotExistsException>(async() => await client.DescribeDomainAsync("does-not-exist"));

            //-----------------------------------------------------------------
            // UpdateDomain:

            // NOTE: Cadence seems to require some time between creating and then updating
            //       a domain.  We're seeing a:
            //
            //          ServiceBusyException("The domain failovers too frequent.")
            //
            //       when this happens.  We'll mitigate this by adding a long delay here.

            await Task.Delay(TimeSpan.FromSeconds(60));

            var updateDomainRequest = new UpdateDomainRequest();

            updateDomainRequest.Options.EmitMetrics    = true;
            updateDomainRequest.Options.RetentionDays  = 77;
            updateDomainRequest.DomainInfo.OwnerEmail  = "*****@*****.**";
            updateDomainRequest.DomainInfo.Description = "new description";

            await client.UpdateDomainAsync("domain-0", updateDomainRequest);

            domainDescribeReply = await client.DescribeDomainAsync("domain-0");

            Assert.True(domainDescribeReply.Configuration.EmitMetrics);
            Assert.Equal(77, domainDescribeReply.Configuration.RetentionDays);
            Assert.Equal("domain-0", domainDescribeReply.DomainInfo.Name);
            Assert.Equal("new description", domainDescribeReply.DomainInfo.Description);
            Assert.Equal("*****@*****.**", domainDescribeReply.DomainInfo.OwnerEmail);
            Assert.Equal(DomainStatus.Registered, domainDescribeReply.DomainInfo.Status);

            await Assert.ThrowsAsync <EntityNotExistsException>(async() => await client.UpdateDomainAsync("does-not-exist", updateDomainRequest));
        }
Пример #6
0
 /// <summary>
 ///  更新网站
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public async Task <UpdateDomainResponse> UpdateDomain(UpdateDomainRequest request)
 {
     return(await new UpdateDomainExecutor().Client(this).Execute <UpdateDomainResponse, UpdateDomainResult, UpdateDomainRequest>(request).ConfigureAwait(false));
 }
Пример #7
0
 /// <summary>
 ///  更新网站
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public UpdateDomainResponse UpdateDomain(UpdateDomainRequest request)
 {
     return(new UpdateDomainExecutor().Client(this).Execute <UpdateDomainResponse, UpdateDomainResult, UpdateDomainRequest>(request));
 }
Пример #8
0
 /// <remarks/>
 public void UpdateDomainAsync(UpdateDomainRequest UpdateDomainRequest, object userState) {
     if ((this.UpdateDomainOperationCompleted == null)) {
         this.UpdateDomainOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateDomainOperationCompleted);
     }
     this.InvokeAsync("UpdateDomain", new object[] {
                 UpdateDomainRequest}, this.UpdateDomainOperationCompleted, userState);
 }
Пример #9
0
 /// <remarks/>
 public void UpdateDomainAsync(UpdateDomainRequest UpdateDomainRequest) {
     this.UpdateDomainAsync(UpdateDomainRequest, null);
 }