示例#1
0
 private Amazon.EC2.Model.ReplaceIamInstanceProfileAssociationResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.ReplaceIamInstanceProfileAssociationRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "ReplaceIamInstanceProfileAssociation");
     try
     {
         #if DESKTOP
         return(client.ReplaceIamInstanceProfileAssociation(request));
         #elif CORECLR
         return(client.ReplaceIamInstanceProfileAssociationAsync(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;
     }
 }
示例#2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.EC2.Model.ReplaceIamInstanceProfileAssociationRequest();

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

            // populate IamInstanceProfile
            var requestIamInstanceProfileIsNull = true;

            request.IamInstanceProfile = new Amazon.EC2.Model.IamInstanceProfileSpecification();
            System.String requestIamInstanceProfile_iamInstanceProfile_Arn = null;
            if (cmdletContext.IamInstanceProfile_Arn != null)
            {
                requestIamInstanceProfile_iamInstanceProfile_Arn = cmdletContext.IamInstanceProfile_Arn;
            }
            if (requestIamInstanceProfile_iamInstanceProfile_Arn != null)
            {
                request.IamInstanceProfile.Arn  = requestIamInstanceProfile_iamInstanceProfile_Arn;
                requestIamInstanceProfileIsNull = false;
            }
            System.String requestIamInstanceProfile_iamInstanceProfile_Name = null;
            if (cmdletContext.IamInstanceProfile_Name != null)
            {
                requestIamInstanceProfile_iamInstanceProfile_Name = cmdletContext.IamInstanceProfile_Name;
            }
            if (requestIamInstanceProfile_iamInstanceProfile_Name != null)
            {
                request.IamInstanceProfile.Name = requestIamInstanceProfile_iamInstanceProfile_Name;
                requestIamInstanceProfileIsNull = false;
            }
            // determine if request.IamInstanceProfile should be set to null
            if (requestIamInstanceProfileIsNull)
            {
                request.IamInstanceProfile = 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);
        }