Container for the parameters to the SwapEnvironmentCNAMEs operation.

Swaps the CNAMEs of two environments.

Inheritance: AmazonElasticBeanstalkRequest
Exemplo n.º 1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.ElasticBeanstalk.Model.SwapEnvironmentCNAMEsRequest();

            if (cmdletContext.DestinationEnvironmentId != null)
            {
                request.DestinationEnvironmentId = cmdletContext.DestinationEnvironmentId;
            }
            if (cmdletContext.DestinationEnvironmentName != null)
            {
                request.DestinationEnvironmentName = cmdletContext.DestinationEnvironmentName;
            }
            if (cmdletContext.SourceEnvironmentId != null)
            {
                request.SourceEnvironmentId = cmdletContext.SourceEnvironmentId;
            }
            if (cmdletContext.SourceEnvironmentName != null)
            {
                request.SourceEnvironmentName = cmdletContext.SourceEnvironmentName;
            }

            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 SwapEnvironmentCNAMEs operation.
 /// <seealso cref="Amazon.ElasticBeanstalk.AmazonElasticBeanstalk.SwapEnvironmentCNAMEs"/>
 /// </summary>
 /// 
 /// <param name="swapEnvironmentCNAMEsRequest">Container for the necessary parameters to execute the SwapEnvironmentCNAMEs operation on
 ///          AmazonElasticBeanstalk.</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>
 public IAsyncResult BeginSwapEnvironmentCNAMEs(SwapEnvironmentCNAMEsRequest swapEnvironmentCNAMEsRequest, AsyncCallback callback, object state)
 {
     return invokeSwapEnvironmentCNAMEs(swapEnvironmentCNAMEsRequest, callback, state, false);
 }
 IAsyncResult invokeSwapEnvironmentCNAMEs(SwapEnvironmentCNAMEsRequest swapEnvironmentCNAMEsRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new SwapEnvironmentCNAMEsRequestMarshaller().Marshall(swapEnvironmentCNAMEsRequest);
     var unmarshaller = SwapEnvironmentCNAMEsResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
 /// <summary>
 /// <para> Swaps the CNAMEs of two environments. </para>
 /// </summary>
 /// 
 /// <param name="swapEnvironmentCNAMEsRequest">Container for the necessary parameters to execute the SwapEnvironmentCNAMEs service method on
 ///          AmazonElasticBeanstalk.</param>
 /// 
 public SwapEnvironmentCNAMEsResponse SwapEnvironmentCNAMEs(SwapEnvironmentCNAMEsRequest swapEnvironmentCNAMEsRequest)
 {
     IAsyncResult asyncResult = invokeSwapEnvironmentCNAMEs(swapEnvironmentCNAMEsRequest, null, null, true);
     return EndSwapEnvironmentCNAMEs(asyncResult);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the SwapEnvironmentCNAMEs operation.
        /// <seealso cref="Amazon.ElasticBeanstalk.IAmazonElasticBeanstalk"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the SwapEnvironmentCNAMEs 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<SwapEnvironmentCNAMEsResponse> SwapEnvironmentCNAMEsAsync(SwapEnvironmentCNAMEsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new SwapEnvironmentCNAMEsRequestMarshaller();
            var unmarshaller = SwapEnvironmentCNAMEsResponseUnmarshaller.Instance;

            return InvokeAsync<SwapEnvironmentCNAMEsRequest,SwapEnvironmentCNAMEsResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        internal SwapEnvironmentCNAMEsResponse SwapEnvironmentCNAMEs(SwapEnvironmentCNAMEsRequest request)
        {
            var marshaller = new SwapEnvironmentCNAMEsRequestMarshaller();
            var unmarshaller = SwapEnvironmentCNAMEsResponseUnmarshaller.Instance;

            return Invoke<SwapEnvironmentCNAMEsRequest,SwapEnvironmentCNAMEsResponse>(request, marshaller, unmarshaller);
        }
  /// <summary>
  /// </summary>
  /// 
  /// <param name="swapEnvironmentCNAMEsRequest">Container for the necessary parameters to execute the SwapEnvironmentCNAMEs service method on
  ///           AmazonElasticBeanstalk.</param>
  /// 
 public SwapEnvironmentCNAMEsResponse SwapEnvironmentCNAMEs(SwapEnvironmentCNAMEsRequest swapEnvironmentCNAMEsRequest) 
 {           
     IRequest<SwapEnvironmentCNAMEsRequest> request = new SwapEnvironmentCNAMEsRequestMarshaller().Marshall(swapEnvironmentCNAMEsRequest);
     SwapEnvironmentCNAMEsResponse response = Invoke<SwapEnvironmentCNAMEsRequest, SwapEnvironmentCNAMEsResponse> (request, this.signer, SwapEnvironmentCNAMEsResponseUnmarshaller.GetInstance());
     return response;
 }
        /// <summary>
        /// <para> Swaps the CNAMEs of two environments. </para>
        /// </summary>
        /// 
        /// <param name="swapEnvironmentCNAMEsRequest">Container for the necessary parameters to execute the SwapEnvironmentCNAMEs service method on
        /// AmazonElasticBeanstalk.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<SwapEnvironmentCNAMEsResponse> SwapEnvironmentCNAMEsAsync(SwapEnvironmentCNAMEsRequest swapEnvironmentCNAMEsRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new SwapEnvironmentCNAMEsRequestMarshaller();
            var unmarshaller = SwapEnvironmentCNAMEsResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, SwapEnvironmentCNAMEsRequest, SwapEnvironmentCNAMEsResponse>(swapEnvironmentCNAMEsRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
		internal SwapEnvironmentCNAMEsResponse SwapEnvironmentCNAMEs(SwapEnvironmentCNAMEsRequest request)
        {
            var task = SwapEnvironmentCNAMEsAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
        public async Task SwapEnvironmentCnamesAsync()
        {
            using (var ebClient = new AmazonElasticBeanstalkClient(creds, configurationProvider.RegionEndpoint))
            {
                loggerProvider.GetLogger().Debug("Swapping Environment CNAMEs...");
                var describeEnvironmentsResponse = await ebClient.DescribeEnvironmentsAsync();
                var current = describeEnvironmentsResponse.Environments
                    .SingleOrDefault(env =>
                        env?.CNAME != null && env.CNAME.StartsWith(currentCNamePrefix, StringComparison.CurrentCultureIgnoreCase) &&
                        env.Status == EnvironmentStatus.Ready);
                var next = describeEnvironmentsResponse.Environments
                    .SingleOrDefault(env =>
                        env?.CNAME != null && env.CNAME.StartsWith(nextCNamePrefix, StringComparison.CurrentCultureIgnoreCase) &&
                        env.Status == EnvironmentStatus.Ready);

                if (current == null)
                {
                    var environments = JsonConvert.SerializeObject(describeEnvironmentsResponse.Environments);
                    var msg = $"Error state: On environment CNAME swap, could not find environment with CNAME: {currentCNamePrefix} in a READY state. Environments: {environments}";
                    loggerProvider.GetLogger().Error(msg);
                    throw new ElasticBeanstalkDeployerException(msg);
                }
                if (next == null)
                {
                    var environments = JsonConvert.SerializeObject(describeEnvironmentsResponse.Environments);
                    var msg = $"Error state: On environment CNAME swap, could not find environment with CNAME: {nextCNamePrefix} in a READY state. Environments: {environments}";
                    loggerProvider.GetLogger().Error(msg);
                    throw new ElasticBeanstalkDeployerException(msg);
                }
                var swapEnvironmentCnamesRequest = new SwapEnvironmentCNAMEsRequest
                {
                    DestinationEnvironmentId = next.EnvironmentId,
                    SourceEnvironmentId = current.EnvironmentId,
                };

                await ebClient.SwapEnvironmentCNAMEsAsync(swapEnvironmentCnamesRequest);
                await WaitForCnameSwapToCompleteAsync(next.EnvironmentId, next.CNAME, current.EnvironmentId, current.CNAME);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initiates the asynchronous execution of the SwapEnvironmentCNAMEs operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the SwapEnvironmentCNAMEs operation on AmazonElasticBeanstalkClient.</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 EndSwapEnvironmentCNAMEs
        ///         operation.</returns>
        public IAsyncResult BeginSwapEnvironmentCNAMEs(SwapEnvironmentCNAMEsRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new SwapEnvironmentCNAMEsRequestMarshaller();
            var unmarshaller = SwapEnvironmentCNAMEsResponseUnmarshaller.Instance;

            return BeginInvoke<SwapEnvironmentCNAMEsRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
        IAsyncResult invokeSwapEnvironmentCNAMEs(SwapEnvironmentCNAMEsRequest request, AsyncCallback callback, object state, bool synchronized)
        {
            var marshaller = new SwapEnvironmentCNAMEsRequestMarshaller();
            var unmarshaller = SwapEnvironmentCNAMEsResponseUnmarshaller.Instance;

            return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer);
        }
        /// <summary>
        /// <para> Swaps the CNAMEs of two environments. </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the SwapEnvironmentCNAMEs service method on
        /// AmazonElasticBeanstalk.</param>
		public SwapEnvironmentCNAMEsResponse SwapEnvironmentCNAMEs(SwapEnvironmentCNAMEsRequest request)
        {
            var task = SwapEnvironmentCNAMEsAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
        /// <summary>
        /// <para> Swaps the CNAMEs of two environments. </para>
        /// </summary>
        /// 
        /// <param name="swapEnvironmentCNAMEsRequest">Container for the necessary parameters to execute the SwapEnvironmentCNAMEs service method on
        /// AmazonElasticBeanstalk.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public async Task<SwapEnvironmentCNAMEsResponse> SwapEnvironmentCNAMEsAsync(SwapEnvironmentCNAMEsRequest swapEnvironmentCNAMEsRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new SwapEnvironmentCNAMEsRequestMarshaller();
            var unmarshaller = SwapEnvironmentCNAMEsResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, SwapEnvironmentCNAMEsRequest, SwapEnvironmentCNAMEsResponse>(swapEnvironmentCNAMEsRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
Exemplo n.º 15
0
 private Amazon.ElasticBeanstalk.Model.SwapEnvironmentCNAMEsResponse CallAWSServiceOperation(IAmazonElasticBeanstalk client, Amazon.ElasticBeanstalk.Model.SwapEnvironmentCNAMEsRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Elastic Beanstalk", "SwapEnvironmentCNAMEs");
     try
     {
         #if DESKTOP
         return(client.SwapEnvironmentCNAMEs(request));
         #elif CORECLR
         return(client.SwapEnvironmentCNAMEsAsync(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;
     }
 }