Updated on 2023-08-11 GMT+08:00

APIG.API

Element Description

API providers configure APIs in API gateways to open backend capabilities. An API is divided into two parts. The first part is oriented to API users and defines how to invoke the API. The second part is oriented to API providers and defines the backend status of the API and how to access backend services through an API gateway.

Element Properties

Table 1 Property Description

Property

Required

Descripiton

mockInfo

No

Mock backend details

Type: APIG.MockInfo

Value Description: For details, see the definition of the datatype.

Default: {}

Suggestion: None

reqMethod

Yes

API request mode

Type: string

Value Description: Supports the following methods: GET, POST, PATCH, DELETE, OPTIONS, PUT, HEAD, and ANY.

Default: GET

Value Constraint: Supports "GET", "POST", "DELETE", "PUT", "PATCH", "HEAD", "OPTIONS", "ANY"

Suggestion: None

name

Yes

API group name

Type: string

Value Description: Supports customization.

Value Constraint: Supports a string of 3-64 characters. This string consists of Chinese characters, letters, digits, and underscores (_), and starts with a letter.

Suggestion: None

backendType

Yes

Backend type

Type: string

Value Description: HTTP: a web backend; FUNCTION: a function workflow; MOCK: a simulated backend

Default: HTTP

Value Constraint: Supports HTTP, FUNCTION, MOCK

Suggestion: None

remark

No

API description

Type: string

Value Description: Indicates the API description,Ensure that the length does not exceed 255 characters.

Value Constraint: Supports a maximum of 255 characters.

Suggestion: None

backendApi

No

Web backend details

Type: APIG.BackendApi

Value Description: For details, see the definition of the datatype.

Default: {u'reqUri': u'unset', u'reqMethod': u'GET', u'urlDomain': u'unset', u'reqProtocol': u'HTTP'}

Suggestion: None

groupId

Yes

Group to which the API belongs

Type: HuaweiCloud.APIG.ApiGroup.Id

Value Description: Supports the use of an existing or new API group. To use a new API group, define the API group object in the template and establish the dependency relationship. You are advised to drag the object to the API group to automatically establish the dependency relationship.

Suggestion: Use the get_input function to pass this parameter. Its value can then be automatically selected when you create a stack on the AOS console. Use the get_reference function to reference an APIG.ApiGroup element created by the current stack. The group ID can then be automatically specified when you use the designer to create a dependency on the APIG.ApiGroup element. Go to the API Gateway console and obtain the IDs of existing API groups.

reqUri

Yes

API access mode

Type: string

Value Description: Indicates the API access address.

Value Constraint: Supports a maximum of 255 characters.

Suggestion: Comply with the URI specifications.

authType

Yes

API authentication mode

Type: string

Value Description: NONE: no authentication; APP: app authentication; IAM: IAM authentication

Default: IAM

Value Constraint: The value can be NONE, APP, or IAM.

Suggestion: Use the IAM authentication mode.

matchMode

Yes

API matching mode

Type: string

Value Description: SWA: prefix match; NORMAL: full match

Default: NORMAL

Value Constraint: Supports "SWA", "NORMAL"

Suggestion: None

cors

Yes

Whether cross-domain access is supported

Type: boolean

Value Description: true: Cross-origin resource sharing (CORS) is supported. false: CORS is not supported.

Default: False

Suggestion: Unless required by services, you are advised to disable cross-domain access to ensure security.

funcInfo

No

Function computation backend details

Type: APIG.FuncInfo

Value Description: For details, see the definition of the datatype.

Default: {u'functionUrn': u'', u'invocationType': u'async'}

Suggestion: None

type

Yes

API type

Type: string

Value Description: public: public API; private: private API

Default: public

Value Constraint: Supports "public", "private"

Suggestion: None

strategyId

No

Process policy used by the API

Type: string

Value Description: Supports the use of an existing or new request throttling policy. To use a new request throttling policy, define the API policy object in the template and establish the dependency relationship. You are advised to connect the API to the API policy.

Suggestion: Use the get_input function to pass this parameter. Its value can then be automatically selected when you create a stack on the AOS console. Use the get_reference function to reference an APIG.Throttle element created by the current stack. The group ID can then be automatically specified when you use the designer to create a dependency on the APIG.Throttle element. Go to the API Gateway console and obtain the IDs of existing API groups.

reqProtocol

Yes

API protocol type

Type: string

Value Description: Supports HTTP and HTTPS, or BOTH.

Default: HTTP

Value Constraint: Supports "HTTP", "HTTPS", "BOTH"

Suggestion: If sensitive information needs to be transferred, you are advised to use HTTPS.

Relationships Between Elements

Table 2 Relationship description

Description

Target

Connected

APIG.Throttle

ContainedIn

APIG.ApiGroup

Return Value

Property

Type

Description

reqUri

string

API Uri

reqMethod

string

API Method

refID

string

API ID

reqProtocol

string

API Protocol

Blueprint Example

inputs:
  apiName:
    default: api321b
  apigroupName:
    default: test_group321b
  throttleName:
    default: throttle321
node_templates:
  throttle1:
    type: HuaweiCloud.APIG.Throttle
    properties:
      name: 
        get_input: throttleName
      remark: test throttle of aos plugin
      apiCallLimits: 10
      appCallLimits: 7
      userCallLimits: 9
      timeInterval: 100
      timeUnit: MINUTE     
  api-group1:
    properties:
      name:
        get_input: apigroupName
      remark: test group of aos plugin
    type: HuaweiCloud.APIG.ApiGroup
  api1:
    properties:
      authType: NONE
      backendApi:
        remark: test backend
        reqMethod: GET
        reqProtocol: HTTP
        reqUri: '/test/{aaa}'
        timeout: 10000
        urlDomain: 192.145.47.226:12346
      backendType: HTTP
      cors: false
      groupId:
        get_attribute:
          - api-group1
          - refID
      matchMode: NORMAL
      name:
        get_input: apiName
      remark: test api of aos plugin
      reqMethod: GET
      reqProtocol: HTTP
      reqUri: '/test/{aaa}'
      strategyId: 
        get_attribute:
          - throttle1
          - refID
    requirements:
      - groupId:
          node: api-group1
      - strategyId:
          node: throttle1
    type: HuaweiCloud.APIG.API
tosca_definitions_version: huaweicloud_tosca_version_1_0