public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.ApiGatewayV2.Model.CreateAuthorizerRequest();

            if (cmdletContext.ApiId != null)
            {
                request.ApiId = cmdletContext.ApiId;
            }
            if (cmdletContext.AuthorizerCredentialsArn != null)
            {
                request.AuthorizerCredentialsArn = cmdletContext.AuthorizerCredentialsArn;
            }
            if (cmdletContext.AuthorizerPayloadFormatVersion != null)
            {
                request.AuthorizerPayloadFormatVersion = cmdletContext.AuthorizerPayloadFormatVersion;
            }
            if (cmdletContext.AuthorizerResultTtlInSecond != null)
            {
                request.AuthorizerResultTtlInSeconds = cmdletContext.AuthorizerResultTtlInSecond.Value;
            }
            if (cmdletContext.AuthorizerType != null)
            {
                request.AuthorizerType = cmdletContext.AuthorizerType;
            }
            if (cmdletContext.AuthorizerUri != null)
            {
                request.AuthorizerUri = cmdletContext.AuthorizerUri;
            }
            if (cmdletContext.EnableSimpleResponse != null)
            {
                request.EnableSimpleResponses = cmdletContext.EnableSimpleResponse.Value;
            }
            if (cmdletContext.IdentitySource != null)
            {
                request.IdentitySource = cmdletContext.IdentitySource;
            }
            if (cmdletContext.IdentityValidationExpression != null)
            {
                request.IdentityValidationExpression = cmdletContext.IdentityValidationExpression;
            }

            // populate JwtConfiguration
            var requestJwtConfigurationIsNull = true;

            request.JwtConfiguration = new Amazon.ApiGatewayV2.Model.JWTConfiguration();
            List <System.String> requestJwtConfiguration_jwtConfiguration_Audience = null;

            if (cmdletContext.JwtConfiguration_Audience != null)
            {
                requestJwtConfiguration_jwtConfiguration_Audience = cmdletContext.JwtConfiguration_Audience;
            }
            if (requestJwtConfiguration_jwtConfiguration_Audience != null)
            {
                request.JwtConfiguration.Audience = requestJwtConfiguration_jwtConfiguration_Audience;
                requestJwtConfigurationIsNull     = false;
            }
            System.String requestJwtConfiguration_jwtConfiguration_Issuer = null;
            if (cmdletContext.JwtConfiguration_Issuer != null)
            {
                requestJwtConfiguration_jwtConfiguration_Issuer = cmdletContext.JwtConfiguration_Issuer;
            }
            if (requestJwtConfiguration_jwtConfiguration_Issuer != null)
            {
                request.JwtConfiguration.Issuer = requestJwtConfiguration_jwtConfiguration_Issuer;
                requestJwtConfigurationIsNull   = false;
            }
            // determine if request.JwtConfiguration should be set to null
            if (requestJwtConfigurationIsNull)
            {
                request.JwtConfiguration = null;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }

            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);
        }
 private Amazon.ApiGatewayV2.Model.CreateAuthorizerResponse CallAWSServiceOperation(IAmazonApiGatewayV2 client, Amazon.ApiGatewayV2.Model.CreateAuthorizerRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon API Gateway V2", "CreateAuthorizer");
     try
     {
         #if DESKTOP
         return(client.CreateAuthorizer(request));
         #elif CORECLR
         return(client.CreateAuthorizerAsync(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;
     }
 }
コード例 #3
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.ApiGatewayV2.Model.CreateAuthorizerRequest();

            if (cmdletContext.ApiId != null)
            {
                request.ApiId = cmdletContext.ApiId;
            }
            if (cmdletContext.AuthorizerCredentialsArn != null)
            {
                request.AuthorizerCredentialsArn = cmdletContext.AuthorizerCredentialsArn;
            }
            if (cmdletContext.AuthorizerResultTtlInSecond != null)
            {
                request.AuthorizerResultTtlInSeconds = cmdletContext.AuthorizerResultTtlInSecond.Value;
            }
            if (cmdletContext.AuthorizerType != null)
            {
                request.AuthorizerType = cmdletContext.AuthorizerType;
            }
            if (cmdletContext.AuthorizerUri != null)
            {
                request.AuthorizerUri = cmdletContext.AuthorizerUri;
            }
            if (cmdletContext.IdentitySource != null)
            {
                request.IdentitySource = cmdletContext.IdentitySource;
            }
            if (cmdletContext.IdentityValidationExpression != null)
            {
                request.IdentityValidationExpression = cmdletContext.IdentityValidationExpression;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }
            if (cmdletContext.ProviderArn != null)
            {
                request.ProviderArns = cmdletContext.ProviderArn;
            }

            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);
        }