protected override void ProcessRecord()
 {
     AmazonEC2 client = base.GetClient();
     Amazon.EC2.Model.BundleInstanceRequest request = new Amazon.EC2.Model.BundleInstanceRequest();
     request.InstanceId = this._InstanceId;
     Amazon.EC2.Model.BundleInstanceResponse response = client.BundleInstance(request);
     base.WriteObject(response.BundleInstanceResult, true);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the BundleInstance operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the BundleInstance 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<BundleInstanceResponse> BundleInstanceAsync(BundleInstanceRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new BundleInstanceRequestMarshaller();
            var unmarshaller = BundleInstanceResponseUnmarshaller.Instance;

            return InvokeAsync<BundleInstanceRequest,BundleInstanceResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        /// <summary>
        /// Bundles an Amazon instance store-backed Windows instance.
        /// 
        ///  
        /// <para>
        /// During bundling, only the root device volume (C:\) is bundled. Data on other instance
        /// store volumes is not preserved.
        /// </para>
        ///  <note> 
        /// <para>
        /// This action is not applicable for Linux/Unix instances or Windows instances that are
        /// backed by Amazon EBS.
        /// </para>
        ///  </note> 
        /// <para>
        /// For more information, see <a href="http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Creating_InstanceStoreBacked_WinAMI.html">Creating
        /// an Instance Store-Backed Windows AMI</a>.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the BundleInstance service method.</param>
        /// 
        /// <returns>The response from the BundleInstance service method, as returned by EC2.</returns>
        public BundleInstanceResponse BundleInstance(BundleInstanceRequest request)
        {
            var marshaller = new BundleInstanceRequestMarshaller();
            var unmarshaller = BundleInstanceResponseUnmarshaller.Instance;

            return Invoke<BundleInstanceRequest,BundleInstanceResponse>(request, marshaller, unmarshaller);
        }
Example #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the BundleInstance operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the BundleInstance operation on AmazonEC2Client.</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 EndBundleInstance
        ///         operation.</returns>
        public IAsyncResult BeginBundleInstance(BundleInstanceRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new BundleInstanceRequestMarshaller();
            var unmarshaller = BundleInstanceResponseUnmarshaller.Instance;

            return BeginInvoke<BundleInstanceRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Example #5
0
 IAsyncResult invokeBundleInstance(BundleInstanceRequest bundleInstanceRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new BundleInstanceRequestMarshaller().Marshall(bundleInstanceRequest);
     var unmarshaller = BundleInstanceResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
Example #6
0
 /// <summary>
 /// Initiates the asynchronous execution of the BundleInstance operation.
 /// <seealso cref="Amazon.EC2.IAmazonEC2.BundleInstance"/>
 /// </summary>
 /// 
 /// <param name="bundleInstanceRequest">Container for the necessary parameters to execute the BundleInstance operation on AmazonEC2.</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 EndBundleInstance
 ///         operation.</returns>
 public IAsyncResult BeginBundleInstance(BundleInstanceRequest bundleInstanceRequest, AsyncCallback callback, object state)
 {
     return invokeBundleInstance(bundleInstanceRequest, callback, state, false);
 }
Example #7
0
 /// <summary>
 /// <para>Bundles an Amazon instance store-backed Windows instance.</para> <para>During bundling, only the root device volume (C:\) is bundled.
 /// Data on other instance store volumes is not preserved.</para> <para><b>NOTE:</b> This procedure is not applicable for Linux/Unix instances
 /// or Windows instances that are backed by Amazon EBS. </para> <para>For more information, see <a
 /// href="http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Creating_InstanceStoreBacked_WinAMI.html" >Creating an Instance Store-Backed
 /// Windows AMI</a> .</para>
 /// </summary>
 /// 
 /// <param name="bundleInstanceRequest">Container for the necessary parameters to execute the BundleInstance service method on
 ///          AmazonEC2.</param>
 /// 
 /// <returns>The response from the BundleInstance service method, as returned by AmazonEC2.</returns>
 /// 
 public BundleInstanceResponse BundleInstance(BundleInstanceRequest bundleInstanceRequest)
 {
     IAsyncResult asyncResult = invokeBundleInstance(bundleInstanceRequest, null, null, true);
     return EndBundleInstance(asyncResult);
 }
Example #8
0
        /// <summary>
        /// <para>Bundles an Amazon instance store-backed Windows instance.</para> <para>During bundling, only the root device volume (C:\) is bundled.
        /// Data on other instance store volumes is not preserved.</para> <para><b>NOTE:</b> This procedure is not applicable for Linux/Unix instances
        /// or Windows instances that are backed by Amazon EBS. </para> <para>For more information, see <a href="http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Creating_InstanceStoreBacked_WinAMI.html">Creating an Instance Store-Backed
        /// Windows AMI</a> .</para>
        /// </summary>
        /// 
        /// <param name="bundleInstanceRequest">Container for the necessary parameters to execute the BundleInstance service method on
        /// AmazonEC2.</param>
        /// 
        /// <returns>The response from the BundleInstance service method, as returned by AmazonEC2.</returns>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<BundleInstanceResponse> BundleInstanceAsync(BundleInstanceRequest bundleInstanceRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new BundleInstanceRequestMarshaller();
            var unmarshaller = BundleInstanceResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, BundleInstanceRequest, BundleInstanceResponse>(bundleInstanceRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
Example #9
0
		internal BundleInstanceResponse BundleInstance(BundleInstanceRequest request)
        {
            var task = BundleInstanceAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
Example #10
0
        /// <summary>
        /// Initiates the asynchronous execution of the BundleInstance operation.
        /// <seealso cref="Amazon.EC2.IAmazonEC2.BundleInstance"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the BundleInstance 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 async Task<BundleInstanceResponse> BundleInstanceAsync(BundleInstanceRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new BundleInstanceRequestMarshaller();
            var unmarshaller = BundleInstanceResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, BundleInstanceRequest, BundleInstanceResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
Example #11
0
        /// <summary>
        /// <para> The BundleInstance operation request that an instance is bundled the next time it boots. The bundling process creates a new image
        /// from a running instance and stores the AMI data in S3. Once bundled, the image must be registered in the normal way using the RegisterImage
        /// API. </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the BundleInstance service method on
        /// AmazonEC2.</param>
        /// 
        /// <returns>The response from the BundleInstance service method, as returned by AmazonEC2.</returns>
		public BundleInstanceResponse BundleInstance(BundleInstanceRequest request)
        {
            var task = BundleInstanceAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
Example #12
0
 private Amazon.EC2.Model.BundleInstanceResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.BundleInstanceRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "BundleInstance");
     try
     {
         #if DESKTOP
         return(client.BundleInstance(request));
         #elif CORECLR
         return(client.BundleInstanceAsync(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;
     }
 }
Example #13
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.EC2.Model.BundleInstanceRequest();

            if (cmdletContext.InstanceId != null)
            {
                request.InstanceId = cmdletContext.InstanceId;
            }

            // populate Storage
            var requestStorageIsNull = true;

            request.Storage = new Amazon.EC2.Model.Storage();
            Amazon.EC2.Model.S3Storage requestStorage_storage_S3 = null;

            // populate S3
            var requestStorage_storage_S3IsNull = true;

            requestStorage_storage_S3 = new Amazon.EC2.Model.S3Storage();
            System.String requestStorage_storage_S3_s3_AWSAccessKeyId = null;
            if (cmdletContext.S3_AWSAccessKeyId != null)
            {
                requestStorage_storage_S3_s3_AWSAccessKeyId = cmdletContext.S3_AWSAccessKeyId;
            }
            if (requestStorage_storage_S3_s3_AWSAccessKeyId != null)
            {
                requestStorage_storage_S3.AWSAccessKeyId = requestStorage_storage_S3_s3_AWSAccessKeyId;
                requestStorage_storage_S3IsNull          = false;
            }
            System.String requestStorage_storage_S3_s3_Bucket = null;
            if (cmdletContext.S3_Bucket != null)
            {
                requestStorage_storage_S3_s3_Bucket = cmdletContext.S3_Bucket;
            }
            if (requestStorage_storage_S3_s3_Bucket != null)
            {
                requestStorage_storage_S3.Bucket = requestStorage_storage_S3_s3_Bucket;
                requestStorage_storage_S3IsNull  = false;
            }
            System.String requestStorage_storage_S3_s3_Prefix = null;
            if (cmdletContext.S3_Prefix != null)
            {
                requestStorage_storage_S3_s3_Prefix = cmdletContext.S3_Prefix;
            }
            if (requestStorage_storage_S3_s3_Prefix != null)
            {
                requestStorage_storage_S3.Prefix = requestStorage_storage_S3_s3_Prefix;
                requestStorage_storage_S3IsNull  = false;
            }
            System.String requestStorage_storage_S3_s3_UploadPolicy = null;
            if (cmdletContext.S3_UploadPolicy != null)
            {
                requestStorage_storage_S3_s3_UploadPolicy = cmdletContext.S3_UploadPolicy;
            }
            if (requestStorage_storage_S3_s3_UploadPolicy != null)
            {
                requestStorage_storage_S3.UploadPolicy = requestStorage_storage_S3_s3_UploadPolicy;
                requestStorage_storage_S3IsNull        = false;
            }
            System.String requestStorage_storage_S3_s3_UploadPolicySignature = null;
            if (cmdletContext.S3_UploadPolicySignature != null)
            {
                requestStorage_storage_S3_s3_UploadPolicySignature = cmdletContext.S3_UploadPolicySignature;
            }
            if (requestStorage_storage_S3_s3_UploadPolicySignature != null)
            {
                requestStorage_storage_S3.UploadPolicySignature = requestStorage_storage_S3_s3_UploadPolicySignature;
                requestStorage_storage_S3IsNull = false;
            }
            // determine if requestStorage_storage_S3 should be set to null
            if (requestStorage_storage_S3IsNull)
            {
                requestStorage_storage_S3 = null;
            }
            if (requestStorage_storage_S3 != null)
            {
                request.Storage.S3   = requestStorage_storage_S3;
                requestStorageIsNull = false;
            }
            // determine if request.Storage should be set to null
            if (requestStorageIsNull)
            {
                request.Storage = null;
            }

            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>
        /// The BundleInstance operation request that an instance is bundled the next time it boots.
        /// The bundling process creates a new image from a running instance and stores
        /// the AMI data in S3. Once bundled, the image must be registered in the normal
        /// way using the RegisterImage API.
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonEC2 service</param>
        /// <param name="request">BundleInstanceRequest request</param>
        public static void InvokeBundleInstance(AmazonEC2 service, BundleInstanceRequest request)
        {
            try 
            {
                BundleInstanceResponse response = service.BundleInstance(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        BundleInstanceResponse");
                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata  responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }
                if (response.IsSetBundleInstanceResult())
                {
                    Console.WriteLine("            BundleInstanceResult");
                    BundleInstanceResult  bundleInstanceResult = response.BundleInstanceResult;
                    List<BundleTask> bundleTaskList = bundleInstanceResult.BundleTask;
                    foreach (BundleTask bundleTask in bundleTaskList)
                    {
                        Console.WriteLine("                BundleTask");
                        if (bundleTask.IsSetInstanceId())
                        {
                            Console.WriteLine("                    InstanceId");
                            Console.WriteLine("                        {0}", bundleTask.InstanceId);
                        }
                        if (bundleTask.IsSetBundleId())
                        {
                            Console.WriteLine("                    BundleId");
                            Console.WriteLine("                        {0}", bundleTask.BundleId);
                        }
                        if (bundleTask.IsSetBundleState())
                        {
                            Console.WriteLine("                    BundleState");
                            Console.WriteLine("                        {0}", bundleTask.BundleState);
                        }
                        if (bundleTask.IsSetStartTime())
                        {
                            Console.WriteLine("                    StartTime");
                            Console.WriteLine("                        {0}", bundleTask.StartTime);
                        }
                        if (bundleTask.IsSetUpdateTime())
                        {
                            Console.WriteLine("                    UpdateTime");
                            Console.WriteLine("                        {0}", bundleTask.UpdateTime);
                        }
                        if (bundleTask.IsSetStorage())
                        {
                            Console.WriteLine("                    Storage");
                            Storage  storage = bundleTask.Storage;
                            if (storage.IsSetS3())
                            {
                                Console.WriteLine("                        S3");
                                S3Storage  s3 = storage.S3;
                                if (s3.IsSetBucket())
                                {
                                    Console.WriteLine("                            Bucket");
                                    Console.WriteLine("                                {0}", s3.Bucket);
                                }
                                if (s3.IsSetPrefix())
                                {
                                    Console.WriteLine("                            Prefix");
                                    Console.WriteLine("                                {0}", s3.Prefix);
                                }
                                if (s3.IsSetAWSAccessKeyId())
                                {
                                    Console.WriteLine("                            AWSAccessKeyId");
                                    Console.WriteLine("                                {0}", s3.AWSAccessKeyId);
                                }
                                if (s3.IsSetUploadPolicy())
                                {
                                    Console.WriteLine("                            UploadPolicy");
                                    Console.WriteLine("                                {0}", s3.UploadPolicy);
                                }
                                if (s3.IsSetUploadPolicySignature())
                                {
                                    Console.WriteLine("                            UploadPolicySignature");
                                    Console.WriteLine("                                {0}", s3.UploadPolicySignature);
                                }
                            }
                        }
                        if (bundleTask.IsSetProgress())
                        {
                            Console.WriteLine("                    Progress");
                            Console.WriteLine("                        {0}", bundleTask.Progress);
                        }
                        if (bundleTask.IsSetBundleTaskError())
                        {
                            Console.WriteLine("                    BundleTaskError");
                            BundleTaskError  bundleTaskError = bundleTask.BundleTaskError;
                            if (bundleTaskError.IsSetCode())
                            {
                                Console.WriteLine("                        Code");
                                Console.WriteLine("                            {0}", bundleTaskError.Code);
                            }
                            if (bundleTaskError.IsSetMessage())
                            {
                                Console.WriteLine("                        Message");
                                Console.WriteLine("                            {0}", bundleTaskError.Message);
                            }
                        }
                    }
                }

            } 
            catch (AmazonEC2Exception ex) 
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }
        }