Exemplo n.º 1
0
        /// <summary>
        /// Creates an application version.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CreateApplicationVersion service method.</param>
        ///
        /// <returns>The response from the CreateApplicationVersion service method, as returned by ServerlessApplicationRepository.</returns>
        /// <exception cref="Amazon.ServerlessApplicationRepository.Model.BadRequestException">
        /// One of the parameters in the request is invalid.
        /// </exception>
        /// <exception cref="Amazon.ServerlessApplicationRepository.Model.ConflictException">
        /// The resource already exists.
        /// </exception>
        /// <exception cref="Amazon.ServerlessApplicationRepository.Model.ForbiddenException">
        /// The client is not authenticated.
        /// </exception>
        /// <exception cref="Amazon.ServerlessApplicationRepository.Model.InternalServerErrorException">
        /// The AWS Serverless Application Repository service encountered an internal error.
        /// </exception>
        /// <exception cref="Amazon.ServerlessApplicationRepository.Model.TooManyRequestsException">
        /// The client is sending more than the allowed number of requests per unit time.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/serverlessrepo-2017-09-08/CreateApplicationVersion">REST API Reference for CreateApplicationVersion Operation</seealso>
        public virtual CreateApplicationVersionResponse CreateApplicationVersion(CreateApplicationVersionRequest request)
        {
            var marshaller   = CreateApplicationVersionRequestMarshaller.Instance;
            var unmarshaller = CreateApplicationVersionResponseUnmarshaller.Instance;

            return(Invoke <CreateApplicationVersionRequest, CreateApplicationVersionResponse>(request, marshaller, unmarshaller));
        }
        /// <summary>
        /// <para>Creates an application version for the specified application.</para> <para><b>NOTE:</b>Once you create an application version with a
        /// specified Amazon S3 bucket and key location, you cannot change that Amazon S3 location. If you change the Amazon S3 location, you receive an
        /// exception when you attempt to launch an environment from the application version. </para>
        /// </summary>
        ///
        /// <param name="createApplicationVersionRequest">Container for the necessary parameters to execute the CreateApplicationVersion service method
        ///           on AmazonElasticBeanstalk.</param>
        ///
        /// <returns>The response from the CreateApplicationVersion service method, as returned by AmazonElasticBeanstalk.</returns>
        ///
        /// <exception cref="TooManyApplicationsException"/>
        /// <exception cref="TooManyApplicationVersionsException"/>
        public CreateApplicationVersionResponse CreateApplicationVersion(CreateApplicationVersionRequest createApplicationVersionRequest)
        {
            IRequest <CreateApplicationVersionRequest> request  = new CreateApplicationVersionRequestMarshaller().Marshall(createApplicationVersionRequest);
            CreateApplicationVersionResponse           response = Invoke <CreateApplicationVersionRequest, CreateApplicationVersionResponse> (request, this.signer, CreateApplicationVersionResponseUnmarshaller.GetInstance());

            return(response);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initiates the asynchronous execution of the CreateApplicationVersion operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateApplicationVersion operation on AmazonServerlessApplicationRepositoryClient.</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 EndCreateApplicationVersion
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/serverlessrepo-2017-09-08/CreateApplicationVersion">REST API Reference for CreateApplicationVersion Operation</seealso>
        public virtual IAsyncResult BeginCreateApplicationVersion(CreateApplicationVersionRequest request, AsyncCallback callback, object state)
        {
            var marshaller   = new CreateApplicationVersionRequestMarshaller();
            var unmarshaller = CreateApplicationVersionResponseUnmarshaller.Instance;

            return(BeginInvoke <CreateApplicationVersionRequest>(request, marshaller, unmarshaller,
                                                                 callback, state));
        }
Exemplo n.º 4
0
        internal virtual CreateApplicationVersionResponse CreateApplicationVersion(CreateApplicationVersionRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = CreateApplicationVersionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateApplicationVersionResponseUnmarshaller.Instance;

            return(Invoke <CreateApplicationVersionResponse>(request, options));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates an application version.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CreateApplicationVersion 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 CreateApplicationVersion service method, as returned by ServerlessApplicationRepository.</returns>
        /// <exception cref="Amazon.ServerlessApplicationRepository.Model.BadRequestException">
        /// One of the parameters in the request is invalid.
        /// </exception>
        /// <exception cref="Amazon.ServerlessApplicationRepository.Model.ConflictException">
        /// The resource already exists.
        /// </exception>
        /// <exception cref="Amazon.ServerlessApplicationRepository.Model.ForbiddenException">
        /// The client is not authenticated.
        /// </exception>
        /// <exception cref="Amazon.ServerlessApplicationRepository.Model.InternalServerErrorException">
        /// The AWS Serverless Application Repository service encountered an internal error.
        /// </exception>
        /// <exception cref="Amazon.ServerlessApplicationRepository.Model.TooManyRequestsException">
        /// The client is sending more than the allowed number of requests per unit of time.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/serverlessrepo-2017-09-08/CreateApplicationVersion">REST API Reference for CreateApplicationVersion Operation</seealso>
        public virtual Task <CreateApplicationVersionResponse> CreateApplicationVersionAsync(CreateApplicationVersionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = CreateApplicationVersionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateApplicationVersionResponseUnmarshaller.Instance;

            return(InvokeAsync <CreateApplicationVersionResponse>(request, options, cancellationToken));
        }
        public IActionResult Post([FromBody] CreateApplicationVersionRequest request)
        {
            if (request == null)
            {
                return(BadRequest(new Error("No request was specified.")));
            }

            if (request.ApplicationId == Guid.Empty)
            {
                return(BadRequest(new Error("An empty application id was specified.")));
            }

            if (string.IsNullOrWhiteSpace(request.Name))
            {
                return(BadRequest(new Error("No name was specified.")));
            }

            if (string.IsNullOrWhiteSpace(request.ImageId))
            {
                return(BadRequest(new Error("No ImageId was specified.")));
            }

            using (var connection = _connectionFactory.CreateAndOpen())
                using (var transaction = connection.BeginTransaction())
                {
                    //Make sure that the application exists.
                    Application application = connection.Get <Application>(request.ApplicationId, transaction);

                    //Make sure that we found it
                    if (application == null)
                    {
                        return(NotFound($"Unable to find application with id {request.ApplicationId}."));
                    }

                    //Create the item
                    ApplicationVersion applicationVersion = new ApplicationVersion()
                    {
                        Name          = request.Name,
                        ApplicationId = request.ApplicationId,
                        ImageId       = request.ImageId,
                        Logs          = request.Logs
                    }.SetNew();

                    //Insert into the relational database
                    connection.Insert(applicationVersion, transaction);

                    //Check to see if we need to make this the current version at the application level.
                    if (request.MakeCurrent)
                    {
                        //Update the application with the latest
                        application.ApplicationVersionId = applicationVersion.Id;
                        connection.Update(application, transaction);

                        //Update the configuration for all of the devices
                        connection.SetNewDeviceConfigurationVersionForApplication(transaction, application.Id);
                    }

                    transaction.Commit();

                    return(Ok(applicationVersion));
                }
        }
Exemplo n.º 7
0
 public Task <ApplicationVersion> UploadApplicationVersionAsync(CreateApplicationVersionRequest request,
                                                                CancellationToken cancellationToken = new CancellationToken())
 {
     return(_client.MakeJsonRequestAsync <ApplicationVersion>(cancellationToken, HttpMethod.Post,
                                                              ResourceUrls.ApplicationVersions, request: request));
 }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateApplicationVersion operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateApplicationVersion 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>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/serverlessrepo-2017-09-08/CreateApplicationVersion">REST API Reference for CreateApplicationVersion Operation</seealso>
        public virtual Task <CreateApplicationVersionResponse> CreateApplicationVersionAsync(CreateApplicationVersionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new CreateApplicationVersionRequestMarshaller();
            var unmarshaller = CreateApplicationVersionResponseUnmarshaller.Instance;

            return(InvokeAsync <CreateApplicationVersionRequest, CreateApplicationVersionResponse>(request, marshaller,
                                                                                                   unmarshaller, cancellationToken));
        }
Exemplo n.º 9
0
        private async Task <int> DeployAsync(CommandContext context, IDockerClient dockerClient, BuildResult result,
                                             string tag, CancellationToken cancellationToken)
        {
            //Get the last id
            var imageId = result.Ids.LastOrDefault();

            if (string.IsNullOrWhiteSpace(imageId))
            {
                Console.Error.WriteLine("No image id was found. Unable to deploy.");

                return(1);
            }

            //Make sure we have an application name
            if (string.IsNullOrWhiteSpace(Application))
            {
                Console.Error.WriteLine("No application was specified.");
                return(1);
            }

            var application = await context.FindApplicationAsync(Application, cancellationToken);

            if (application == null)
            {
                return(1);
            }

            //Create the request
            var applicationUploadInfoRequest = new GetApplicationUploadInfoRequest()
            {
                ApplicationId = application.Id,
                ImageId       = imageId,
                Name          = tag
            };

            var applicationUploadInfo = await context.Client.ApplicationUpload.GetApplicationUploadInfo(applicationUploadInfoRequest, cancellationToken);

            if (applicationUploadInfo.CanUpload)
            {
                Console.WriteLine($"Deploying with imageid '{imageId}'...");

                var parameters = new ImagePushParameters
                {
                    ImageID = imageId,
                    Tag     = tag
                };

                string registryHost = RegistryHost ?? applicationUploadInfo.RegistryHost;

                var target = $"{registryHost}/{applicationUploadInfo.Repository}";

                //Tag it!
                await dockerClient.Images.TagImageAsync(imageId, new ImageTagParameters
                {
                    RepositoryName = target,
                    Tag            = tag
                }, cancellationToken);

                //Auth config (will have to include the token)
                var authConfig = new AuthConfig
                {
                    ServerAddress = registryHost
                };

                Console.WriteLine($"Pushing to '{registryHost}'...");

                //Push it to the application registry!
                await dockerClient.Images.PushImageAsync(target, parameters, authConfig,
                                                         new Progress <JSONMessage>(p => Console.WriteLine(p.ProgressMessage)), cancellationToken);

                //Let the service now about the new application version.
                var uploadRequest = new CreateApplicationVersionRequest
                {
                    ApplicationId = application.Id,
                    Name          = tag,
                    ImageId       = imageId,
                    Logs          = result.ToString(),
                    MakeCurrent   = MakeCurrent
                };

                //Upload the application version
                await context.Client.ApplicationVersions.UploadApplicationVersionAsync(uploadRequest, cancellationToken);
            }
            else
            {
                Console.Error.WriteLine($"Warning: Unable to upload image - '{applicationUploadInfo.Reason}'.");
            }

            return(0);
        }