UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

179 lines 7.07 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.MethodResponse = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Provides an HTTP Method Response for an API Gateway Resource. More information about API Gateway method responses can be found in the [Amazon API Gateway Developer Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-settings-method-response.html). * * ## Example Usage * * ### Basic Response * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const myDemoAPI = new aws.apigateway.RestApi("MyDemoAPI", { * name: "MyDemoAPI", * description: "This is my API for demonstration purposes", * }); * const myDemoResource = new aws.apigateway.Resource("MyDemoResource", { * restApi: myDemoAPI.id, * parentId: myDemoAPI.rootResourceId, * pathPart: "mydemoresource", * }); * const myDemoMethod = new aws.apigateway.Method("MyDemoMethod", { * restApi: myDemoAPI.id, * resourceId: myDemoResource.id, * httpMethod: "GET", * authorization: "NONE", * }); * const myDemoIntegration = new aws.apigateway.Integration("MyDemoIntegration", { * restApi: myDemoAPI.id, * resourceId: myDemoResource.id, * httpMethod: myDemoMethod.httpMethod, * type: "MOCK", * }); * const response200 = new aws.apigateway.MethodResponse("response_200", { * restApi: myDemoAPI.id, * resourceId: myDemoResource.id, * httpMethod: myDemoMethod.httpMethod, * statusCode: "200", * }); * ``` * * ### Response with Custom Header and Model * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const myDemoAPI = new aws.apigateway.RestApi("MyDemoAPI", { * name: "MyDemoAPI", * description: "This is my API for demonstration purposes", * }); * const myDemoResource = new aws.apigateway.Resource("MyDemoResource", { * restApi: myDemoAPI.id, * parentId: myDemoAPI.rootResourceId, * pathPart: "mydemoresource", * }); * const myDemoMethod = new aws.apigateway.Method("MyDemoMethod", { * restApi: myDemoAPI.id, * resourceId: myDemoResource.id, * httpMethod: "GET", * authorization: "NONE", * }); * const myDemoIntegration = new aws.apigateway.Integration("MyDemoIntegration", { * restApi: myDemoAPI.id, * resourceId: myDemoResource.id, * httpMethod: myDemoMethod.httpMethod, * type: "MOCK", * }); * const myDemoResponseModel = new aws.apigateway.Model("MyDemoResponseModel", { * restApi: myDemoAPI.id, * name: "MyDemoResponseModel", * description: "API response for MyDemoMethod", * contentType: "application/json", * schema: JSON.stringify({ * $schema: "http://json-schema.org/draft-04/schema#", * title: "MyDemoResponse", * type: "object", * properties: { * Message: { * type: "string", * }, * }, * }), * }); * const response200 = new aws.apigateway.MethodResponse("response_200", { * restApi: myDemoAPI.id, * resourceId: myDemoResource.id, * httpMethod: myDemoMethod.httpMethod, * statusCode: "200", * responseModels: { * "application/json": "MyDemoResponseModel", * }, * responseParameters: { * "method.response.header.Content-Type": false, * "method-response-header.X-My-Demo-Header": false, * }, * }); * ``` * * ## Import * * Using `pulumi import`, import `aws_api_gateway_method_response` using `REST-API-ID/RESOURCE-ID/HTTP-METHOD/STATUS-CODE`. For example: * * ```sh * $ pulumi import aws:apigateway/methodResponse:MethodResponse example 12345abcde/67890fghij/GET/200 * ``` */ class MethodResponse extends pulumi.CustomResource { /** * Get an existing MethodResponse resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new MethodResponse(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of MethodResponse. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === MethodResponse.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["httpMethod"] = state?.httpMethod; resourceInputs["region"] = state?.region; resourceInputs["resourceId"] = state?.resourceId; resourceInputs["responseModels"] = state?.responseModels; resourceInputs["responseParameters"] = state?.responseParameters; resourceInputs["restApi"] = state?.restApi; resourceInputs["statusCode"] = state?.statusCode; } else { const args = argsOrState; if (args?.httpMethod === undefined && !opts.urn) { throw new Error("Missing required property 'httpMethod'"); } if (args?.resourceId === undefined && !opts.urn) { throw new Error("Missing required property 'resourceId'"); } if (args?.restApi === undefined && !opts.urn) { throw new Error("Missing required property 'restApi'"); } if (args?.statusCode === undefined && !opts.urn) { throw new Error("Missing required property 'statusCode'"); } resourceInputs["httpMethod"] = args?.httpMethod; resourceInputs["region"] = args?.region; resourceInputs["resourceId"] = args?.resourceId; resourceInputs["responseModels"] = args?.responseModels; resourceInputs["responseParameters"] = args?.responseParameters; resourceInputs["restApi"] = args?.restApi; resourceInputs["statusCode"] = args?.statusCode; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(MethodResponse.__pulumiType, name, resourceInputs, opts); } } exports.MethodResponse = MethodResponse; /** @internal */ MethodResponse.__pulumiType = 'aws:apigateway/methodResponse:MethodResponse'; //# sourceMappingURL=methodResponse.js.map