示例#1
0
        public async stt::Task GetDeploymentRequestObjectAsync()
        {
            moq::Mock <Deployments.DeploymentsClient> mockGrpcClient = new moq::Mock <Deployments.DeploymentsClient>(moq::MockBehavior.Strict);
            GetDeploymentRequest request = new GetDeploymentRequest
            {
                DeploymentName = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"),
            };
            Deployment expectedResponse = new Deployment
            {
                DeploymentName           = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"),
                FlowVersionAsVersionName = VersionName.FromProjectLocationAgentFlowVersion("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[VERSION]"),
                State     = Deployment.Types.State.Succeeded,
                Result    = new Deployment.Types.Result(),
                StartTime = new wkt::Timestamp(),
                EndTime   = new wkt::Timestamp(),
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Deployment responseCancellationToken = await client.GetDeploymentAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
示例#2
0
        /// <summary>
        /// Gets the deployment info
        /// </summary>
        /// <param name="deploymentID">A deployment ID associated with the applicable IAM user or AWS account.</param>
        /// <param name="settings">The <see cref="DeploySettings"/> used during the request to AWS.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        public async Task <DeploymentInfo> GetDeploymentInfo(string deploymentID, DeploySettings settings, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (String.IsNullOrEmpty(deploymentID))
            {
                throw new ArgumentNullException("deploymentID");
            }



            // Create Request
            AmazonCodeDeployClient client  = this.CreateClient(settings);
            GetDeploymentRequest   request = new GetDeploymentRequest();

            request.DeploymentId = deploymentID;



            // Check Response
            GetDeploymentResponse response = await client.GetDeploymentAsync(request, cancellationToken);

            if (response.HttpStatusCode == HttpStatusCode.OK)
            {
                _Log.Verbose("Successfully found deployment info '{0}'", deploymentID);
                return(response.DeploymentInfo);
            }
            else
            {
                _Log.Error("Failed to get deployment info '{0}'", deploymentID);
                return(null);
            }
        }
示例#3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="request">
 /// The request object containing all of the parameters for the API call.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// The RPC response.
 /// </returns>
 public override GetDeploymentResponse GetDeployment(
     GetDeploymentRequest request,
     gaxgrpc::CallSettings callSettings = null)
 {
     Modify_GetDeploymentRequest(ref request, ref callSettings);
     return(_callGetDeployment.Sync(request, callSettings));
 }
示例#4
0
        private async Task <Deployment> GetDeployment(ObjectId id)
        {
            var request  = new GetDeploymentRequest(id);
            var response = await _mediator.Send(request).ConfigureAwait(false);

            return(response.Deployment);
        }
示例#5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="request">
 /// The request object containing all of the parameters for the API call.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// A Task containing the RPC response.
 /// </returns>
 public override stt::Task <GetDeploymentResponse> GetDeploymentAsync(
     GetDeploymentRequest request,
     gaxgrpc::CallSettings callSettings = null)
 {
     Modify_GetDeploymentRequest(ref request, ref callSettings);
     return(_callGetDeployment.Async(request, callSettings));
 }
示例#6
0
        private (Deployment deployment, NugetFeed feed) GetDeployment(ObjectId id)
        {
            var request  = new GetDeploymentRequest(id);
            var response = _mediator.Send(request).Result;

            return(response.Deployment, response.Feed);
        }
        /// <summary>
        /// Gets a deployment by identifier.
        /// </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>
        public async Task <GetDeploymentResponse> GetDeployment(GetDeploymentRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called getDeployment");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/deployments/{deploymentId}".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);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage);
                }

                return(Converter.FromHttpResponseMessage <GetDeploymentResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"GetDeployment failed with error: {e.Message}");
                throw;
            }
        }
 public static Deployment GetDeployment(GetDeploymentRequest request)
 {
     return(ExceptionHandler.HandleGrpcCall(() =>
     {
         var response = deploymentServiceClient.GetDeployment(request);
         return response.Deployment;
     }));
 }
        /// <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 <GetDeploymentRequest, GetDeploymentResponse> ForDeployment(GetDeploymentRequest request, WaiterConfiguration config, params Deployment.LifecycleStateEnum[] targetStates)
        {
            var agent = new WaiterAgent <GetDeploymentRequest, GetDeploymentResponse>(
                request,
                request => client.GetDeployment(request),
                response => targetStates.Contains(response.Deployment.LifecycleState.Value),
                targetStates.Contains(Deployment.LifecycleStateEnum.Deleted)
                );

            return(new Waiter <GetDeploymentRequest, GetDeploymentResponse>(config, agent));
        }
        public static void RemoveDeploymentTag(GetDeploymentRequest request, string tag)
        {
            ExceptionHandler.HandleGrpcCall(() =>
            {
                var deployment = GetDeployment(request);

                if (deployment.Tag.Contains(tag))
                {
                    deployment.Tag.Remove(tag);
                    UpdateDeployment(deployment);
                }
            });
        }
 /// <summary>Snippet for GetDeployment</summary>
 public void GetDeploymentRequestObject()
 {
     // Snippet: GetDeployment(GetDeploymentRequest, CallSettings)
     // Create client
     DeploymentsClient deploymentsClient = DeploymentsClient.Create();
     // Initialize request argument(s)
     GetDeploymentRequest request = new GetDeploymentRequest
     {
         DeploymentName = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"),
     };
     // Make the request
     Deployment response = deploymentsClient.GetDeployment(request);
     // End snippet
 }
 /// <summary>Snippet for GetDeployment</summary>
 public void GetDeploymentRequestObject()
 {
     // Snippet: GetDeployment(GetDeploymentRequest, CallSettings)
     // Create client
     GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.Create();
     // Initialize request argument(s)
     GetDeploymentRequest request = new GetDeploymentRequest
     {
         DeploymentName = DeploymentName.FromProjectDeployment("[PROJECT]", "[DEPLOYMENT]"),
     };
     // Make the request
     Deployment response = gSuiteAddOnsClient.GetDeployment(request);
     // End snippet
 }
        public static void SetMaxWorkerCapacity(GetDeploymentRequest request, string workerType, int maxWorkerCapacity)
        {
            ExceptionHandler.HandleGrpcCall(() =>
            {
                var deployment = GetDeployment(request);
                foreach (var workerCapacity in deployment.WorkerConnectionCapacities)
                {
                    if (workerCapacity.WorkerType == workerType)
                    {
                        workerCapacity.MaxCapacity = maxWorkerCapacity;
                    }
                }

                UpdateDeployment(deployment);
            });
        }
        public static int GetCurrentWorkerCapacity(GetDeploymentRequest request, string workerType)
        {
            return(ExceptionHandler.HandleGrpcCall(() =>
            {
                var deployment = GetDeployment(request);
                foreach (var workerCapacity in deployment.WorkerConnectionCapacities)
                {
                    if (workerCapacity.WorkerType == workerType)
                    {
                        return workerCapacity.MaxCapacity - workerCapacity.RemainingCapacity;
                    }
                }

                throw new ArgumentException($"Couldn't find worker type {workerType} in deployment {deployment.Name}");
            }));
        }
        /// <summary>Snippet for GetDeploymentAsync</summary>
        public async Task GetDeploymentRequestObjectAsync()
        {
            // Snippet: GetDeploymentAsync(GetDeploymentRequest, CallSettings)
            // Additional: GetDeploymentAsync(GetDeploymentRequest, CancellationToken)
            // Create client
            GSuiteAddOnsClient gSuiteAddOnsClient = await GSuiteAddOnsClient.CreateAsync();

            // Initialize request argument(s)
            GetDeploymentRequest request = new GetDeploymentRequest
            {
                DeploymentName = DeploymentName.FromProjectDeployment("[PROJECT]", "[DEPLOYMENT]"),
            };
            // Make the request
            Deployment response = await gSuiteAddOnsClient.GetDeploymentAsync(request);

            // End snippet
        }
        public static void AddDeploymentTags(GetDeploymentRequest request, IEnumerable <string> tags)
        {
            ExceptionHandler.HandleGrpcCall(() =>
            {
                var deployment = GetDeployment(request);

                foreach (var tag in tags)
                {
                    if (!deployment.Tag.Contains(tag))
                    {
                        deployment.Tag.Add(tag);
                    }
                }

                UpdateDeployment(deployment);
            });
        }
        /// <summary>Snippet for GetDeploymentAsync</summary>
        public async Task GetDeploymentRequestObjectAsync()
        {
            // Snippet: GetDeploymentAsync(GetDeploymentRequest, CallSettings)
            // Additional: GetDeploymentAsync(GetDeploymentRequest, CancellationToken)
            // Create client
            DeploymentsClient deploymentsClient = await DeploymentsClient.CreateAsync();

            // Initialize request argument(s)
            GetDeploymentRequest request = new GetDeploymentRequest
            {
                DeploymentName = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"),
            };
            // Make the request
            Deployment response = await deploymentsClient.GetDeploymentAsync(request);

            // End snippet
        }
 public static void UpdateDeploymentTag(GetDeploymentRequest request, string tagPrefix, string tagValue)
 {
     ExceptionHandler.HandleGrpcCall(() =>
     {
         var deployment = GetDeployment(request);
         var tags       = deployment.Tag.ToList();
         foreach (var tag in tags)
         {
             if (tag.StartsWith(tagPrefix))
             {
                 deployment.Tag.Remove(tag);
             }
         }
         deployment.Tag.Add($"{tagPrefix}_{tagValue}");
         UpdateDeployment(deployment);
     });
 }
