ALIYUN::APIG::HttpApi

更新时间:
复制 MD 格式

ALIYUN::APIG::HttpApi类型用于创建HTTP API。

语法

{
  "Type": "ALIYUN::APIG::HttpApi",
  "Properties": {
    "AuthConfig": Map,
    "AgentProtocols": List,
    "ResourceGroupId": String,
    "Strategy": String,
    "EnableAuth": Boolean,
    "BelongGatewayId": String,
    "IngressConfig": Map,
    "ModelCategory": String,
    "VersionConfig": Map,
    "OnlyChangeConfig": Boolean,
    "RemoveBasePathOnForward": Boolean,
    "FirstByteTimeout": Integer,
    "DeployConfigs": List,
    "BuiltinRouteNames": List,
    "AiProtocols": List,
    "HttpApiName": String,
    "Protocols": List,
    "BasePath": String,
    "Description": String,
    "Type": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

HttpApiName

String

API 名称。

无。

AgentProtocols

List

代理支持的协议列表

AiProtocols

List

AI 协议列表。

AuthConfig

Map

权限认证配置

更多信息,请参考AuthConfig属性

BasePath

String

API 基础路径。

需要以/开头。

BelongGatewayId

String

所属网关 ID

BuiltinRouteNames

List

内置路由名称列表

DeployConfigs

List

API 部署配置列表。

更多信息,请参考DeployConfigs属性

Description

String

API 描述。

无。

EnableAuth

Boolean

是否开启权限认证

FirstByteTimeout

Integer

首字节超时时间

IngressConfig

Map

HTTP Ingress API 配置信息。

更多信息,请参考IngressConfig属性

ModelCategory

String

模型类别

OnlyChangeConfig

Boolean

仅修改配置

Protocols

List

API 访问协议列表。

取值:

  • HTTP

  • HTTPS

RemoveBasePathOnForward

Boolean

转发时是否移除基础路径

ResourceGroupId

String

资源组 ID。

Strategy

String

导入的冲突合并策略

Type

String

HTTP API 的类型。

取值:

  • Http

  • Rest

  • WebSocket

  • HttpIngress

VersionConfig

Map

API 版本化配置

更多信息,请参考VersionConfig属性

AuthConfig语法

"AuthConfig":{
  "AuthType": String,
  "AuthMode": String
}

AuthConfig属性

属性名称

类型

必须

允许更新

描述

约束

AuthMode

String

认证模式

AuthType

String

认证类型

VersionConfig语法

"VersionConfig":{
  "Enable": Boolean,
  "QueryName": String,
  "HeaderName": String,
  "Scheme": String,
  "Version": String
}

VersionConfig属性

属性名称

类型

必须

允许更新

描述

约束

Enable

Boolean

是否启用版本化控制。

HeaderName

String

Header 版本化方案时,指定的 Header 参数中的 Key。

QueryName

String

Query 版本化方案时,指定的 Query 参数中的 Key。

Scheme

String

版本化方案。

取值:

  • Path:Path。

  • Query:Query。

  • Header:Header。

Version

String

版本号。

IngressConfig语法

"IngressConfig":{
  "EnvironmentId": String,
  "WatchNamespace": String,
  "OverrideIngressIp": Boolean,
  "ClusterId": String,
  "IngressClass": String,
  "SourceId": String
}

IngressConfig属性

属性名称

类型

必须

允许更新

描述

约束

ClusterId

String

集群 ID。

EnvironmentId

String

环境 ID。

IngressClass

String

监听的 Ingress Class。

OverrideIngressIp

Boolean

是否更新 Ingress Status 里的地址。

SourceId

String

来源 ID。

WatchNamespace

String

监听的命名空间。

DeployConfigs语法

"DeployConfigs":
[{
  "AutoDeploy": Boolean,
  "Mock": Map,
  "GatewayType": String,
  "GatewayInfo": Map,
  "ServiceConfigs": List,
  "BackendScene": String,
  "CustomDomainIds": List,
  "SubDomains": List,
  "PolicyConfigs": List,
  "EnvironmentId": String,
  "CustomDomainInfos": List,
  "RouteBackend": Map,
  "GatewayId": String
}]

DeployConfigs属性

属性名称

类型

必须

允许更新

描述

约束

AutoDeploy

Boolean

是否自动部署。

BackendScene

String

发布场景。

CustomDomainIds

List

用户自定义域名 ID 列表。

CustomDomainInfos

List

用户自定义域名内容列表。

更多信息,请参考CustomDomainInfos属性

EnvironmentId

String

环境 ID。

GatewayId

String

网关实例 ID。

GatewayInfo

Map

网关信息。

更多信息,请参考GatewayInfo属性

GatewayType

String

网关类型。

Mock

Map

Mock 配置。

PolicyConfigs

List

策略配置列表。

更多信息,请参考PolicyConfigs属性

RouteBackend

Map

后端服务信息。

ServiceConfigs

List

服务配置列表。

更多信息,请参考ServiceConfigs属性

SubDomains

List

二级域名内容列表。

更多信息,请参考SubDomains属性

GatewayInfo语法

"GatewayInfo":{
  "EngineVersion": String,
  "Name": String,
  "VpcInfo": Map,
  "GatewayId": String
}

GatewayInfo属性

属性名称

类型

必须

允许更新

描述

约束

EngineVersion

String

网关引擎版本。

GatewayId

String

网关 id。

Name

String

网关名称。

VpcInfo

Map

vpc 信息。

更多信息,请参考VpcInfo属性

VpcInfo语法

"VpcInfo":{
  "VpcId": String,
  "Name": String
}

VpcInfo属性

属性名称

类型

必须

允许更新

描述

约束

Name

String

专有网络名称。

VpcId

String

专有网络 ID。

SubDomains语法

"SubDomains":[{
  "DomainId": String,
  "Protocol": String,
  "Name": String,
  "NetworkType": String
}]

SubDomains属性

属性名称

类型

必须

允许更新

描述

约束

DomainId

String

域名 ID。

Name

String

域名名称。

NetworkType

String

网络类型。

Protocol

String

协议。

ServiceConfigs语法

"SubDomains":[{
  "ServiceId": String,
  "PassThroughModelName": Boolean,
  "Name": String,
  "TargetModelName": String
}]

ServiceConfigs属性

属性名称

类型

必须

允许更新

描述

约束

Name

String

服务名称。

PassThroughModelName

Boolean

透传模型名称

ServiceId

String

服务 ID。

TargetModelName

String

目标模型名称。

CustomDomainInfos语法

"CustomDomainInfos":[{
  "DomainId": String,
  "Protocol": String,
  "Name": String
}]

CustomDomainInfos属性

属性名称

类型

必须

允许更新

描述

约束

DomainId

String

域名 ID。

Name

String

域名名称。

Protocol

String

协议。

PolicyConfigs语法

"PolicyConfigs":[{
    "Enable": Boolean,
    "SemanticRouterConfig": Map,
    "AiToolSelectionConfig": Map,
    "AiSecurityGuardConfig": Map,
    "Type": String,
    "AiStatisticsConfig": Map,
    "AiFallbackConfig": Map,
    "AiNetworkSearchConfig": Map,
    "AiTokenRateLimitConfig": Map,
    "AiCacheConfig": Map
}]

PolicyConfigs属性

属性名称

类型

必须

允许更新

描述

约束

AiCacheConfig

Map

AI 缓存配置。

更多信息,请参考AiCacheConfig属性

AiFallbackConfig

Map

AI 降级配置。

更多信息,请参考AiFallbackConfig属性

AiNetworkSearchConfig

Map

AI 网络搜索配置。

更多信息,请参考AiNetworkSearchConfig属性

AiSecurityGuardConfig

Map

AI 安全防护配置。

更多信息,请参考AiSecurityGuardConfig属性

AiStatisticsConfig

Map

AI 统计配置。

更多信息,请参考AiStatisticsConfig属性

AiTokenRateLimitConfig

Map

AI 令牌速率限制配置。

更多信息,请参考AiTokenRateLimitConfig属性

AiToolSelectionConfig

Map

协议。

更多信息,请参考AiToolSelectionConfig属性

Enable

Boolean

是否启用。

SemanticRouterConfig

Map

语义路由配置。

更多信息,请参考SemanticRouterConfig属性

Type

String

策略模板类型。

AiStatisticsConfig语法

"AiStatisticsConfig":{
  "LogResponseContent": Boolean,
  "PathFieldConfigs": List,
  "LogRequestContent": Boolean
}

AiStatisticsConfig属性

属性名称

类型

必须

允许更新

描述

约束

LogRequestContent

Boolean

是否记录请求内容

LogResponseContent

Boolean

是否记录响应内容

PathFieldConfigs

List

自定义字段采集配置列表,按 API 路径维度配置

更多信息,请参考PathFieldConfigs属性

PathFieldConfigs语法

"PathFieldConfigs":{
  "Path": String,
  "FieldPaths": List
}

PathFieldConfigs属性

属性名称

类型

必须

允许更新

描述

约束

FieldPaths

List

字段采集配置。

Path

String

API 路径

AiNetworkSearchConfig语法

"AiNetworkSearchConfig":{
  "SearchFrom": Map,
  "NeedReference": Boolean,
  "SearchRewrite": Map,
  "PluginStatus": Map,
  "DefaultLang": String,
  "DefaultEnable": Boolean,
  "SearchEngineConfig": Map,
  "ReferenceFormat": String,
  "ReferenceLocation": String
}

AiNetworkSearchConfig属性

属性名称

类型

必须

允许更新

描述

约束

DefaultEnable

Boolean

默认启用

DefaultLang

String

默认语言

NeedReference

Boolean

是否需要引用

PluginStatus

Map

插件状态。

更多信息,请参考PluginStatus属性

ReferenceFormat

String

引用格式

ReferenceLocation

String

引用位置

SearchEngineConfig

Map

搜索引擎配置

更多信息,请参考SearchEngineConfig属性

SearchFrom

Map

搜索来源

更多信息,请参考SearchFrom属性

SearchRewrite

Map

搜索重写

更多信息,请参考SearchRewrite属性

SearchFrom语法

"SearchFrom":{
  "OptionArgs": String,
  "Type": String,
  "ApiKey": String,
  "TimeRange": Map,
  "Industry": String,
  "Endpoint": String,
  "ContentMode": String,
  "Start": Integer,
  "TimeoutMillisecond": Integer,
  "Count": Integer
}

SearchFrom属性

属性名称

类型

必须

允许更新

描述

约束

ApiKey

String

API Key

ContentMode

String

内容模式

Count

Integer

统计项数量

Endpoint

String

网关接入点。

Industry

String

实例行业类型

OptionArgs

String

可选参数

Start

Integer

日程开始时间。

TimeoutMillisecond

Integer

超时时间

TimeRange

Map

时间范围

Type

String

类型。

PluginStatus语法

"PluginStatus":{
  "ErrorLogs": String,
  "ServiceHealthy": Boolean,
  "PluginId": String
}

PluginStatus属性

属性名称

类型

必须

允许更新

描述

约束

ErrorLogs

String

错误日志

PluginId

String

插件 ID

ServiceHealthy

String

服务健康状态

SearchEngineConfig语法

"SearchEngineConfig":{
  "OptionArgs": String,
  "Type": String,
  "ApiKey": String,
  "TimeRange": Map,
  "Industry": String,
  "Endpoint": String,
  "ContentMode": String,
  "Start": Integer,
  "TimeoutMillisecond": Integer,
  "Count": Integer
}

SearchEngineConfig属性

属性名称

类型

必须

允许更新

描述

约束

ApiKey

String

API Key

ContentMode

String

内容模式

Count

Integer

数量

Endpoint

String

接入点

Industry

String

实例行业类型

OptionArgs

String

错误日志

Start

Integer

开始时间

TimeoutMillisecond

Integer

超时时间

TimeRange

Map

时间范围

Type

String

插件类型。

SearchRewrite语法

"SearchRewrite":{
  "Enable": Boolean,
  "MaxCount": Integer,
  "ModelName": String,
  "ServiceId": String,
  "TimeoutMillisecond": Integer
}

SearchRewrite属性

属性名称

类型

必须

允许更新

描述

约束

Enable

Boolean

是否启用

MaxCount

Integer

最大数量

ModelName

String

模型名称

ServiceId

String

服务 ID

TimeoutMillisecond

Integer

超时时间

AiFallbackConfig语法

"AiFallbackConfig":{
  "OnlyRedirectUpstreamCode": Boolean,
  "ServiceConfigs": List,
  "RouteEmbedded": Boolean
}

AiFallbackConfig属性

属性名称

类型

必须

允许更新

描述

约束

OnlyRedirectUpstreamCode

Boolean

仅重定向上游编码

RouteEmbedded

Boolean

是否内嵌路由

ServiceConfigs

List

服务配置列表

更多信息,请参考ServiceConfigs属性

AiTokenRateLimitConfig语法

"AiTokenRateLimitConfig":{
  "GlobalRules": List,
  "RedisConfig": Map,
  "PluginStatus": Map,
  "EnableGlobalRules": Boolean,
  "Rules": List
}

AiTokenRateLimitConfig属性

属性名称

类型

必须

允许更新

描述

约束

EnableGlobalRules

Boolean

启用全局规则

GlobalRules

List

全局规则

更多信息,请参考GlobalRules属性

PluginStatus

Map

插件状态。

更多信息,请参考PluginStatus属性

RedisConfig

Map

Redis 配置

更多信息,请参考RedisConfig属性

Rules

List

规则列表

更多信息,请参考Rules属性

Rules语法

"Rules":[{
  "LimitType": String,
  "MatchKey": String,
  "LimitMode": String,
  "LimitValue": Integer,
  "MatchType": String,
  "MatchValue": String
}]

Rules属性

属性名称

类型

必须

允许更新

描述

约束

LimitMode

String

限流模式

LimitType

String

限流类型

LimitValue

String

限流值

MatchKey

String

匹配键

MatchType

String

查询匹配类型

MatchValue

String

匹配值

GlobalRules语法

"GlobalRules":[{
  "LimitType": String,
  "MatchKey": String,
  "LimitMode": String,
  "LimitValue": Integer,
  "MatchType": String,
  "MatchValue": String
}]

GlobalRules属性

属性名称

类型

必须

允许更新

描述

约束

LimitMode

String

限流模式

LimitType

String

限流类型

LimitValue

String

限流值

MatchKey

String

匹配键

MatchType

String

查询匹配类型

MatchValue

String

匹配值

RedisConfig语法

"RedisConfig":{
  "Host": String,
  "Username": String,
  "Port": Integer,
  "Timeout": Integer,
  "DatabaseNumber": Integer,
  "Password": String
}

RedisConfig属性

属性名称

类型

必须

允许更新

描述

约束

DatabaseNumber

Integer

数据库连接数

Host

String

节点的 IP 地址。

Password

String

密码

Port

Integer

端口号

Timeout

Integer

健康检查响应超时时间。

单位:秒。

Username

String

用户名

AiCacheConfig语法

"AiCacheConfig":{
  "CacheTTL": Integer,
  "CacheKeyStrategy": String,
  "VectorConfig": Map,
  "PluginStatus": Map,
  "RedisConfig": Map,
  "EmbeddingConfig": Map,
  "CacheMode": String
}

AiCacheConfig属性

属性名称

类型

必须

允许更新

描述

约束

CacheKeyStrategy

String

缓存键策略

CacheMode

String

缓存模式

CacheTTL

Integer

缓存生存时间(TTL)

EmbeddingConfig

Map

嵌入配置

更多信息,请参考EmbeddingConfig属性

PluginStatus

Map

插件状态。

更多信息,请参考PluginStatus属性

RedisConfig

Map

Redis 配置

更多信息,请参考RedisConfig属性

VectorConfig

Map

向量配置

更多信息,请参考VectorConfig属性

EmbeddingConfig语法

"EmbeddingConfig":{
  "ModelName": String,
  "ServiceId": String,
  "Type": String,
  "Timeout": Integer
}

EmbeddingConfig属性

属性名称

类型

必须

允许更新

描述

约束

ModelName

String

模型名称

ServiceId

String

服务 ID

Timeout

Integer

健康检查响应超时时间。

单位:秒。

Type

String

类型

VectorConfig语法

"VectorConfig":{
  "ApiKey": String,
  "Timeout": Integer,
  "ServiceHost": String,
  "Type": String,
  "Threshold": Number,
  "CollectionId": String
}

VectorConfig属性

属性名称

类型

必须

允许更新

描述

约束

ApiKey

String

API Key

CollectionId

String

集合 ID

ServiceHost

String

服务主机地址

Threshold

Number

阈值

Timeout

Integer

健康检查响应超时时间。

单位:秒。

Type

Integer

类型

AiSecurityGuardConfig语法

"AiSecurityGuardConfig":{
  "RiskConfig": List,
  "ConsumerRequestCheckService": List,
  "RequestImageCheckService": String,
  "CheckResponseImage": Boolean,
  "RiskAlertLevel": String,
  "CheckResponse": Boolean,
  "BufferLimit": Integer,
  "PluginStatus": Map,
  "RequestCheckService": String,
  "CheckRequest": Boolean,
  "ConsumerRiskLevel": List,
  "ResponseCheckService": String,
  "ConsumerResponseCheckService": List,
  "ResponseImageCheckService": String,
  "CheckRequestImage": Boolean,
  "ServiceAddress": String
}

AiSecurityGuardConfig属性

属性名称

类型

必须

允许更新

描述

约束

BufferLimit

Integer

缓冲区大小上限

CheckRequest

Boolean

检查请求

CheckRequestImage

Boolean

检查请求中的图像

CheckResponse

Boolean

检查响应

CheckResponseImage

Boolean

检查响应中的图像

ConsumerRequestCheckService

List

消费者请求校验服务

更多信息,请参考ConsumerRequestCheckService属性

ConsumerResponseCheckService

List

消费者响应校验服务

更多信息,请参考ConsumerResponseCheckService属性

ConsumerRiskLevel

List

消费者风险等级

更多信息,请参考ConsumerRiskLevel属性

PluginStatus

Map

插件当前状态

更多信息,请参考PluginStatus属性

RequestCheckService

String

请求检查服务

RequestImageCheckService

String

请求图像检查服务

ResponseCheckService

String

响应检查服务

ResponseImageCheckService

String

响应图像检查服务

RiskAlertLevel

String

风险告警级别

RiskConfig

List

风险配置

更多信息,请参考RiskConfig属性

ServiceAddress

String

服务地址

ConsumerRiskLevel语法

"ConsumerRiskLevel":[{
  "Level": String,
  "Name": String,
  "Type": String,
  "MatchType": String
}]

ConsumerRiskLevel属性

属性名称

类型

必须

允许更新

描述

约束

Level

String

冲突等级

MatchType

String

查询匹配类型

Name

String

参数名称。

Type

String

类型

RiskConfig语法

"RiskConfig":[{
  "ConsumerRules": Map,
  "Type": String,
  "Level": String
}]

RiskConfig属性

属性名称

类型

必须

允许更新

描述

约束

ConsumerRules

Map

消费者规则

更多信息,请参考ConsumerRules属性

Level

String

冲突等级

Type

String

插件类型。

ConsumerRules语法

"ConsumerRules":{
  "Pattern": String,
  "MatchType": String
}

ConsumerRules属性

属性名称

类型

必须

允许更新

描述

约束

MatchType

String

查询匹配类型

Pattern

String

匹配模式

ConsumerRequestCheckService语法

"ConsumerRequestCheckService":[{
  "RequestCheckService": String,
  "ModalityType": String,
  "MatchType": String,
  "RequestImageCheckService": String,
  "Name": String
}]

ConsumerRequestCheckService属性

属性名称

类型

必须

允许更新

描述

约束

MatchType

String

查询匹配类型

ModalityType

String

模态类型

Name

String

服务名称

RequestCheckService

String

请求校验服务

RequestImageCheckService

String

请求图片校验服务

ConsumerResponseCheckService语法

"ConsumerResponseCheckService":[{
  "ModalityType": String,
  "ResponseCheckService": String,
  "MatchType": String,
  "ResponseImageCheckService": String,
  "Name": String
}]

ConsumerResponseCheckService属性

属性名称

类型

必须

允许更新

描述

约束

MatchType

String

查询匹配类型

ModalityType

String

模态类型

Name

String

服务名称

ResponseCheckService

String

响应检查服务

ResponseImageCheckService

String

响应图像检查服务

SemanticRouterConfig语法

"SemanticRouterConfig":{
  "TimeoutMillisecond": Integer
}

SemanticRouterConfig属性

属性名称

类型

必须

允许更新

描述

约束

TimeoutMillisecond

Integer

超时时间

AiToolSelectionConfig语法

"AiToolSelectionConfig":{
  "EnableConditions": Map,
  "QueryRewriting": Map,
  "ToolReranking": Map,
  "PluginStatus": Map
}

AiToolSelectionConfig属性

属性名称

类型

必须

允许更新

描述

约束

EnableConditions

Map

启用条件

更多信息,请参考EnableConditions属性

PluginStatus

Map

插件状态

更多信息,请参考PluginStatus属性

QueryRewriting

Map

查询重写

更多信息,请参考QueryRewriting属性

ToolReranking

Map

工具重排序

更多信息,请参考ToolReranking属性

QueryRewriting语法

"QueryRewriting":{
  "FallbackStrategy": String,
  "TriggerConditions": Map,
  "ContextSelection": Map,
  "MaxOutputTokens": Integer,
  "ModelService": Map,
  "Enabled": Boolean,
  "PromptConfig": Map
}

QueryRewriting属性

属性名称

类型

必须

允许更新

描述

约束

ContextSelection

Map

上下文选择

更多信息,请参考ContextSelection属性

Enabled

Boolean

是否开启集群审计日志功能。

FallbackStrategy

String

回退策略

MaxOutputTokens

Integer

最大输出令牌数

ModelService

Map

模型服务

更多信息,请参考ModelService属性

PromptConfig

Map

提示词配置

更多信息,请参考PromptConfig属性

TriggerConditions

Map

触发条件

更多信息,请参考TriggerConditions属性

PromptConfig语法

"PromptConfig":{
  "Type": String,
  "CustomPrompt": String
}

PromptConfig属性

属性名称

类型

必须

允许更新

描述

约束

CustomPrompt

String

抽取指令

Type

String

插件类型。

TriggerConditions语法

"TriggerConditions":{
  "MessageCountThreshold": Integer
}

TriggerConditions属性

属性名称

类型

必须

允许更新

描述

约束

MessageCountThreshold

String

消息数量阈值

ContextSelection语法

"ContextSelection":{
  "Type": String,
  "Value": String
}

ContextSelection属性

属性名称

类型

必须

允许更新

描述

约束

Type

String

插件类型。

Value

String

匹配值。

ModelService语法

"ModelService":{
  "ModelName": String,
  "ServiceId": String,
  "TimeoutMillisecond": Integer
}

ModelService属性

属性名称

类型

必须

允许更新

描述

约束

ModelName

String

模型名称

ServiceId

String

服务 ID

TimeoutMillisecond

Integer

超时时间

ToolReranking语法

"ToolReranking":{
  "FallbackStrategy": String,
  "FilteringMethod": String,
  "ScoreThreshold": Number,
  "TopNCount": Integer,
  "ModelService": Map,
  "TopKPercent": Number
}

ToolReranking属性

属性名称

类型

必须

允许更新

描述

约束

FallbackStrategy

String

回退策略

FilteringMethod

String

过滤方法

ModelService

Map

模型服务

更多信息,请参考ModelService属性

ScoreThreshold

Number

分数阈值

TopKPercent

Number

前 K 百分比

TopNCount

Integer

前 N 个数量

EnableConditions语法

"EnableConditions":{
  "ToolCountThreshold": Integer
}

EnableConditions属性

属性名称

类型

必须

允许更新

描述

约束

ToolCountThreshold

Integer

工具数量阈值

返回值

Fn::GetAtt

  • HttpApiId:HTTP API ID。

示例

场景 1 :创建一个HTTP协议的API。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 创建一个HTTP协议的API,适用于内部服务调用或开发测试。
  en: Create an HTTP API for internal service calls or dev/test environments.
Parameters:
  HttpApiName:
    Type: String
    Label:
      zh-cn: API名称
      en: API Name
    Description:
      zh-cn: HTTP API的名称,长度为1~64个字符。
      en: The name of the HTTP API, 1 to 64 characters.
    MinLength: 1
    MaxLength: 64
    AssociationProperty: AutoCompleteInput
    AssociationPropertyMetadata:
      Length: 5
      Prefix: my-api-
      CharacterClasses:
        - Class: lowercase
          min: 1
    Default: my-api
Resources:
  HttpApi:
    Type: ALIYUN::APIG::HttpApi
    Properties:
      HttpApiName:
        Ref: HttpApiName
      Type: Http
      Protocols:
        - HTTP
      BasePath: /
Outputs:
  HttpApiId:
    Label:
      zh-cn: API ID
      en: API ID
    Value:
      Fn::GetAtt:
        - HttpApi
        - HttpApiId
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "创建一个HTTP协议的API,适用于内部服务调用或开发测试。",
    "en": "Create an HTTP API for internal service calls or dev/test environments."
  },
  "Parameters": {
    "HttpApiName": {
      "Type": "String",
      "Label": {
        "zh-cn": "API名称",
        "en": "API Name"
      },
      "Description": {
        "zh-cn": "HTTP API的名称,长度为1~64个字符。",
        "en": "The name of the HTTP API, 1 to 64 characters."
      },
      "MinLength": 1,
      "MaxLength": 64,
      "AssociationProperty": "AutoCompleteInput",
      "AssociationPropertyMetadata": {
        "Length": 5,
        "Prefix": "my-api-",
        "CharacterClasses": [
          {
            "Class": "lowercase",
            "min": 1
          }
        ]
      },
      "Default": "my-api"
    }
  },
  "Resources": {
    "HttpApi": {
      "Type": "ALIYUN::APIG::HttpApi",
      "Properties": {
        "HttpApiName": {
          "Ref": "HttpApiName"
        },
        "Type": "Http",
        "Protocols": [
          "HTTP"
        ],
        "BasePath": "/"
      }
    }
  },
  "Outputs": {
    "HttpApiId": {
      "Label": {
        "zh-cn": "API ID",
        "en": "API ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "HttpApi",
          "HttpApiId"
        ]
      }
    }
  }
}

场景 2 :创建支持HTTPHTTPS双协议的RESTful API,配置版本化基础路径。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 创建REST类型API,支持HTTP和HTTPS双协议,配置版本化基础路径。
  en: Create a RESTful API with both HTTP and HTTPS, with a versioned base path.
Parameters:
  HttpApiName:
    Type: String
    Label:
      zh-cn: API名称
      en: API Name
    Description:
      zh-cn: RESTful API的名称,长度为1~64个字符。
      en: The name of the RESTful API, 1 to 64 characters.
    MinLength: 1
    MaxLength: 64
    AssociationProperty: AutoCompleteInput
    AssociationPropertyMetadata:
      Length: 5
      Prefix: rest-api-
      CharacterClasses:
        - Class: lowercase
          min: 1
    Default: rest-api
  BasePath:
    Type: String
    Label:
      zh-cn: API基础路径
      en: API Base Path
    Description:
      zh-cn: >-
        API的基础路径,需以/开头。建议使用版本号作为路径前缀,
        如/v1、/v2,便于API版本管理。
      en: >-
        The base path of the API, must start with /.
        Using a version prefix like /v1, /v2 is recommended.
    Default: /v1
    AllowedValues:
      - /v1
      - /v2
      - /api/v1
      - /api/v2
  Description:
    Type: String
    Label:
      zh-cn: API描述
      en: API Description
    Description:
      zh-cn: API的功能描述信息。
      en: Functional description of the API.
    Default: 生产环境RESTful API服务
    MaxLength: 256
