models
Creates, updates, deletes or gets a model resource or lists models in a region
Overview
| Name | models |
| Type | Resource |
| Description | The AWS::ApiGatewayV2::Model resource updates data model for a WebSocket API. For more information, see Model Selection Expressions in the API Gateway Developer Guide. |
| Id | awscc.apigatewayv2.models |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
model_id | string | |
description | string | The description of the model. |
content_type | string | The content-type for the model, for example, "application/json". |
schema | object | The schema for the model. For application/json models, this should be JSON schema draft 4 model. |
api_id | string | The API identifier. |
name | string | The name of the model. |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
model_id | string | |
api_id | string | The API identifier. |
region | string | AWS region. |
For more information, see AWS::ApiGatewayV2::Model.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | models | INSERT | ApiId, Schema, Name, region |
delete_resource | models | DELETE | Identifier, region |
update_resource | models | UPDATE | Identifier, PatchDocument, region |
list_resources | models_list_only | SELECT | region |
get_resource | models | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual model.
SELECT
region,
model_id,
description,
content_type,
schema,
api_id,
name
FROM awscc.apigatewayv2.models
WHERE
region = '{{ region }}' AND
Identifier = '{{ api_id }}|{{ model_id }}';
Lists all models in a region.
SELECT
region,
api_id,
model_id
FROM awscc.apigatewayv2.models_list_only
WHERE
region = '{{ region }}';
INSERT example
Use the following StackQL query and manifest file to create a new model resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.apigatewayv2.models (
Schema,
ApiId,
Name,
region
)
SELECT
'{{ schema }}',
'{{ api_id }}',
'{{ name }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
/*+ create */
INSERT INTO awscc.apigatewayv2.models (
Description,
ContentType,
Schema,
ApiId,
Name,
region
)
SELECT
'{{ description }}',
'{{ content_type }}',
'{{ schema }}',
'{{ api_id }}',
'{{ name }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: model
props:
- name: description
value: '{{ description }}'
- name: content_type
value: '{{ content_type }}'
- name: schema
value: {}
- name: api_id
value: '{{ api_id }}'
- name: name
value: '{{ name }}'
UPDATE example
Use the following StackQL query and manifest file to update a model resource, using stack-deploy.
/*+ update */
UPDATE awscc.apigatewayv2.models
SET PatchDocument = string('{{ {
"Description": description,
"ContentType": content_type,
"Schema": schema,
"Name": name
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ api_id }}|{{ model_id }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
DELETE example
/*+ delete */
DELETE FROM awscc.apigatewayv2.models
WHERE
Identifier = '{{ api_id }}|{{ model_id }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
Additional Parameters
Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:
| Parameter | Description |
|---|---|
ClientToken | A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.A client token is valid for 36 hours once used. After that, a resource request with the same client token is treated as a new request. If you do not specify a client token, one is generated for inclusion in the request. |
RoleArn | The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.If you do not specify a role, a temporary session is created using your AWS user credentials. |
TypeVersionId | For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used. |
Permissions
To operate on the models resource, the following permissions are required:
- Create
- Update
- Read
- Delete
- List
apigateway:POST
apigateway:PATCH,
apigateway:GET,
apigateway:PUT
apigateway:GET
apigateway:GET,
apigateway:DELETE
apigateway:GET