示例#19
0
        private void HandleOutput(GetDeploymentRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

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

            case Default:
                response = client.GetDeployment(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Deployment);
        }
示例#20
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetDeploymentRequest request;

            try
            {
                request = new GetDeploymentRequest
                {
                    DeploymentId = DeploymentId,
                    OpcRequestId = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
示例#21
0
        internal static GetDeploymentResponse GetDeployment(string deploymentId, string region)
        {
            try
            {
                GetDeploymentRequest request = new GetDeploymentRequest()
                {
                    DeploymentId = deploymentId
                };

                AmazonCodeDeployClient client = string.IsNullOrEmpty(region) ?
                                                new AmazonCodeDeployClient() :
                                                new AmazonCodeDeployClient(RegionEndpoint.GetBySystemName(region));

                Task <GetDeploymentResponse> response = client.GetDeploymentAsync(request);
                Task.WaitAll(new Task[] { response });

                return(response.Result);
            }
            catch (System.Exception e)
            {
                Log.Error($"{e.GetBaseException().GetType().Name}: {e.Message}");
                return(null);
            }
        }
示例#22
0
        public void GetDeployment()
        {
            moq::Mock <Deployments.DeploymentsClient> mockGrpcClient = new moq::Mock <Deployments.DeploymentsClient>(moq::MockBehavior.Strict);
            GetDeploymentRequest request = new GetDeploymentRequest
            {
                DeploymentName = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"),
            };
            Deployment expectedResponse = new Deployment
            {
                DeploymentName           = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"),
                FlowVersionAsVersionName = VersionName.FromProjectLocationAgentFlowVersion("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[VERSION]"),
                State     = Deployment.Types.State.Succeeded,
                Result    = new Deployment.Types.Result(),
                StartTime = new wkt::Timestamp(),
                EndTime   = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.GetDeployment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            DeploymentsClient client   = new DeploymentsClientImpl(mockGrpcClient.Object, null);
            Deployment        response = client.GetDeployment(request.Name);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
示例#23
0
 public SpatialOSReceiveHandler(Connection connection, GetDeploymentRequest request)
 {
     this.connection = connection;
     this.request    = request;
     SetupHandlers();
 }
示例#24
0
        private void UpdatePlayerCount(GetDeploymentRequest getDeploymentRequest)
        {
            var playerCount = DeploymentModifier.GetCurrentWorkerCapacity(getDeploymentRequest, sessionConfig.ClientType);

            DeploymentModifier.UpdateDeploymentTag(getDeploymentRequest, Tags.Players, playerCount.ToString());
        }
 /// <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 <GetDeploymentRequest, GetDeploymentResponse> ForDeployment(GetDeploymentRequest request, params Deployment.LifecycleStateEnum[] targetStates)
 {
     return(this.ForDeployment(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }
 /// <summary>
 /// Retrieves the specified [Deployment][google.cloud.dialogflow.cx.v3.Deployment].
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual Deployment GetDeployment(GetDeploymentRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
 /// <summary>
 /// Retrieves the specified [Deployment][google.cloud.dialogflow.cx.v3.Deployment].
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <Deployment> GetDeploymentAsync(GetDeploymentRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
 /// <summary>
 /// Retrieves the specified [Deployment][google.cloud.dialogflow.cx.v3.Deployment].
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <Deployment> GetDeploymentAsync(GetDeploymentRequest request, st::CancellationToken cancellationToken) =>
 GetDeploymentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
 partial void Modify_GetDeploymentRequest(ref GetDeploymentRequest request, ref gaxgrpc::CallSettings settings);