Resources:
  RestApi:
    Type: ALIYUN::APIG::HttpApi
    Properties:
      HttpApiName:
        Ref: HttpApiName
      Type: Rest
      Protocols:
        - HTTP
        - HTTPS
      BasePath:
        Ref: BasePath
      Description:
        Ref: Description
Outputs:
  HttpApiId:
    Label:
      zh-cn: API ID
      en: API ID
    Value:
      Fn::GetAtt:
        - RestApi
        - HttpApiId
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "创建REST类型API,支持HTTP和HTTPS双协议,配置版本化基础路径。",
    "en": "Create a RESTful API with both HTTP and HTTPS, with a versioned base path."
  },
  "Parameters": {
    "HttpApiName": {
      "Type": "String",
      "Label": {
        "zh-cn": "API名称",
        "en": "API Name"
      },
      "Description": {
        "zh-cn": "RESTful API的名称,长度为1~64个字符。",
        "en": "The name of the RESTful API, 1 to 64 characters."
      },
      "MinLength": 1,
      "MaxLength": 64,
      "AssociationProperty": "AutoCompleteInput",
      "AssociationPropertyMetadata": {
        "Length": 5,
        "Prefix": "rest-api-",
        "CharacterClasses": [
          {
            "Class": "lowercase",
            "min": 1
          }
        ]
      },
      "Default": "rest-api"
    },
    "BasePath": {
      "Type": "String",
      "Label": {
        "zh-cn": "API基础路径",
        "en": "API Base Path"
      },
      "Description": {
        "zh-cn": "API的基础路径,需以/开头。建议使用版本号作为路径前缀,如/v1、/v2,便于API版本管理。",
        "en": "The base path of the API, must start with /. Using a version prefix like /v1, /v2 is recommended."
      },
      "Default": "/v1",
      "AllowedValues": [
        "/v1",
        "/v2",
        "/api/v1",
        "/api/v2"
      ]
    },
    "Description": {
      "Type": "String",
      "Label": {
        "zh-cn": "API描述",
        "en": "API Description"
      },
      "Description": {
        "zh-cn": "API的功能描述信息。",
        "en": "Functional description of the API."
      },
      "Default": "生产环境RESTful API服务",
      "MaxLength": 256
    }
  },
  "Resources": {
    "RestApi": {
      "Type": "ALIYUN::APIG::HttpApi",
      "Properties": {
        "HttpApiName": {
          "Ref": "HttpApiName"
        },
        "Type": "Rest",
        "Protocols": [
          "HTTP",
          "HTTPS"
        ],
        "BasePath": {
          "Ref": "BasePath"
        },
        "Description": {
          "Ref": "Description"
        }
      }
    }
  },
  "Outputs": {
    "HttpApiId": {
      "Label": {
        "zh-cn": "API ID",
        "en": "API ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "RestApi",
          "HttpApiId"
        ]
      }
    }
  }
}

