Ejemplo n.º 1
0
        /// <summary>
        /// Gets information about 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/GetDomain.cs.html">here</a> to see an example of how to use GetDomain API.</example>
        public async Task <GetDomainResponse> GetDomain(GetDomainRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called getDomain");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/domains/{domainId}".Trim('/')));
            HttpMethod         method         = new HttpMethod("GET");
            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 <GetDomainResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"GetDomain failed with error: {e.Message}");
                throw;
            }
        }
Ejemplo n.º 2
0
        public async Task GetDomainAsync()
        {
            var request = new GetDomainRequest()
            {
                DomainId = Domain.Id
            };
            var response = await mailinatorClient.DomainsClient.GetDomainAsync(request);

            Assert.IsTrue(response != null);
        }
        /// <summary>
        /// The endpoint fetches a specific domain
        /// </summary>
        /// <param name="request">GetDomainRequest object.</param>
        /// <returns></returns>
        public async Task <GetDomainResponse> GetDomainAsync(GetDomainRequest request)
        {
            var requestObject = httpClient.GetRequest(endpointUrl + "/{domain_id}", Method.GET);

            requestObject.AddUrlSegment("domain_id", request.DomainId);

            var response = await httpClient.ExecuteAsync <GetDomainResponse>(requestObject);

            return(response);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a waiter using the provided configuration.
        /// </summary>
        /// <param name="request">Request to send.</param>
        /// <param name="config">Wait Configuration</param>
        /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param>
        /// <returns>a new Oci.common.Waiter instance</returns>
        public Waiter <GetDomainRequest, GetDomainResponse> ForDomain(GetDomainRequest request, WaiterConfiguration config, params Domain.LifecycleStateEnum[] targetStates)
        {
            var agent = new WaiterAgent <GetDomainRequest, GetDomainResponse>(
                request,
                request => client.GetDomain(request),
                response => targetStates.Contains(response.Domain.LifecycleState.Value),
                targetStates.Contains(Domain.LifecycleStateEnum.Deleted)
                );

            return(new Waiter <GetDomainRequest, GetDomainResponse>(config, agent));
        }
        public async stt::Task GetDomainAsync_ResourceNames()
        {
            moq::Mock <ManagedIdentitiesService.ManagedIdentitiesServiceClient> mockGrpcClient = new moq::Mock <ManagedIdentitiesService.ManagedIdentitiesServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetDomainRequest request = new GetDomainRequest
            {
                DomainName = new DomainName("[PROJECT]", "[LOCATION]", "[DOMAIN]"),
            };
            Domain expectedResponse = new Domain
            {
                DomainName = new DomainName("[PROJECT]", "[LOCATION]", "[DOMAIN]"),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                AuthorizedNetworks =
                {
                    "authorized_networksfe43416a",
                },
                ReservedIpRange = "reserved_ip_range779ab299",
                Locations       =
                {
                    "locationsc7b6c0b4",
                },
                Admin         = "admin292f2321",
                Fqdn          = "fqdnc75d2ea0",
                CreateTime    = new wkt::Timestamp(),
                UpdateTime    = new wkt::Timestamp(),
                State         = Domain.Types.State.PerformingMaintenance,
                StatusMessage = "status_message2c618f86",
                Trusts        = { new Trust(), },
            };

            mockGrpcClient.Setup(x => x.GetDomainAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Domain>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ManagedIdentitiesServiceClient client = new ManagedIdentitiesServiceClientImpl(mockGrpcClient.Object, null);
            Domain responseCallSettings           = await client.GetDomainAsync(request.DomainName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Domain responseCancellationToken = await client.GetDomainAsync(request.DomainName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 6
0
        private void HandleOutput(GetDomainRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

            switch (ParameterSetName)
            {
            case LifecycleStateParamSet:
                response = client.Waiters.ForDomain(request, waiterConfig, WaitForLifecycleState).Execute();
                break;

            case Default:
                response = client.GetDomain(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Domain);
        }
Ejemplo n.º 7
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetDomainRequest request;

            try
            {
                request = new GetDomainRequest
                {
                    DomainId     = DomainId,
                    OpcRequestId = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a waiter using default wait configuration.
 /// </summary>
 /// <param name="request">Request to send.</param>
 /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param>
 /// <returns>a new Oci.common.Waiter instance</returns>
 public Waiter <GetDomainRequest, GetDomainResponse> ForDomain(GetDomainRequest request, params Domain.LifecycleStateEnum[] targetStates)
 {
     return(this.ForDomain(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }