public async Task CreateCluster() { var request = new CreateClusterRequest { ClusterName = _context.Settings.Cluster.Name }; await _client.CreateClusterAsync(request); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.ECS.Model.CreateClusterRequest(); if (cmdletContext.CapacityProvider != null) { request.CapacityProviders = cmdletContext.CapacityProvider; } if (cmdletContext.ClusterName != null) { request.ClusterName = cmdletContext.ClusterName; } if (cmdletContext.DefaultCapacityProviderStrategy != null) { request.DefaultCapacityProviderStrategy = cmdletContext.DefaultCapacityProviderStrategy; } if (cmdletContext.Setting != null) { request.Settings = cmdletContext.Setting; } if (cmdletContext.Tag != null) { request.Tags = cmdletContext.Tag; } 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 CreateCluster operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateCluster 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<CreateClusterResponse> CreateClusterAsync(CreateClusterRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateClusterRequestMarshaller(); var unmarshaller = CreateClusterResponseUnmarshaller.Instance; return InvokeAsync<CreateClusterRequest,CreateClusterResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Creates a new Amazon ECS cluster. By default, your account will receive a <code>default</code> /// cluster when you launch your first container instance. However, you can create your /// own cluster with a unique name with the <code>CreateCluster</code> action. /// </summary> /// <param name="request">Container for the necessary parameters to execute the CreateCluster service method.</param> /// /// <returns>The response from the CreateCluster 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.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 CreateClusterResponse CreateCluster(CreateClusterRequest request) { var marshaller = new CreateClusterRequestMarshaller(); var unmarshaller = CreateClusterResponseUnmarshaller.Instance; return Invoke<CreateClusterRequest,CreateClusterResponse>(request, marshaller, unmarshaller); }
private Amazon.ECS.Model.CreateClusterResponse CallAWSServiceOperation(IAmazonECS client, Amazon.ECS.Model.CreateClusterRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon EC2 Container Service", "CreateCluster"); try { #if DESKTOP return(client.CreateCluster(request)); #elif CORECLR return(client.CreateClusterAsync(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; } }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.ECS.Model.CreateClusterRequest(); if (cmdletContext.CapacityProvider != null) { request.CapacityProviders = cmdletContext.CapacityProvider; } if (cmdletContext.ClusterName != null) { request.ClusterName = cmdletContext.ClusterName; } // populate Configuration var requestConfigurationIsNull = true; request.Configuration = new Amazon.ECS.Model.ClusterConfiguration(); Amazon.ECS.Model.ExecuteCommandConfiguration requestConfiguration_configuration_ExecuteCommandConfiguration = null; // populate ExecuteCommandConfiguration var requestConfiguration_configuration_ExecuteCommandConfigurationIsNull = true; requestConfiguration_configuration_ExecuteCommandConfiguration = new Amazon.ECS.Model.ExecuteCommandConfiguration(); System.String requestConfiguration_configuration_ExecuteCommandConfiguration_executeCommandConfiguration_KmsKeyId = null; if (cmdletContext.ExecuteCommandConfiguration_KmsKeyId != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_executeCommandConfiguration_KmsKeyId = cmdletContext.ExecuteCommandConfiguration_KmsKeyId; } if (requestConfiguration_configuration_ExecuteCommandConfiguration_executeCommandConfiguration_KmsKeyId != null) { requestConfiguration_configuration_ExecuteCommandConfiguration.KmsKeyId = requestConfiguration_configuration_ExecuteCommandConfiguration_executeCommandConfiguration_KmsKeyId; requestConfiguration_configuration_ExecuteCommandConfigurationIsNull = false; } Amazon.ECS.ExecuteCommandLogging requestConfiguration_configuration_ExecuteCommandConfiguration_executeCommandConfiguration_Logging = null; if (cmdletContext.ExecuteCommandConfiguration_Logging != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_executeCommandConfiguration_Logging = cmdletContext.ExecuteCommandConfiguration_Logging; } if (requestConfiguration_configuration_ExecuteCommandConfiguration_executeCommandConfiguration_Logging != null) { requestConfiguration_configuration_ExecuteCommandConfiguration.Logging = requestConfiguration_configuration_ExecuteCommandConfiguration_executeCommandConfiguration_Logging; requestConfiguration_configuration_ExecuteCommandConfigurationIsNull = false; } Amazon.ECS.Model.ExecuteCommandLogConfiguration requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration = null; // populate LogConfiguration var requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfigurationIsNull = true; requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration = new Amazon.ECS.Model.ExecuteCommandLogConfiguration(); System.Boolean?requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_CloudWatchEncryptionEnabled = null; if (cmdletContext.LogConfiguration_CloudWatchEncryptionEnabled != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_CloudWatchEncryptionEnabled = cmdletContext.LogConfiguration_CloudWatchEncryptionEnabled.Value; } if (requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_CloudWatchEncryptionEnabled != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration.CloudWatchEncryptionEnabled = requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_CloudWatchEncryptionEnabled.Value; requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfigurationIsNull = false; } System.String requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_CloudWatchLogGroupName = null; if (cmdletContext.LogConfiguration_CloudWatchLogGroupName != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_CloudWatchLogGroupName = cmdletContext.LogConfiguration_CloudWatchLogGroupName; } if (requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_CloudWatchLogGroupName != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration.CloudWatchLogGroupName = requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_CloudWatchLogGroupName; requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfigurationIsNull = false; } System.String requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3BucketName = null; if (cmdletContext.LogConfiguration_S3BucketName != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3BucketName = cmdletContext.LogConfiguration_S3BucketName; } if (requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3BucketName != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration.S3BucketName = requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3BucketName; requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfigurationIsNull = false; } System.Boolean?requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3EncryptionEnabled = null; if (cmdletContext.LogConfiguration_S3EncryptionEnabled != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3EncryptionEnabled = cmdletContext.LogConfiguration_S3EncryptionEnabled.Value; } if (requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3EncryptionEnabled != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration.S3EncryptionEnabled = requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3EncryptionEnabled.Value; requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfigurationIsNull = false; } System.String requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3KeyPrefix = null; if (cmdletContext.LogConfiguration_S3KeyPrefix != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3KeyPrefix = cmdletContext.LogConfiguration_S3KeyPrefix; } if (requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3KeyPrefix != null) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration.S3KeyPrefix = requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration_logConfiguration_S3KeyPrefix; requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfigurationIsNull = false; } // determine if requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration should be set to null if (requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfigurationIsNull) { requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration = null; } if (requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration != null) { requestConfiguration_configuration_ExecuteCommandConfiguration.LogConfiguration = requestConfiguration_configuration_ExecuteCommandConfiguration_configuration_ExecuteCommandConfiguration_LogConfiguration; requestConfiguration_configuration_ExecuteCommandConfigurationIsNull = false; } // determine if requestConfiguration_configuration_ExecuteCommandConfiguration should be set to null if (requestConfiguration_configuration_ExecuteCommandConfigurationIsNull) { requestConfiguration_configuration_ExecuteCommandConfiguration = null; } if (requestConfiguration_configuration_ExecuteCommandConfiguration != null) { request.Configuration.ExecuteCommandConfiguration = requestConfiguration_configuration_ExecuteCommandConfiguration; requestConfigurationIsNull = false; } // determine if request.Configuration should be set to null if (requestConfigurationIsNull) { request.Configuration = null; } if (cmdletContext.DefaultCapacityProviderStrategy != null) { request.DefaultCapacityProviderStrategy = cmdletContext.DefaultCapacityProviderStrategy; } if (cmdletContext.Setting != null) { request.Settings = cmdletContext.Setting; } if (cmdletContext.Tag != null) { request.Tags = cmdletContext.Tag; } 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 CreateCluster operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateCluster 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 EndCreateCluster /// operation.</returns> public IAsyncResult BeginCreateCluster(CreateClusterRequest request, AsyncCallback callback, object state) { var marshaller = new CreateClusterRequestMarshaller(); var unmarshaller = CreateClusterResponseUnmarshaller.Instance; return BeginInvoke<CreateClusterRequest>(request, marshaller, unmarshaller, callback, state); }