/// <summary>
        /// <para> Launches an environment for the specified application using the specified configuration. </para>
        /// </summary>
        ///
        /// <param name="createEnvironmentRequest">Container for the necessary parameters to execute the CreateEnvironment service method on
        ///           AmazonElasticBeanstalk.</param>
        ///
        /// <returns>The response from the CreateEnvironment service method, as returned by AmazonElasticBeanstalk.</returns>
        ///
        /// <exception cref="TooManyEnvironmentsException"/>
        public CreateEnvironmentResponse CreateEnvironment(CreateEnvironmentRequest createEnvironmentRequest)
        {
            IRequest <CreateEnvironmentRequest> request  = new CreateEnvironmentRequestMarshaller().Marshall(createEnvironmentRequest);
            CreateEnvironmentResponse           response = Invoke <CreateEnvironmentRequest, CreateEnvironmentResponse> (request, this.signer, CreateEnvironmentResponseUnmarshaller.GetInstance());

            return(response);
        }
Esempio n. 2
0
        public async stt::Task CreateEnvironmentRequestObjectAsync()
        {
            moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict);
            CreateEnvironmentRequest request = new CreateEnvironmentRequest
            {
                ParentAsAgentName = AgentName.FromProject("[PROJECT]"),
                Environment       = new Environment(),
                EnvironmentId     = "environment_id26e3069e",
            };
            Environment expectedResponse = new Environment
            {
                EnvironmentName      = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"),
                Description          = "description2cf9da67",
                AgentVersion         = "agent_versioncd5f59a0",
                State                = Environment.Types.State.Loading,
                UpdateTime           = new wkt::Timestamp(),
                TextToSpeechSettings = new TextToSpeechSettings(),
                Fulfillment          = new Fulfillment(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 3
0
        public void CreateEnvironmentRequestObject()
        {
            moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict);
            CreateEnvironmentRequest request = new CreateEnvironmentRequest
            {
                ParentAsAgentName = AgentName.FromProject("[PROJECT]"),
                Environment       = new Environment(),
                EnvironmentId     = "environment_id26e3069e",
            };
            Environment expectedResponse = new Environment
            {
                EnvironmentName           = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"),
                Description               = "description2cf9da67",
                AgentVersionAsVersionName = VersionName.FromProjectVersion("[PROJECT]", "[VERSION]"),
                State                = Environment.Types.State.Loading,
                UpdateTime           = new wkt::Timestamp(),
                TextToSpeechSettings = new TextToSpeechSettings(),
                Fulfillment          = new Fulfillment(),
            };

            mockGrpcClient.Setup(x => x.CreateEnvironment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EnvironmentsClient client   = new EnvironmentsClientImpl(mockGrpcClient.Object, null);
            Environment        response = client.CreateEnvironment(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 4
0
        public ModelEnvironment CreateEnvironment(CreateEnvironmentRequest body)
        {
            if (body == null)
            {
                throw new ArgumentNullException(nameof(body));
            }

            if (string.IsNullOrEmpty(VersionDate))
            {
                throw new ArgumentNullException("versionDate cannot be null. Use 'DISCOVERY_VERSION_DATE_2016_12_01'");
            }

            ModelEnvironment result = null;

            try
            {
                result = this.Client.WithAuthentication(this.UserName, this.Password)
                         .PostAsync($"{this.Endpoint}/v1/environments")
                         .WithArgument("version", VersionDate)
                         .WithBody <CreateEnvironmentRequest>(body)
                         .As <ModelEnvironment>()
                         .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
        public void CreateEnvironment()
        {
            CreateEnvironmentRequest createEnvironmentRequest = new CreateEnvironmentRequest()
            {
                Name        = _createdEnvironmentName,
                Description = _createdEnvironmentDescription,
                Size        = _createdEnvironmentSize
            };

            Console.WriteLine(string.Format("\nCalling CreateEnvironment()..."));
            var result = _discovery.CreateEnvironment(createEnvironmentRequest);

            if (result != null)
            {
                if (result != null)
                {
                    Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
                }
                else
                {
                    Console.WriteLine("result is null.");
                }

                _createdEnvironmentId = result.EnvironmentId;
            }
            else
            {
                Console.WriteLine("result is null.");
            }
        }
Esempio n. 6
0
        /// <summary>Snippet for CreateEnvironmentAsync</summary>
        public async Task CreateEnvironmentRequestObjectAsync()
        {
            // Snippet: CreateEnvironmentAsync(CreateEnvironmentRequest, CallSettings)
            // Additional: CreateEnvironmentAsync(CreateEnvironmentRequest, CancellationToken)
            // Create client
            EnvironmentsClient environmentsClient = await EnvironmentsClient.CreateAsync();

            // Initialize request argument(s)
            CreateEnvironmentRequest request = new CreateEnvironmentRequest
            {
                Parent      = "",
                Environment = new gcoasv::Environment(),
            };
            // Make the request
            Operation <gcoasv::Environment, OperationMetadata> response = await environmentsClient.CreateEnvironmentAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <gcoasv::Environment, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            gcoasv::Environment result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <gcoasv::Environment, OperationMetadata> retrievedResponse = await environmentsClient.PollOnceCreateEnvironmentAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                gcoasv::Environment retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Esempio n. 7
0
        internal virtual CreateEnvironmentResponse CreateEnvironment(CreateEnvironmentRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = CreateEnvironmentRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateEnvironmentResponseUnmarshaller.Instance;

            return(Invoke <CreateEnvironmentResponse>(request, options));
        }
Esempio n. 8
0
        /// <summary>
        /// Initiates the asynchronous execution of the CreateEnvironment operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateEnvironment operation on AmazonFinspaceClient.</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 EndCreateEnvironment
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/finspace-2021-03-12/CreateEnvironment">REST API Reference for CreateEnvironment Operation</seealso>
        public virtual IAsyncResult BeginCreateEnvironment(CreateEnvironmentRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = CreateEnvironmentRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateEnvironmentResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
Esempio n. 9
0
        /// <summary>
        /// Creates an Amazon Managed Workflows for Apache Airflow (MWAA) environment.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CreateEnvironment service method.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the CreateEnvironment service method, as returned by MWAA.</returns>
        /// <exception cref="Amazon.MWAA.Model.InternalServerException">
        /// InternalServerException: An internal error has occurred.
        /// </exception>
        /// <exception cref="Amazon.MWAA.Model.ValidationException">
        /// ValidationException: The provided input is not valid.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mwaa-2020-07-01/CreateEnvironment">REST API Reference for CreateEnvironment Operation</seealso>
        public virtual Task <CreateEnvironmentResponse> CreateEnvironmentAsync(CreateEnvironmentRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = CreateEnvironmentRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateEnvironmentResponseUnmarshaller.Instance;

            return(InvokeAsync <CreateEnvironmentResponse>(request, options, cancellationToken));
        }
Esempio n. 10
0
        public void CreateEnvironmentRequestModel()
        {
            var request = new CreateEnvironmentRequest(1, "a");

            Assert.Equal("a", request.Name);
            Assert.Equal(1, request.OwnerId);

            Assert.Throws <ArgumentException>(() => new CreateEnvironmentRequest(1, ""));
            Assert.Throws <ArgumentOutOfRangeException>(() => new CreateEnvironmentRequest(-1, "a"));
        }
Esempio n. 11
0
 internal static void CreateNewEnvironment(AdminCenterClient adminCenterClient, string newEnvironmentName, string environmentType, string countryCode)
 {
     var createEnvironmentRequest = new CreateEnvironmentRequest
     {
         CountryCode = countryCode,
         EnvironmentType = environmentType
     };
     Microsoft.Dynamics.BusinessCentral.AdminCenter.Models.Environment newEnvironment = adminCenterClient.CreateEnvironment("BusinessCentral", newEnvironmentName, createEnvironmentRequest);
     Utils.ConsoleWriteLineAsJson(newEnvironment);
 }
Esempio n. 12
0
 public async Task Create()
 {
     var request = new CreateEnvironmentRequest
     {
         ApplicationName   = application.Name,
         EnvironmentName   = name,
         SolutionStackName = "64bit Windows Server 2016 v1.2.0 running IIS 10.0"
     };
     await client.CreateEnvironmentAsync(request);
 }
Esempio n. 13
0
        /// <summary>
        /// 用于在用户账户下创建消息队列 Tdmq环境(命名空间)
        /// </summary>
        /// <param name="req"><see cref="CreateEnvironmentRequest"/></param>
        /// <returns><see cref="CreateEnvironmentResponse"/></returns>
        public CreateEnvironmentResponse CreateEnvironmentSync(CreateEnvironmentRequest req)
        {
            JsonResponseModel <CreateEnvironmentResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "CreateEnvironment");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <CreateEnvironmentResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
Esempio n. 14
0
        public Environment CreateEnvironment(CreateEnvironmentRequest body)
        {
            try
            {
                var result = DiscoveryRepository.CreateEnvironment(body);

                return(result);
            }
            catch (Exception ex)
            {
                Logger.Error("DiscoveryService.CreateEnvironment failed", this, ex);
            }

            return(null);
        }
 /// <summary>Snippet for CreateEnvironment</summary>
 public void CreateEnvironmentRequestObject()
 {
     // Snippet: CreateEnvironment(CreateEnvironmentRequest, CallSettings)
     // Create client
     EnvironmentsClient environmentsClient = EnvironmentsClient.Create();
     // Initialize request argument(s)
     CreateEnvironmentRequest request = new CreateEnvironmentRequest
     {
         ParentAsAgentName = AgentName.FromProject("[PROJECT]"),
         Environment       = new gcdv::Environment(),
         EnvironmentId     = "",
     };
     // Make the request
     gcdv::Environment response = environmentsClient.CreateEnvironment(request);
     // End snippet
 }
        /// <summary>Snippet for CreateEnvironmentAsync</summary>
        public async Task CreateEnvironmentRequestObjectAsync()
        {
            // Snippet: CreateEnvironmentAsync(CreateEnvironmentRequest, CallSettings)
            // Additional: CreateEnvironmentAsync(CreateEnvironmentRequest, CancellationToken)
            // Create client
            EnvironmentsClient environmentsClient = await EnvironmentsClient.CreateAsync();

            // Initialize request argument(s)
            CreateEnvironmentRequest request = new CreateEnvironmentRequest
            {
                ParentAsAgentName = AgentName.FromProject("[PROJECT]"),
                Environment       = new gcdv::Environment(),
                EnvironmentId     = "",
            };
            // Make the request
            gcdv::Environment response = await environmentsClient.CreateEnvironmentAsync(request);

            // End snippet
        }
Esempio n. 17
0
        private async Task <string> CreateEnvironment(string application, string environment, string versionLabel)
        {
            var createRequest = new CreateEnvironmentRequest
            {
                ApplicationName   = application,
                EnvironmentName   = environment,
                VersionLabel      = versionLabel,
                SolutionStackName = this.GetSolutionStackOrDefault(this.DeployEnvironmentOptions.SolutionStack, EBDefinedCommandOptions.ARGUMENT_SOLUTION_STACK, true),
                CNAMEPrefix       = this.GetStringValueOrDefault(this.DeployEnvironmentOptions.CNamePrefix, EBDefinedCommandOptions.ARGUMENT_CNAME_PREFIX, false)
            };

            var environmentType = this.GetStringValueOrDefault(this.DeployEnvironmentOptions.EnvironmentType, EBDefinedCommandOptions.ARGUMENT_ENVIRONMENT_TYPE, false);

            if (!string.IsNullOrEmpty(environmentType))
            {
                createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
                {
                    Namespace  = "aws:elasticbeanstalk:environment",
                    OptionName = "EnvironmentType",
                    Value      = environmentType
                });
            }

            var healthCheckURl = this.GetStringValueOrDefault(this.DeployEnvironmentOptions.HealthCheckUrl, EBDefinedCommandOptions.ARGUMENT_HEALTH_CHECK_URL, false);

            if (!string.IsNullOrEmpty(healthCheckURl))
            {
                createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
                {
                    Namespace  = "aws:elasticbeanstalk:application",
                    OptionName = "Application Healthcheck URL",
                    Value      = healthCheckURl
                });
            }

            var ec2KeyPair = this.GetStringValueOrDefault(this.DeployEnvironmentOptions.EC2KeyPair, EBDefinedCommandOptions.ARGUMENT_EC2_KEYPAIR, false);

            if (!string.IsNullOrEmpty(ec2KeyPair))
            {
                createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
                {
                    Namespace  = "aws:autoscaling:launchconfiguration",
                    OptionName = "EC2KeyName",
                    Value      = ec2KeyPair
                });
            }

            var instanceType = this.GetStringValueOrDefault(this.DeployEnvironmentOptions.InstanceType, EBDefinedCommandOptions.ARGUMENT_INSTANCE_TYPE, false);

            if (string.IsNullOrEmpty(instanceType))
            {
                instanceType = "t2.small";
            }

            createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
            {
                Namespace  = "aws:autoscaling:launchconfiguration",
                OptionName = "InstanceType",
                Value      = instanceType
            });

            var instanceProfile = this.GetInstanceProfileOrDefault(this.DeployEnvironmentOptions.InstanceProfile, EBDefinedCommandOptions.ARGUMENT_INSTANCE_PROFILE, true, string.Format("eb_{0}_{1}", application, environment));

            if (!string.IsNullOrEmpty(instanceProfile))
            {
                createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
                {
                    Namespace  = "aws:autoscaling:launchconfiguration",
                    OptionName = "IamInstanceProfile",
                    Value      = instanceProfile
                });
            }

            var serviceRole = this.GetServiceRoleOrCreateIt(this.DeployEnvironmentOptions.ServiceRole, EBDefinedCommandOptions.ARGUMENT_SERVICE_ROLE,
                                                            "aws-elasticbeanstalk-ec2-role", Constants.EC2_ASSUME_ROLE_POLICY, null, "AWSElasticBeanstalkWebTier", "AWSElasticBeanstalkMulticontainerDocker", "AWSElasticBeanstalkWorkerTier");

            if (!string.IsNullOrEmpty(serviceRole))
            {
                createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
                {
                    Namespace  = "aws:elasticbeanstalk:environment",
                    OptionName = "ServiceRole",
                    Value      = serviceRole
                });
            }

            AddAdditionalOptions(createRequest.OptionSettings);

            var tags = ConvertToTagsCollection();

            if (tags != null && tags.Count > 0)
            {
                createRequest.Tags = tags;
            }

            try
            {
                var createResponse = await this.EBClient.CreateEnvironmentAsync(createRequest);

                return(createResponse.EnvironmentArn);
            }
            catch (Exception e)
            {
                throw new ElasticBeanstalkExceptions("Error creating environment: " + e.Message, ElasticBeanstalkExceptions.EBCode.FailedToCreateEnvironment);
            }
        }
        private async Task <string> CreateEnvironment(string application, string environment, string versionLabel, bool isWindowsEnvironment)
        {
            var createRequest = new CreateEnvironmentRequest
            {
                ApplicationName   = application,
                EnvironmentName   = environment,
                VersionLabel      = versionLabel,
                SolutionStackName = this.GetSolutionStackOrDefault(this.DeployEnvironmentOptions.SolutionStack, EBDefinedCommandOptions.ARGUMENT_SOLUTION_STACK, true),
                CNAMEPrefix       = this.GetStringValueOrDefault(this.DeployEnvironmentOptions.CNamePrefix, EBDefinedCommandOptions.ARGUMENT_CNAME_PREFIX, false)
            };

            string environmentType, loadBalancerType;

            DetermineEnvironment(out environmentType, out loadBalancerType);

            if (!string.IsNullOrEmpty(environmentType))
            {
                createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
                {
                    Namespace  = "aws:elasticbeanstalk:environment",
                    OptionName = "EnvironmentType",
                    Value      = environmentType
                });
            }

            var ec2KeyPair = this.GetStringValueOrDefault(this.DeployEnvironmentOptions.EC2KeyPair, EBDefinedCommandOptions.ARGUMENT_EC2_KEYPAIR, false);

            if (!string.IsNullOrEmpty(ec2KeyPair))
            {
                createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
                {
                    Namespace  = "aws:autoscaling:launchconfiguration",
                    OptionName = "EC2KeyName",
                    Value      = ec2KeyPair
                });
            }

            var instanceType = this.GetStringValueOrDefault(this.DeployEnvironmentOptions.InstanceType, EBDefinedCommandOptions.ARGUMENT_INSTANCE_TYPE, false);

            if (string.IsNullOrEmpty(instanceType))
            {
                instanceType = isWindowsEnvironment ? EBConstants.DEFAULT_WINDOWS_INSTANCE_TYPE : EBConstants.DEFAULT_LINUX_INSTANCE_TYPE;
            }


            createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
            {
                Namespace  = "aws:autoscaling:launchconfiguration",
                OptionName = "InstanceType",
                Value      = instanceType
            });

            var instanceProfile = this.GetInstanceProfileOrDefault(this.DeployEnvironmentOptions.InstanceProfile, EBDefinedCommandOptions.ARGUMENT_INSTANCE_PROFILE, true, string.Format("eb_{0}_{1}", application, environment));

            if (!string.IsNullOrEmpty(instanceProfile))
            {
                int pos = instanceProfile.LastIndexOf('/');
                if (pos != -1)
                {
                    instanceProfile = instanceProfile.Substring(pos + 1);
                }

                createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
                {
                    Namespace  = "aws:autoscaling:launchconfiguration",
                    OptionName = "IamInstanceProfile",
                    Value      = instanceProfile
                });
            }

            var serviceRole = this.GetServiceRoleOrCreateIt(this.DeployEnvironmentOptions.ServiceRole, EBDefinedCommandOptions.ARGUMENT_SERVICE_ROLE,
                                                            "aws-elasticbeanstalk-service-role", Constants.ELASTICBEANSTALK_ASSUME_ROLE_POLICY, null, "AWSElasticBeanstalkService", "AWSElasticBeanstalkEnhancedHealth");

            if (!string.IsNullOrEmpty(serviceRole))
            {
                int pos = serviceRole.LastIndexOf('/');
                if (pos != -1)
                {
                    serviceRole = serviceRole.Substring(pos + 1);
                }

                createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
                {
                    Namespace  = "aws:elasticbeanstalk:environment",
                    OptionName = "ServiceRole",
                    Value      = serviceRole
                });
            }

            if (!string.IsNullOrWhiteSpace(loadBalancerType))
            {
                if (!EBConstants.ValidLoadBalancerType.Contains(loadBalancerType))
                {
                    throw new ElasticBeanstalkExceptions($"The loadbalancer type {loadBalancerType} is invalid. Valid values are: {string.Join(", ", EBConstants.ValidLoadBalancerType)}", ElasticBeanstalkExceptions.EBCode.InvalidLoadBalancerType);
                }

                createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
                {
                    Namespace  = "aws:elasticbeanstalk:environment",
                    OptionName = "LoadBalancerType",
                    Value      = loadBalancerType
                });
            }


            AddAdditionalOptions(createRequest.OptionSettings, true, isWindowsEnvironment);

            var tags = ConvertToTagsCollection();

            if (tags != null && tags.Count > 0)
            {
                createRequest.Tags = tags;
            }

            try
            {
                var createResponse = await this.EBClient.CreateEnvironmentAsync(createRequest);

                return(createResponse.EnvironmentArn);
            }
            catch (Exception e)
            {
                throw new ElasticBeanstalkExceptions("Error creating environment: " + e.Message, ElasticBeanstalkExceptions.EBCode.FailedToCreateEnvironment);
            }
        }