Show / Hide Table of Contents

Class MethodOptions

Inheritance
System.Object
MethodOptions
Implements
IMethodOptions
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.AWS.APIGateway.dll
Syntax (csharp)
public class MethodOptions : Object, IMethodOptions
Syntax (vb)
Public Class MethodOptions
    Inherits Object
    Implements IMethodOptions
Remarks

ExampleMetadata: infused

Examples
RestApi api;
Function userLambda;


var userModel = api.AddModel("UserModel", new ModelOptions {
    Schema = new JsonSchema {
        Type = JsonSchemaType.OBJECT,
        Properties = new Dictionary<string, JsonSchema> {
            { "userId", new JsonSchema {
                Type = JsonSchemaType.STRING
            } },
            { "name", new JsonSchema {
                Type = JsonSchemaType.STRING
            } }
        },
        Required = new [] { "userId" }
    }
});
api.Root.AddResource("user").AddMethod("POST",
new LambdaIntegration(userLambda), new MethodOptions {
    RequestModels = new Dictionary<string, IModel> {
        { "application/json", userModel }
    }
});

Synopsis

Constructors

MethodOptions()

Properties

ApiKeyRequired

Indicates whether the method requires clients to submit a valid API key.

AuthorizationScopes

A list of authorization scopes configured on the method.

AuthorizationType

Method authorization. If the value is set of Custom, an authorizer must also be specified.

Authorizer

If authorizationType is Custom, this specifies the ID of the method authorizer resource.

MethodResponses

The responses that can be sent to the client who calls the method.

OperationName

A friendly operation name for the method.

RequestModels

The models which describe data structure of request payload.

RequestParameters

The request parameters that API Gateway accepts.

RequestValidator

The ID of the associated request validator.

RequestValidatorOptions

Request validator options to create new validator Only one of requestValidator or requestValidatorOptions must be specified.

Constructors

MethodOptions()

public MethodOptions()

Properties

ApiKeyRequired

Indicates whether the method requires clients to submit a valid API key.

public Nullable<bool> ApiKeyRequired { get; set; }
Property Value

System.Nullable<System.Boolean>

Remarks

Default: false

AuthorizationScopes

A list of authorization scopes configured on the method.

public string[] AuthorizationScopes { get; set; }
Property Value

System.String[]

Remarks

The scopes are used with a COGNITO_USER_POOLS authorizer to authorize the method invocation.

Default: - no authorization scopes

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-method.html#cfn-apigateway-method-authorizationscopes

AuthorizationType

Method authorization. If the value is set of Custom, an authorizer must also be specified.

public Nullable<AuthorizationType> AuthorizationType { get; set; }
Property Value

System.Nullable<AuthorizationType>

Remarks

If you're using one of the authorizers that are available via the {@link Authorizer} class, such as {@link Authorizer#token()}, it is recommended that this option not be specified. The authorizer will take care of setting the correct authorization type. However, specifying an authorization type using this property that conflicts with what is expected by the {@link Authorizer} will result in an error.

Default: - open access unless authorizer is specified

Authorizer

If authorizationType is Custom, this specifies the ID of the method authorizer resource.

public IAuthorizer Authorizer { get; set; }
Property Value

IAuthorizer

Remarks

If specified, the value of authorizationType must be set to Custom

MethodResponses

The responses that can be sent to the client who calls the method.

public IMethodResponse[] MethodResponses { get; set; }
Property Value

IMethodResponse[]

Remarks

Default: None

This property is not required, but if these are not supplied for a Lambda proxy integration, the Lambda function must return a value of the correct format, for the integration response to be correctly mapped to a response to the client.

See: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-settings-method-response.html

OperationName

A friendly operation name for the method.

public string OperationName { get; set; }
Property Value

System.String

Remarks

For example, you can assign the OperationName of ListPets for the GET /pets method.

RequestModels

The models which describe data structure of request payload.

public IDictionary<string, IModel> RequestModels { get; set; }
Property Value

System.Collections.Generic.IDictionary<System.String, IModel>

Remarks

When combined with requestValidator or requestValidatorOptions, the service will validate the API request payload before it reaches the API's Integration (including proxies). Specify requestModels as key-value pairs, with a content type (e.g. 'application/json') as the key and an API Gateway Model as the value.

See: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-settings-method-request.html#setup-method-request-model

Examples
RestApi api;
Function userLambda;


var userModel = api.AddModel("UserModel", new ModelOptions {
    Schema = new JsonSchema {
        Type = JsonSchemaType.OBJECT,
        Properties = new Dictionary<string, JsonSchema> {
            { "userId", new JsonSchema {
                Type = JsonSchemaType.STRING
            } },
            { "name", new JsonSchema {
                Type = JsonSchemaType.STRING
            } }
        },
        Required = new [] { "userId" }
    }
});
api.Root.AddResource("user").AddMethod("POST",
new LambdaIntegration(userLambda), new MethodOptions {
    RequestModels = new Dictionary<string, IModel> {
        { "application/json", userModel }
    }
});

RequestParameters

The request parameters that API Gateway accepts.

public IDictionary<string, bool> RequestParameters { get; set; }
Property Value

System.Collections.Generic.IDictionary<System.String, System.Boolean>

Remarks

Specify request parameters as key-value pairs (string-to-Boolean mapping), with a source as the key and a Boolean as the value. The Boolean specifies whether a parameter is required. A source must match the format method.request.location.name, where the location is querystring, path, or header, and name is a valid, unique parameter name.

Default: None

RequestValidator

The ID of the associated request validator.

public IRequestValidator RequestValidator { get; set; }
Property Value

IRequestValidator

Remarks

Only one of requestValidator or requestValidatorOptions must be specified. Works together with requestModels or requestParameters to validate the request before it reaches integration like Lambda Proxy Integration.

Default: - No default validator

RequestValidatorOptions

Request validator options to create new validator Only one of requestValidator or requestValidatorOptions must be specified.

public IRequestValidatorOptions RequestValidatorOptions { get; set; }
Property Value

IRequestValidatorOptions

Remarks

Works together with requestModels or requestParameters to validate the request before it reaches integration like Lambda Proxy Integration.

Default: - No default validator

Implements

IMethodOptions
Back to top Generated by DocFX