1 | import { Resource } from '@aws-cdk/core';
|
2 | import { Construct } from 'constructs';
|
3 | import * as jsonSchema from './json-schema';
|
4 | import { IRestApi } from './restapi';
|
5 | export interface IModel {
|
6 | /**
|
7 | * Returns the model name, such as 'myModel'
|
8 | *
|
9 | * @attribute
|
10 | */
|
11 | readonly modelId: string;
|
12 | }
|
13 | /**
|
14 | * Represents a reference to a REST API's Empty model, which is available
|
15 | * as part of the model collection by default. This can be used for mapping
|
16 | * JSON responses from an integration to what is returned to a client,
|
17 | * where strong typing is not required. In the absence of any defined
|
18 | * model, the Empty model will be used to return the response payload
|
19 | * unmapped.
|
20 | *
|
21 | * Definition
|
22 | * {
|
23 | * "$schema" : "http://json-schema.org/draft-04/schema#",
|
24 | * "title" : "Empty Schema",
|
25 | * "type" : "object"
|
26 | * }
|
27 | *
|
28 | * @see https://docs.amazonaws.cn/en_us/apigateway/latest/developerguide/models-mappings.html#models-mappings-models
|
29 | * @deprecated You should use Model.EMPTY_MODEL
|
30 | */
|
31 | export declare class EmptyModel implements IModel {
|
32 | readonly modelId = "Empty";
|
33 | }
|
34 | /**
|
35 | * Represents a reference to a REST API's Error model, which is available
|
36 | * as part of the model collection by default. This can be used for mapping
|
37 | * error JSON responses from an integration to a client, where a simple
|
38 | * generic message field is sufficient to map and return an error payload.
|
39 | *
|
40 | * Definition
|
41 | * {
|
42 | * "$schema" : "http://json-schema.org/draft-04/schema#",
|
43 | * "title" : "Error Schema",
|
44 | * "type" : "object",
|
45 | * "properties" : {
|
46 | * "message" : { "type" : "string" }
|
47 | * }
|
48 | * }
|
49 | * @deprecated You should use Model.ERROR_MODEL
|
50 | */
|
51 | export declare class ErrorModel implements IModel {
|
52 | readonly modelId = "Error";
|
53 | }
|
54 | export interface ModelOptions {
|
55 | /**
|
56 | * The content type for the model. You can also force a
|
57 | * content type in the request or response model mapping.
|
58 | *
|
59 | * @default 'application/json'
|
60 | */
|
61 | readonly contentType?: string;
|
62 | /**
|
63 | * A description that identifies this model.
|
64 | * @default None
|
65 | */
|
66 | readonly description?: string;
|
67 | /**
|
68 | * A name for the model.
|
69 | *
|
70 | * Important
|
71 | * If you specify a name, you cannot perform updates that
|
72 | * require replacement of this resource. You can perform
|
73 | * updates that require no or some interruption. If you
|
74 | * must replace the resource, specify a new name.
|
75 | *
|
76 | * @default <auto> If you don't specify a name,
|
77 | * AWS CloudFormation generates a unique physical ID and
|
78 | * uses that ID for the model name. For more information,
|
79 | * see Name Type.
|
80 | */
|
81 | readonly modelName?: string;
|
82 | /**
|
83 | * The schema to use to transform data to one or more output formats.
|
84 | * Specify null ({}) if you don't want to specify a schema.
|
85 | */
|
86 | readonly schema: jsonSchema.JsonSchema;
|
87 | }
|
88 | export interface ModelProps extends ModelOptions {
|
89 | /**
|
90 | * The rest API that this model is part of.
|
91 | *
|
92 | * The reason we need the RestApi object itself and not just the ID is because the model
|
93 | * is being tracked by the top-level RestApi object for the purpose of calculating it's
|
94 | * hash to determine the ID of the deployment. This allows us to automatically update
|
95 | * the deployment when the model of the REST API changes.
|
96 | */
|
97 | readonly restApi: IRestApi;
|
98 | }
|
99 | export declare class Model extends Resource implements IModel {
|
100 | /**
|
101 | * Represents a reference to a REST API's Error model, which is available
|
102 | * as part of the model collection by default. This can be used for mapping
|
103 | * error JSON responses from an integration to a client, where a simple
|
104 | * generic message field is sufficient to map and return an error payload.
|
105 | *
|
106 | * Definition
|
107 | * {
|
108 | * "$schema" : "http://json-schema.org/draft-04/schema#",
|
109 | * "title" : "Error Schema",
|
110 | * "type" : "object",
|
111 | * "properties" : {
|
112 | * "message" : { "type" : "string" }
|
113 | * }
|
114 | * }
|
115 | */
|
116 | static readonly ERROR_MODEL: IModel;
|
117 | /**
|
118 | * Represents a reference to a REST API's Empty model, which is available
|
119 | * as part of the model collection by default. This can be used for mapping
|
120 | * JSON responses from an integration to what is returned to a client,
|
121 | * where strong typing is not required. In the absence of any defined
|
122 | * model, the Empty model will be used to return the response payload
|
123 | * unmapped.
|
124 | *
|
125 | * Definition
|
126 | * {
|
127 | * "$schema" : "http://json-schema.org/draft-04/schema#",
|
128 | * "title" : "Empty Schema",
|
129 | * "type" : "object"
|
130 | * }
|
131 | *
|
132 | * @see https://docs.amazonaws.cn/en_us/apigateway/latest/developerguide/models-mappings.html#models-mappings-models
|
133 | */
|
134 | static readonly EMPTY_MODEL: IModel;
|
135 | static fromModelName(scope: Construct, id: string, modelName: string): IModel;
|
136 | /**
|
137 | * Returns the model name, such as 'myModel'
|
138 | *
|
139 | * @attribute
|
140 | */
|
141 | readonly modelId: string;
|
142 | constructor(scope: Construct, id: string, props: ModelProps);
|
143 | }
|