/// <summary> /// Initiates the asynchronous execution of the UpdateService operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UpdateService 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<UpdateServiceResponse> UpdateServiceAsync(UpdateServiceRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new UpdateServiceRequestMarshaller(); var unmarshaller = UpdateServiceResponseUnmarshaller.Instance; return InvokeAsync<UpdateServiceRequest,UpdateServiceResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Modify the desired count or task definition used in a service. /// /// /// <para> /// You can add to or subtract from the number of instantiations of a task definition /// in a service by specifying the cluster that the service is running in and a new <code>desiredCount</code> /// parameter. /// </para> /// /// <para> /// You can use <code>UpdateService</code> to modify your task definition and deploy a /// new version of your service, one task at a time. If you modify the task definition /// with <code>UpdateService</code>, Amazon ECS spawns a task with the new version of /// the task definition and then stops an old task after the new version is running. Because /// <code>UpdateService</code> starts a new version of the task before stopping an old /// version, your cluster must have capacity to support one more instantiation of the /// task when <code>UpdateService</code> is run. If your cluster cannot support another /// instantiation of the task used in your service, you can reduce the desired count of /// your service by one before modifying the task definition. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the UpdateService service method.</param> /// /// <returns>The response from the UpdateService 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> /// <exception cref="Amazon.ECS.Model.ServiceNotActiveException"> /// The specified service is not active. You cannot update a service that is not active. /// If you have previously deleted a service, you can recreate it with <a>CreateService</a>. /// </exception> /// <exception cref="Amazon.ECS.Model.ServiceNotFoundException"> /// The specified service could not be found. You can view your available services with /// <a>ListServices</a>. Amazon ECS services are cluster-specific and region-specific. /// </exception> public UpdateServiceResponse UpdateService(UpdateServiceRequest request) { var marshaller = new UpdateServiceRequestMarshaller(); var unmarshaller = UpdateServiceResponseUnmarshaller.Instance; return Invoke<UpdateServiceRequest,UpdateServiceResponse>(request, marshaller, unmarshaller); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.ECS.Model.UpdateServiceRequest(); if (cmdletContext.CapacityProviderStrategy != null) { request.CapacityProviderStrategy = cmdletContext.CapacityProviderStrategy; } if (cmdletContext.Cluster != null) { request.Cluster = cmdletContext.Cluster; } // populate DeploymentConfiguration var requestDeploymentConfigurationIsNull = true; request.DeploymentConfiguration = new Amazon.ECS.Model.DeploymentConfiguration(); System.Int32?requestDeploymentConfiguration_deploymentConfiguration_MaximumPercent = null; if (cmdletContext.DeploymentConfiguration_MaximumPercent != null) { requestDeploymentConfiguration_deploymentConfiguration_MaximumPercent = cmdletContext.DeploymentConfiguration_MaximumPercent.Value; } if (requestDeploymentConfiguration_deploymentConfiguration_MaximumPercent != null) { request.DeploymentConfiguration.MaximumPercent = requestDeploymentConfiguration_deploymentConfiguration_MaximumPercent.Value; requestDeploymentConfigurationIsNull = false; } System.Int32?requestDeploymentConfiguration_deploymentConfiguration_MinimumHealthyPercent = null; if (cmdletContext.DeploymentConfiguration_MinimumHealthyPercent != null) { requestDeploymentConfiguration_deploymentConfiguration_MinimumHealthyPercent = cmdletContext.DeploymentConfiguration_MinimumHealthyPercent.Value; } if (requestDeploymentConfiguration_deploymentConfiguration_MinimumHealthyPercent != null) { request.DeploymentConfiguration.MinimumHealthyPercent = requestDeploymentConfiguration_deploymentConfiguration_MinimumHealthyPercent.Value; requestDeploymentConfigurationIsNull = false; } // determine if request.DeploymentConfiguration should be set to null if (requestDeploymentConfigurationIsNull) { request.DeploymentConfiguration = null; } if (cmdletContext.DesiredCount != null) { request.DesiredCount = cmdletContext.DesiredCount.Value; } if (cmdletContext.ForceNewDeployment != null) { request.ForceNewDeployment = cmdletContext.ForceNewDeployment.Value; } if (cmdletContext.HealthCheckGracePeriodSecond != null) { request.HealthCheckGracePeriodSeconds = cmdletContext.HealthCheckGracePeriodSecond.Value; } // populate NetworkConfiguration var requestNetworkConfigurationIsNull = true; request.NetworkConfiguration = new Amazon.ECS.Model.NetworkConfiguration(); Amazon.ECS.Model.AwsVpcConfiguration requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration = null; // populate AwsvpcConfiguration var requestNetworkConfiguration_networkConfiguration_AwsvpcConfigurationIsNull = true; requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration = new Amazon.ECS.Model.AwsVpcConfiguration(); Amazon.ECS.AssignPublicIp requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_AssignPublicIp = null; if (cmdletContext.AwsvpcConfiguration_AssignPublicIp != null) { requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_AssignPublicIp = cmdletContext.AwsvpcConfiguration_AssignPublicIp; } if (requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_AssignPublicIp != null) { requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration.AssignPublicIp = requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_AssignPublicIp; requestNetworkConfiguration_networkConfiguration_AwsvpcConfigurationIsNull = false; } List <System.String> requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_SecurityGroup = null; if (cmdletContext.AwsvpcConfiguration_SecurityGroup != null) { requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_SecurityGroup = cmdletContext.AwsvpcConfiguration_SecurityGroup; } if (requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_SecurityGroup != null) { requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration.SecurityGroups = requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_SecurityGroup; requestNetworkConfiguration_networkConfiguration_AwsvpcConfigurationIsNull = false; } List <System.String> requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_Subnet = null; if (cmdletContext.AwsvpcConfiguration_Subnet != null) { requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_Subnet = cmdletContext.AwsvpcConfiguration_Subnet; } if (requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_Subnet != null) { requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration.Subnets = requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_Subnet; requestNetworkConfiguration_networkConfiguration_AwsvpcConfigurationIsNull = false; } // determine if requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration should be set to null if (requestNetworkConfiguration_networkConfiguration_AwsvpcConfigurationIsNull) { requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration = null; } if (requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration != null) { request.NetworkConfiguration.AwsvpcConfiguration = requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration; requestNetworkConfigurationIsNull = false; } // determine if request.NetworkConfiguration should be set to null if (requestNetworkConfigurationIsNull) { request.NetworkConfiguration = null; } if (cmdletContext.PlatformVersion != null) { request.PlatformVersion = cmdletContext.PlatformVersion; } if (cmdletContext.Service != null) { request.Service = cmdletContext.Service; } if (cmdletContext.TaskDefinition != null) { request.TaskDefinition = cmdletContext.TaskDefinition; } 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); }
private Amazon.ECS.Model.UpdateServiceResponse CallAWSServiceOperation(IAmazonECS client, Amazon.ECS.Model.UpdateServiceRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon EC2 Container Service", "UpdateService"); try { #if DESKTOP return(client.UpdateService(request)); #elif CORECLR return(client.UpdateServiceAsync(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; } }
/// <summary> /// Initiates the asynchronous execution of the UpdateService operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UpdateService 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 EndUpdateService /// operation.</returns> public IAsyncResult BeginUpdateService(UpdateServiceRequest request, AsyncCallback callback, object state) { var marshaller = new UpdateServiceRequestMarshaller(); var unmarshaller = UpdateServiceResponseUnmarshaller.Instance; return BeginInvoke<UpdateServiceRequest>(request, marshaller, unmarshaller, callback, state); }