# ResourceProps

Extends: [ResourceOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.ResourceOptions.html)
Used as props by: [Resource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.Resource.html)

- Source: [`aws-apigateway/lib/resource.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigateway/lib/resource.ts#L159)

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_apigateway as apigateway } from 'aws-cdk-lib';

declare const authorizer: apigateway.Authorizer;
declare const integration: apigateway.Integration;
declare const model: apigateway.Model;
declare const requestValidator: apigateway.RequestValidator;
declare const resource: apigateway.Resource;
const resourceProps: apigateway.ResourceProps = {
  parent: resource,
  pathPart: 'pathPart',

  // the properties below are optional
  defaultCorsPreflightOptions: {
    allowOrigins: ['allowOrigins'],

    // the properties below are optional
    allowCredentials: false,
    allowHeaders: ['allowHeaders'],
    allowMethods: ['allowMethods'],
    disableCache: false,
    exposeHeaders: ['exposeHeaders'],
    maxAge: cdk.Duration.minutes(30),
    statusCode: 123,
  },
  defaultIntegration: integration,
  defaultMethodOptions: {
    apiKeyRequired: false,
    authorizationScopes: ['authorizationScopes'],
    authorizationType: apigateway.AuthorizationType.NONE,
    authorizer: authorizer,
    methodResponses: [{
      statusCode: 'statusCode',

      // the properties below are optional
      responseModels: {
        responseModelsKey: model,
      },
      responseParameters: {
        responseParametersKey: false,
      },
    }],
    operationName: 'operationName',
    requestModels: {
      requestModelsKey: model,
    },
    requestParameters: {
      requestParametersKey: false,
    },
    requestValidator: requestValidator,
    requestValidatorOptions: {
      requestValidatorName: 'requestValidatorName',
      validateRequestBody: false,
      validateRequestParameters: false,
    },
  },
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_apigateway as apigateway

# authorizer: apigateway.Authorizer
# integration: apigateway.Integration
# model: apigateway.Model
# request_validator: apigateway.RequestValidator
# resource: apigateway.Resource

resource_props = apigateway.ResourceProps(
    parent=resource,
    path_part="pathPart",

    # the properties below are optional
    default_cors_preflight_options=apigateway.CorsOptions(
        allow_origins=["allowOrigins"],

        # the properties below are optional
        allow_credentials=False,
        allow_headers=["allowHeaders"],
        allow_methods=["allowMethods"],
        disable_cache=False,
        expose_headers=["exposeHeaders"],
        max_age=cdk.Duration.minutes(30),
        status_code=123
    ),
    default_integration=integration,
    default_method_options=apigateway.MethodOptions(
        api_key_required=False,
        authorization_scopes=["authorizationScopes"],
        authorization_type=apigateway.AuthorizationType.NONE,
        authorizer=authorizer,
        method_responses=[apigateway.MethodResponse(
            status_code="statusCode",

            # the properties below are optional
            response_models={
                "response_models_key": model
            },
            response_parameters={
                "response_parameters_key": False
            }
        )],
        operation_name="operationName",
        request_models={
            "request_models_key": model
        },
        request_parameters={
            "request_parameters_key": False
        },
        request_validator=request_validator,
        request_validator_options=apigateway.RequestValidatorOptions(
            request_validator_name="requestValidatorName",
            validate_request_body=False,
            validate_request_parameters=False
        )
    )
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.apigateway.*;

Authorizer authorizer;
Integration integration;
Model model;
RequestValidator requestValidator;
Resource resource;

ResourceProps resourceProps = ResourceProps.builder()
        .parent(resource)
        .pathPart("pathPart")

        // the properties below are optional
        .defaultCorsPreflightOptions(CorsOptions.builder()
                .allowOrigins(List.of("allowOrigins"))

                // the properties below are optional
                .allowCredentials(false)
                .allowHeaders(List.of("allowHeaders"))
                .allowMethods(List.of("allowMethods"))
                .disableCache(false)
                .exposeHeaders(List.of("exposeHeaders"))
                .maxAge(Duration.minutes(30))
                .statusCode(123)
                .build())
        .defaultIntegration(integration)
        .defaultMethodOptions(MethodOptions.builder()
                .apiKeyRequired(false)
                .authorizationScopes(List.of("authorizationScopes"))
                .authorizationType(AuthorizationType.NONE)
                .authorizer(authorizer)
                .methodResponses(List.of(MethodResponse.builder()
                        .statusCode("statusCode")

                        // the properties below are optional
                        .responseModels(Map.of(
                                "responseModelsKey", model))
                        .responseParameters(Map.of(
                                "responseParametersKey", false))
                        .build()))
                .operationName("operationName")
                .requestModels(Map.of(
                        "requestModelsKey", model))
                .requestParameters(Map.of(
                        "requestParametersKey", false))
                .requestValidator(requestValidator)
                .requestValidatorOptions(RequestValidatorOptions.builder()
                        .requestValidatorName("requestValidatorName")
                        .validateRequestBody(false)
                        .validateRequestParameters(false)
                        .build())
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.APIGateway;

Authorizer authorizer;
Integration integration;
Model model;
RequestValidator requestValidator;
Resource resource;

var resourceProps = new ResourceProps {
    Parent = resource,
    PathPart = "pathPart",

    // the properties below are optional
    DefaultCorsPreflightOptions = new CorsOptions {
        AllowOrigins = new [] { "allowOrigins" },

        // the properties below are optional
        AllowCredentials = false,
        AllowHeaders = new [] { "allowHeaders" },
        AllowMethods = new [] { "allowMethods" },
        DisableCache = false,
        ExposeHeaders = new [] { "exposeHeaders" },
        MaxAge = Duration.Minutes(30),
        StatusCode = 123
    },
    DefaultIntegration = integration,
    DefaultMethodOptions = new MethodOptions {
        ApiKeyRequired = false,
        AuthorizationScopes = new [] { "authorizationScopes" },
        AuthorizationType = AuthorizationType.NONE,
        Authorizer = authorizer,
        MethodResponses = new [] { new MethodResponse {
            StatusCode = "statusCode",

            // the properties below are optional
            ResponseModels = new Dictionary<string, IModel> {
                { "responseModelsKey", model }
            },
            ResponseParameters = new Dictionary<string, boolean> {
                { "responseParametersKey", false }
            }
        } },
        OperationName = "operationName",
        RequestModels = new Dictionary<string, IModel> {
            { "requestModelsKey", model }
        },
        RequestParameters = new Dictionary<string, boolean> {
            { "requestParametersKey", false }
        },
        RequestValidator = requestValidator,
        RequestValidatorOptions = new RequestValidatorOptions {
            RequestValidatorName = "requestValidatorName",
            ValidateRequestBody = false,
            ValidateRequestParameters = false
        }
    }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var authorizer Authorizer
var integration Integration
var model Model
var requestValidator RequestValidator
var resource Resource

resourceProps := &ResourceProps{
	Parent: resource,
	PathPart: jsii.String("pathPart"),

	// the properties below are optional
	DefaultCorsPreflightOptions: &CorsOptions{
		AllowOrigins: []*string{
			jsii.String("allowOrigins"),
		},

		// the properties below are optional
		AllowCredentials: jsii.Boolean(false),
		AllowHeaders: []*string{
			jsii.String("allowHeaders"),
		},
		AllowMethods: []*string{
			jsii.String("allowMethods"),
		},
		DisableCache: jsii.Boolean(false),
		ExposeHeaders: []*string{
			jsii.String("exposeHeaders"),
		},
		MaxAge: cdk.Duration_Minutes(jsii.Number(30)),
		StatusCode: jsii.Number(123),
	},
	DefaultIntegration: integration,
	DefaultMethodOptions: &MethodOptions{
		ApiKeyRequired: jsii.Boolean(false),
		AuthorizationScopes: []*string{
			jsii.String("authorizationScopes"),
		},
		AuthorizationType: awscdk.Aws_apigateway.AuthorizationType_NONE,
		Authorizer: authorizer,
		MethodResponses: []MethodResponse{
			&MethodResponse{
				StatusCode: jsii.String("statusCode"),

				// the properties below are optional
				ResponseModels: map[string]IModel{
					"responseModelsKey": model,
				},
				ResponseParameters: map[string]*bool{
					"responseParametersKey": jsii.Boolean(false),
				},
			},
		},
		OperationName: jsii.String("operationName"),
		RequestModels: map[string]IModel{
			"requestModelsKey": model,
		},
		RequestParameters: map[string]*bool{
			"requestParametersKey": jsii.Boolean(false),
		},
		RequestValidator: requestValidator,
		RequestValidatorOptions: &RequestValidatorOptions{
			RequestValidatorName: jsii.String("requestValidatorName"),
			ValidateRequestBody: jsii.Boolean(false),
			ValidateRequestParameters: jsii.Boolean(false),
		},
	},
}
```

## Properties

- `defaultCorsPreflightOptions`: [CorsOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.CorsOptions.html) — Adds a CORS preflight OPTIONS method to this resource and all child resources.

  **Default:** CORS is disabled

  You can add CORS at the resource-level using `addCorsPreflight`.

- `defaultIntegration`: [Integration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.Integration.html) — An integration to use as a default for all methods created within this API unless an integration is specified.

  **Default:** Inherited from parent.

- `defaultMethodOptions`: [MethodOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.MethodOptions.html) — Method options to use as a default for all methods created within this API unless custom options are specified.

  **Default:** Inherited from parent.

- `parent`: [IResource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.IResource.html) (required) — The parent resource of this resource.

  You can either pass another
  `Resource` object or a `RestApi` object here.

- `pathPart`: string (required) — A path name for the resource.