场景 3 :创建WebSocket API并配置HTTPS安全域名,实现实时通信服务。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 创建WebSocket API并配置HTTPS安全域名,实现安全的实时通信服务。
  en: Create a WebSocket API with an HTTPS domain for secure real-time communication.
Parameters:
  HttpApiName:
    Type: String
    Label:
      zh-cn: API名称
      en: API Name
    Description:
      zh-cn: WebSocket API的名称,长度为1~64个字符。
      en: The name of the WebSocket API, 1 to 64 characters.
    MinLength: 1
    MaxLength: 64
    AssociationProperty: AutoCompleteInput
    AssociationPropertyMetadata:
      Length: 5
      Prefix: ws-api-
      CharacterClasses:
        - Class: lowercase
          min: 1
    Default: ws-api
  BasePath:
    Type: String
    Label:
      zh-cn: WebSocket基础路径
      en: WebSocket Base Path
    Description:
      zh-cn: WebSocket API的基础路径,需以/开头。
      en: The base path of the WebSocket API, must start with /.
    Default: /ws
  DomainName:
    Type: String
    Label:
      zh-cn: 域名
      en: Domain Name
    Description:
      zh-cn: >-
        WebSocket服务的域名,例如ws.example.com。
        需已完成域名备案和DNS解析。
      en: >-
        The domain name for WebSocket service, e.g. ws.example.com.
        DNS resolution and ICP filing must be completed.
    AllowedPattern: '^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$'
  CertIdentifier:
    Type: String
    Label:
      zh-cn: SSL证书标识
      en: SSL Certificate Identifier
    Description:
      zh-cn: SSL证书的唯一标识,可在SSL证书服务控制台获取。证书需与域名匹配。
      en: >-
        The unique identifier of the SSL certificate.
        The certificate must match the domain name.
