Container for the parameters to the ModifyImageAttribute operation. Modifies the specified attribute of the specified AMI. You can specify only one attribute at a time.

AWS Marketplace product codes cannot be modified. Images with an AWS Marketplace product code cannot be made public.

Inheritance: AmazonEC2Request
        /// <summary>
        /// The ModifyImageAttribute operation modifies an attribute of an AMI.
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonEC2 service</param>
        /// <param name="request">ModifyImageAttributeRequest request</param>
        public static void InvokeModifyImageAttribute(AmazonEC2 service, ModifyImageAttributeRequest request)
        {
            try 
            {
                ModifyImageAttributeResponse response = service.ModifyImageAttribute(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        ModifyImageAttributeResponse");
                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata  responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }

            } 
            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);
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the ModifyImageAttribute operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ModifyImageAttribute 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<ModifyImageAttributeResponse> ModifyImageAttributeAsync(ModifyImageAttributeRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ModifyImageAttributeRequestMarshaller();
            var unmarshaller = ModifyImageAttributeResponseUnmarshaller.Instance;

            return InvokeAsync<ModifyImageAttributeRequest,ModifyImageAttributeResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        /// <summary>
        /// Modifies the specified attribute of the specified AMI. You can specify only one attribute
        /// at a time.
        /// 
        ///  <note>
        /// <para>
        /// AWS Marketplace product codes cannot be modified. Images with an AWS Marketplace product
        /// code cannot be made public.
        /// </para>
        /// </note>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the ModifyImageAttribute service method.</param>
        /// 
        /// <returns>The response from the ModifyImageAttribute service method, as returned by EC2.</returns>
        public ModifyImageAttributeResponse ModifyImageAttribute(ModifyImageAttributeRequest request)
        {
            var marshaller = new ModifyImageAttributeRequestMarshaller();
            var unmarshaller = ModifyImageAttributeResponseUnmarshaller.Instance;

            return Invoke<ModifyImageAttributeRequest,ModifyImageAttributeResponse>(request, marshaller, unmarshaller);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initiates the asynchronous execution of the ModifyImageAttribute operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ModifyImageAttribute 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 EndModifyImageAttribute
        ///         operation.</returns>
        public IAsyncResult BeginModifyImageAttribute(ModifyImageAttributeRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new ModifyImageAttributeRequestMarshaller();
            var unmarshaller = ModifyImageAttributeResponseUnmarshaller.Instance;

            return BeginInvoke<ModifyImageAttributeRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Ejemplo n.º 5
0
 IAsyncResult invokeModifyImageAttribute(ModifyImageAttributeRequest modifyImageAttributeRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new ModifyImageAttributeRequestMarshaller().Marshall(modifyImageAttributeRequest);
     var unmarshaller = ModifyImageAttributeResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initiates the asynchronous execution of the ModifyImageAttribute operation.
 /// <seealso cref="Amazon.EC2.IAmazonEC2.ModifyImageAttribute"/>
 /// </summary>
 /// 
 /// <param name="modifyImageAttributeRequest">Container for the necessary parameters to execute the ModifyImageAttribute 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>
 public IAsyncResult BeginModifyImageAttribute(ModifyImageAttributeRequest modifyImageAttributeRequest, AsyncCallback callback, object state)
 {
     return invokeModifyImageAttribute(modifyImageAttributeRequest, callback, state, false);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// <para>Modifies the specified attribute of the specified AMI. You can specify only one attribute at a time.</para> <para><b>NOTE:</b> AWS
 /// Marketplace product codes cannot be modified. Images with an AWS Marketplace product code cannot be made public. </para>
 /// </summary>
 /// 
 /// <param name="modifyImageAttributeRequest">Container for the necessary parameters to execute the ModifyImageAttribute service method on
 ///          AmazonEC2.</param>
 /// 
 public ModifyImageAttributeResponse ModifyImageAttribute(ModifyImageAttributeRequest modifyImageAttributeRequest)
 {
     IAsyncResult asyncResult = invokeModifyImageAttribute(modifyImageAttributeRequest, null, null, true);
     return EndModifyImageAttribute(asyncResult);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// <para>Modifies the specified attribute of the specified AMI. You can specify only one attribute at a time.</para> <para><b>NOTE:</b> AWS
        /// Marketplace product codes cannot be modified. Images with an AWS Marketplace product code cannot be made public. </para>
        /// </summary>
        /// 
        /// <param name="modifyImageAttributeRequest">Container for the necessary parameters to execute the ModifyImageAttribute service method on
        /// AmazonEC2.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<ModifyImageAttributeResponse> ModifyImageAttributeAsync(ModifyImageAttributeRequest modifyImageAttributeRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ModifyImageAttributeRequestMarshaller();
            var unmarshaller = ModifyImageAttributeResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, ModifyImageAttributeRequest, ModifyImageAttributeResponse>(modifyImageAttributeRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
Ejemplo n.º 9
0
		internal ModifyImageAttributeResponse ModifyImageAttribute(ModifyImageAttributeRequest request)
        {
            var task = ModifyImageAttributeAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initiates the asynchronous execution of the ModifyImageAttribute operation.
        /// <seealso cref="Amazon.EC2.IAmazonEC2.ModifyImageAttribute"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ModifyImageAttribute 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<ModifyImageAttributeResponse> ModifyImageAttributeAsync(ModifyImageAttributeRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ModifyImageAttributeRequestMarshaller();
            var unmarshaller = ModifyImageAttributeResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, ModifyImageAttributeRequest, ModifyImageAttributeResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// <para> The ModifyImageAttribute operation modifies an attribute of an AMI. </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ModifyImageAttribute service method on
        /// AmazonEC2.</param>
		public ModifyImageAttributeResponse ModifyImageAttribute(ModifyImageAttributeRequest request)
        {
            var task = ModifyImageAttributeAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
 private Amazon.EC2.Model.ModifyImageAttributeResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.ModifyImageAttributeRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "ModifyImageAttribute");
     try
     {
         #if DESKTOP
         return(client.ModifyImageAttribute(request));
         #elif CORECLR
         return(client.ModifyImageAttributeAsync(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.EC2.Model.ModifyImageAttributeRequest();

            if (cmdletContext.Attribute != null)
            {
                request.Attribute = cmdletContext.Attribute;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.ImageId != null)
            {
                request.ImageId = cmdletContext.ImageId;
            }

            // populate LaunchPermission
            var requestLaunchPermissionIsNull = true;

            request.LaunchPermission = new Amazon.EC2.Model.LaunchPermissionModifications();
            List <Amazon.EC2.Model.LaunchPermission> requestLaunchPermission_launchPermission_Add = null;

            if (cmdletContext.LaunchPermission_Add != null)
            {
                requestLaunchPermission_launchPermission_Add = cmdletContext.LaunchPermission_Add;
            }
            if (requestLaunchPermission_launchPermission_Add != null)
            {
                request.LaunchPermission.Add  = requestLaunchPermission_launchPermission_Add;
                requestLaunchPermissionIsNull = false;
            }
            List <Amazon.EC2.Model.LaunchPermission> requestLaunchPermission_launchPermission_Remove = null;

            if (cmdletContext.LaunchPermission_Remove != null)
            {
                requestLaunchPermission_launchPermission_Remove = cmdletContext.LaunchPermission_Remove;
            }
            if (requestLaunchPermission_launchPermission_Remove != null)
            {
                request.LaunchPermission.Remove = requestLaunchPermission_launchPermission_Remove;
                requestLaunchPermissionIsNull   = false;
            }
            // determine if request.LaunchPermission should be set to null
            if (requestLaunchPermissionIsNull)
            {
                request.LaunchPermission = null;
            }
            if (cmdletContext.OperationType != null)
            {
                request.OperationType = cmdletContext.OperationType;
            }
            if (cmdletContext.ProductCode != null)
            {
                request.ProductCodes = cmdletContext.ProductCode;
            }
            if (cmdletContext.UserGroup != null)
            {
                request.UserGroups = cmdletContext.UserGroup;
            }
            if (cmdletContext.UserId != null)
            {
                request.UserIds = cmdletContext.UserId;
            }
            if (cmdletContext.Value != null)
            {
                request.Value = cmdletContext.Value;
            }

            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);
        }
 protected override void ProcessRecord()
 {
     AmazonEC2 client = base.GetClient();
     Amazon.EC2.Model.ModifyImageAttributeRequest request = new Amazon.EC2.Model.ModifyImageAttributeRequest();
     request.ImageId = this._ImageId;
     request.Attribute = this._Attribute;
     request.OperationType = this._OperationType;
     if (string.IsNullOrEmpty(this._UserId))
     {
         request.UserId.Add(this._UserId);
     }
     if (string.IsNullOrEmpty(this._UserGroup))
     {
         request.UserGroup.Add(this._UserGroup);
     }
     if (string.IsNullOrEmpty(this._ProductCode))
     {
         request.ProductCode.Add(this._ProductCode);
     }
     request.Description = this._Description;
     Amazon.EC2.Model.ModifyImageAttributeResponse response = client.ModifyImageAttribute(request);
 }