private Amazon.EC2.Model.AssociateIamInstanceProfileResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.AssociateIamInstanceProfileRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "AssociateIamInstanceProfile"); try { #if DESKTOP return(client.AssociateIamInstanceProfile(request)); #elif CORECLR return(client.AssociateIamInstanceProfileAsync(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.AssociateIamInstanceProfileRequest(); // 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; } if (cmdletContext.InstanceId != null) { request.InstanceId = cmdletContext.InstanceId; } 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); }