Container for the parameters to the DescribeServices operation. Describes the specified services running in your cluster.
Inheritance: AmazonECSRequest
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.ECS.Model.DescribeServicesRequest();

            if (cmdletContext.Cluster != null)
            {
                request.Cluster = cmdletContext.Cluster;
            }
            if (cmdletContext.Include != null)
            {
                request.Include = cmdletContext.Include;
            }
            if (cmdletContext.Service != null)
            {
                request.Services = cmdletContext.Service;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeServices operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeServices operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<DescribeServicesResponse> DescribeServicesAsync(DescribeServicesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DescribeServicesRequestMarshaller();
            var unmarshaller = DescribeServicesResponseUnmarshaller.Instance;

            return InvokeAsync<DescribeServicesRequest,DescribeServicesResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        /// <summary>
        /// Describes the specified services running in your cluster.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the DescribeServices service method.</param>
        /// 
        /// <returns>The response from the DescribeServices service method, as returned by ECS.</returns>
        /// <exception cref="Amazon.ECS.Model.ClientException">
        /// These errors are usually caused by something the client did, such as use an action
        /// or resource on behalf of a user that doesn't have permission to use the action or
        /// resource, or specify an identifier that is not valid.
        /// </exception>
        /// <exception cref="Amazon.ECS.Model.ClusterNotFoundException">
        /// The specified cluster could not be found. You can view your available clusters with
        /// <a>ListClusters</a>. Amazon ECS clusters are region-specific.
        /// </exception>
        /// <exception cref="Amazon.ECS.Model.InvalidParameterException">
        /// The specified parameter is invalid. Review the available parameters for the API request.
        /// </exception>
        /// <exception cref="Amazon.ECS.Model.ServerException">
        /// These errors are usually caused by a server-side issue.
        /// </exception>
        public DescribeServicesResponse DescribeServices(DescribeServicesRequest request)
        {
            var marshaller = new DescribeServicesRequestMarshaller();
            var unmarshaller = DescribeServicesResponseUnmarshaller.Instance;

            return Invoke<DescribeServicesRequest,DescribeServicesResponse>(request, marshaller, unmarshaller);
        }
Esempio n. 4
0
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeServices operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeServices operation on AmazonECSClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDescribeServices
        ///         operation.</returns>
        public IAsyncResult BeginDescribeServices(DescribeServicesRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new DescribeServicesRequestMarshaller();
            var unmarshaller = DescribeServicesResponseUnmarshaller.Instance;

            return BeginInvoke<DescribeServicesRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 private Amazon.ECS.Model.DescribeServicesResponse CallAWSServiceOperation(IAmazonECS client, Amazon.ECS.Model.DescribeServicesRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon EC2 Container Service", "DescribeServices");
     try
     {
         #if DESKTOP
         return(client.DescribeServices(request));
         #elif CORECLR
         return(client.DescribeServicesAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
        private async Task<bool> PerformRollingServiceDeployment(
            string cluster, string serviceName, string taskRevision)
        {
            var describeRequest = new DescribeServicesRequest
            {
                Cluster = cluster,
                Services = new List<string> { serviceName}
            };
            var originalService = (await this.ECSClient.DescribeServicesAsync(describeRequest)).Services[0];

            int totalTasks = originalService.DesiredCount;

            Console.Write("Reducing the number of tasks to {0} for existing definition...", totalTasks / 2);
            await this.ECSClient.UpdateServiceAsync(new UpdateServiceRequest
            {
                Cluster = cluster,
                Service = serviceName,
                DesiredCount = totalTasks / 2
            });
            if (!await WaitTillUpdateServiceComplete(describeRequest))
            {
                Console.Error.WriteLine("\nECS Cluster did not reduce the number of existing tasks.");
                return false;
            }
            Console.WriteLine("Complete");

            Console.Write("Starting {0} task(s) with new definition...", totalTasks / 2);
            await this.ECSClient.UpdateServiceAsync(new UpdateServiceRequest
            {
                Cluster = cluster,
                Service = serviceName,
                TaskDefinition = taskRevision,
                DesiredCount = totalTasks / 2
            });
            if (!await WaitTillUpdateServiceComplete(describeRequest))
            {
                Console.Error.WriteLine("\nECS Cluster did not start tasks with new task definition.");
                return false;
            }
            Console.WriteLine("Complete");

            Console.Write("Starting remaining tasks with new task definition...");
            await this.ECSClient.UpdateServiceAsync(new UpdateServiceRequest
            {
                Cluster = cluster,
                Service = serviceName,
                DesiredCount = totalTasks
            });
            if (!await WaitTillUpdateServiceComplete(describeRequest))
            {
                Console.Error.WriteLine("\nECS Cluster did not start tasks with new task definition.");
                return false;
            }
            Console.WriteLine("Complete with {0} total tasks", totalTasks);

            return true;
        }
        private async Task<bool> WaitTillUpdateServiceComplete(DescribeServicesRequest describeRequest)
        {
            long start = DateTime.Now.Ticks;
            Service service = null;
            do
            {
                Thread.Sleep(1000);
                service = (await this.ECSClient.DescribeServicesAsync(describeRequest)).Services[0];
            } while (   service.Deployments.Count != 1 && 
                        TimeSpan.FromTicks(DateTime.Now.Ticks - start).TotalMinutes < 2);

            if(service.Deployments.Count != 1)
            {
                return false;
            }

            return true;
        }