Resources:
  WebSocketApi:
    Type: ALIYUN::APIG::HttpApi
    Properties:
      HttpApiName:
        Ref: HttpApiName
      Type: WebSocket
      Protocols:
        - HTTPS
      BasePath:
        Ref: BasePath
      Description:
        Fn::Sub: WebSocket实时通信API - ${HttpApiName}
  Domain:
    Type: ALIYUN::APIG::Domain
    Properties:
      DomainName:
        Ref: DomainName
      Protocol: HTTPS
      CertIdentifier:
        Ref: CertIdentifier
      ForceHttps: true
      TlsMin: TLS 1.2
      TlsMax: TLS 1.3
      Http2Option: Open
Outputs:
  HttpApiId:
    Label:
      zh-cn: API ID
      en: API ID
    Value:
      Fn::GetAtt:
        - WebSocketApi
        - HttpApiId
  DomainId:
    Label:
      zh-cn: 域名ID
      en: Domain ID
    Value:
      Fn::GetAtt:
        - Domain
        - DomainId
  DomainName:
    Label:
      zh-cn: 域名
      en: Domain Name
    Value:
      Fn::GetAtt:
        - Domain
        - DomainName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "创建WebSocket API并配置HTTPS安全域名,实现安全的实时通信服务。",
    "en": "Create a WebSocket API with an HTTPS domain for secure real-time communication."
  },
  "Parameters": {
    "HttpApiName": {
      "Type": "String",
      "Label": {
        "zh-cn": "API名称",
        "en": "API Name"
      },
      "Description": {
        "zh-cn": "WebSocket API的名称,长度为1~64个字符。",
        "en": "The name of the WebSocket API, 1 to 64 characters."
      },
      "MinLength": 1,
      "MaxLength": 64,
      "AssociationProperty": "AutoCompleteInput",
      "AssociationPropertyMetadata": {
        "Length": 5,
        "Prefix": "ws-api-",
        "CharacterClasses": [
          {
            "Class": "lowercase",
            "min": 1
          }
        ]
      },
      "Default": "ws-api"
    },
    "BasePath": {
      "Type": "String",
      "Label": {
        "zh-cn": "WebSocket基础路径",
        "en": "WebSocket Base Path"
      },
      "Description": {
        "zh-cn": "WebSocket API的基础路径,需以/开头。",
        "en": "The base path of the WebSocket API, must start with /."
      },
      "Default": "/ws"
    },
    "DomainName": {
      "Type": "String",
      "Label": {
        "zh-cn": "域名",
        "en": "Domain Name"
      },
      "Description": {
        "zh-cn": "WebSocket服务的域名,例如ws.example.com。需已完成域名备案和DNS解析。",
        "en": "The domain name for WebSocket service, e.g. ws.example.com. DNS resolution and ICP filing must be completed."
      },
      "AllowedPattern": "^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$"
    },
    "CertIdentifier": {
      "Type": "String",
      "Label": {
        "zh-cn": "SSL证书标识",
        "en": "SSL Certificate Identifier"
      },
      "Description": {
        "zh-cn": "SSL证书的唯一标识,可在SSL证书服务控制台获取。证书需与域名匹配。",
        "en": "The unique identifier of the SSL certificate. The certificate must match the domain name."
      }
    }
  },
  "Resources": {
    "WebSocketApi": {
      "Type": "ALIYUN::APIG::HttpApi",
      "Properties": {
        "HttpApiName": {
          "Ref": "HttpApiName"
        },
        "Type": "WebSocket",
        "Protocols": [
          "HTTPS"
        ],
        "BasePath": {
          "Ref": "BasePath"
        },
        "Description": {
          "Fn::Sub": "WebSocket实时通信API - ${HttpApiName}"
        }
      }
    },
    "Domain": {
      "Type": "ALIYUN::APIG::Domain",
      "Properties": {
        "DomainName": {
          "Ref": "DomainName"
        },
        "Protocol": "HTTPS",
        "CertIdentifier": {
          "Ref": "CertIdentifier"
        },
        "ForceHttps": true,
        "TlsMin": "TLS 1.2",
        "TlsMax": "TLS 1.3",
        "Http2Option": "Open"
      }
    }
  },
  "Outputs": {
    "HttpApiId": {
      "Label": {
        "zh-cn": "API ID",
        "en": "API ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "WebSocketApi",
          "HttpApiId"
        ]
      }
    },
    "DomainId": {
      "Label": {
        "zh-cn": "域名ID",
        "en": "Domain ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "Domain",
          "DomainId"
        ]
      }
    },
    "DomainName": {
      "Label": {
        "zh-cn": "域名",
        "en": "Domain Name"
      },
      "Value": {
        "Fn::GetAtt": [
          "Domain",
          "DomainName"
        ]
      }
    }
  }
}