ALIYUN::APIG::Operation

ALIYUN::APIG::Operation类型用于为HTTP API创建接口。

语法

{
  "Type": "ALIYUN::APIG::Operation",
  "Properties": {
    "HttpApiId": String,
    "Method": String,
    "OperationName": String,
    "Path": String,
    "Description": String,
    "Mock": Map
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

HttpApiId

String

创建接口所属的 HTTP API ID。

Method

String

方法。

枚举值:

  • TRACE:TRACE。

  • HEAD:HEAD。

  • DELETE:DELETE。

  • POST:POST。

  • GET:GET。

  • CONNECT:CONNECT。

  • OPTIONS:OPTIONS。

  • PUT:PUT。

  • PATCH:PATCH。

OperationName

String

接口名称。

Path

String

接口路径。

Description

String

接口描述。

Mock

Map

接口 Mock 配置。

仅当 API 发布场景为 Mock 时生效。更多信息,请参见Mock属性

Mock语法

"Mock": {
  "ResponseContent": String,
  "ResponseCode": Integer,
  "Enable": Boolean
}

Mock属性

属性名称

类型

必须

允许更新

描述

约束

ResponseCode

Integer

响应码。

Enable

Boolean

是否启用 Mock。

ResponseContent

String

响应内容。

返回值

Fn::GetAtt

  • Path:接口路径。

  • Description:接口描述。

  • OperationName:接口名称。

  • OperationId:接口ID。

  • CreateTime:接口的创建时间。

  • Method:接口方法。

  • Mock:接口 Mock 参数配置

示例

ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
  ExtensionResource:
    Type: ALIYUN::APIG::Operation
    Properties:
      HttpApiId: api-csxxxxxxxxx
      OperationName: GetUserInfo2
      Path: /user
      Method: GET
Outputs:
  Path:
    Description: The interface path of the operation.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Path
  Description:
    Description: The description of the operation.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Description
  OperationName:
    Description: The name of the resource.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - OperationName
  OperationId:
    Description: The ID of the operation.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - OperationId
  CreateTime:
    Description: The creation timestamp of the operation.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - CreateTime
  Method:
    Description: The method of http protocol.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Method
  Mock:
    Description: Mock configuration.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Mock
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
  },
  "Resources": {
    "ExtensionResource": {
      "Type": "ALIYUN::APIG::Operation",
      "Properties": {
        "HttpApiId": "api-csxxxxxxxxx",
        "OperationName": "GetUserInfo2",
        "Path": "/user",
        "Method": "GET"
      }
    }
  },
  "Outputs": {
    "Path": {
      "Description": "The interface path of the operation.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Path"
        ]
      }
    },
    "Description": {
      "Description": "The description of the operation.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Description"
        ]
      }
    },
    "OperationName": {
      "Description": "The name of the resource.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "OperationName"
        ]
      }
    },
    "OperationId": {
      "Description": "The ID of the operation.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "OperationId"
        ]
      }
    },
    "CreateTime": {
      "Description": "The creation timestamp of the operation.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "CreateTime"
        ]
      }
    },
    "Method": {
      "Description": "The method of http protocol.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Method"
        ]
      }
    },
    "Mock": {
      "Description": "Mock configuration.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Mock"
        ]
      }
    }
  }
}