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

Creating a System Subscription Event

Function

This API is used to create a system subscription event.

URI

POST /v2/{project_id}/routemgr/exchanger/systemevents

Table 1 Path parameter

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Request

Table 2 Parameters in the request header

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. The token can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

ief-instance-id

No

String

Platinum edition instance ID. This parameter is left blank for a professional edition instance.

Content-Type

Yes

String

Message body type (format). The default value is application/json.

Table 3 Parameter in the request body

Parameter

Mandatory

Type

Description

systemevent

No

EventCreateDetail object

Basic information of the system subscription event.

Table 4 EventCreateDetail

Parameter

Mandatory

Type

Description

name

No

String

System subscription event name. The value can contain a maximum of 64 characters, including lowercase letters, digits, underscores (_), and hyphens (-). Names of system subscription events and message rules created under the same account must be unique.

description

No

String

Description. The maximum length is 255 characters. The following characters are not allowed: ^~#$%&*<>()[]{}'"\

events

No

String

System subscription event topic. Each topic consists of edge resource/operation. Multiple topics are separated by commas (,). The following topics are supported:

  • edgeNode/offline: node offline
  • edgeNode/online: node online
  • edgeNode/all: node offline and node online
  • deployment/created: containerized application creation
  • deployment/updated: containerized application update
  • deployment/deleted: containerized application deletion
  • deployment/all: containerized application creation, update, and deletion
  • instance/created: application instance creation
  • instance/updated: application instance update
  • instance/deleted: application instance deletion
  • instance/all: application instance creation, update, and deletion

target

No

String

Destination endpoint ID.

target_resource

No

EndpointResource object

Destination endpoint resource.

Table 5 EndpointResource

Parameter

Mandatory

Type

Description

resource

No

String

Message endpoint resource. Example: - dis: {"channel": "dis channel name"} - servicebus: {"path": "/request path"} - apigw: {"resource": "http://ssss.com"} - eventbus: {"topic": "/xxxx"}

Response

Status code: 201

Table 6 Parameter in the response body

Parameter

Type

Description

systemevent

Event object

Details of the system subscription events.

Table 7 Event

Parameter

Type

Description

id

String

System subscription event ID.

name

String

System subscription event name. The value can contain a maximum of 64 characters, including lowercase letters, digits, underscores (_), and hyphens (-). Names of system subscription events and message rules created under the same account must be unique.

project_id

String

ID of the project to which the system subscription event belongs.

created_at

String

Creation time.

updated_at

String

Update time.

description

String

Description. The value can contain a maximum of 255 characters. The following characters are not allowed: ^~#$%&*<>()[]{}'"\

in_using

Boolean

Whether the system subscription rule is enabled. The default value is true, indicating that the rule is enabled.

events

String

System subscription event topic. Each topic consists of edge resource/operation. Multiple topics are separated by commas (,). The following topics are supported:

  • edgeNode/offline: node offline
  • edgeNode/online: node online
  • edgeNode/all: node offline and node online
  • deployment/created: containerized application creation
  • deployment/updated: containerized application update
  • deployment/deleted: containerized application deletion
  • deployment/all: containerized application creation, update, and deletion
  • instance/created: application instance creation
  • instance/updated: application instance update
  • instance/deleted: application instance deletion
  • instance/all: application instance creation, update, and deletion

target

EndpointObjResp object

Destination endpoint.

target_resource

Map<String,String>

Destination endpoint's resource attribute.

success_messages

Integer

Successful requests.

fail_messages

Integer

Failed requests.

delete_at

Integer

Deletion time.

Table 8 EndpointObjResp

Parameter

Type

Description

created_at

String

Creation time.

description

String

Endpoint description. The value can contain a maximum of 255 characters. The following characters are not allowed: ^~#$%&*<>()[]{}'"\

id

String

Endpoint ID.

ief_instance_id

String

Platinum edition instance ID. This parameter is left blank for a professional edition instance.

is_shared

Boolean

Whether the endpoint is shared.

name

String

Endpoint name. The value can contain a maximum of 64 characters, including letters, digits, underscores (_), and hyphens (-). Endpoint names created under the same account must be unique.

project_id

String

Project ID.

properties

Map<String,Object>

Endpoint properties to be displayed. Example:

  • dis: {"domain_id":"user's domain id"}
  • servicebus: {"service_port":8080}
  • apigw: {"domain_id":"user's domain id"}

type

String

Endpoint type. The options are as follows:

  • dis
  • servicebus
  • apigw

updated_at

String

Update time.

Example Request

A system subscription event with the node online topic is created.

{
  "systemevent" : {
    "name" : "aa",
    "description" : "",
    "events" : "edgeNode/online",
    "target_resource" : {
      "resource" : "https://www.fake.com"
    },
    "target" : "591ba510-8c62-41b8-a0c3-d94262ef97ef"
  }
}

Example Response

Status code: 201

Creation succeeded.

{
  "systemevent" : {
    "id" : "b79f4d8e-4549-4da4-9a9c-a9d13452c7d6",
    "project_id" : "ed202955e111444e8ced21a1bd75fc59",
    "created_at" : "2022-11-02T07:17:01.372735871Z",
    "updated_at" : "2022-11-02T07:17:01.372735998Z",
    "name" : "aa",
    "description" : "",
    "in_using" : true,
    "events" : "edgeNode/online",
    "target" : {
      "name" : "apigw",
      "description" : "",
      "type" : "apigw",
      "properties" : {
        "domain_id" : "d0857ebddc514a7381c3673363e61337"
      },
      "ief_instance_id" : "38898a99-d67c-41f8-a8cb-8c53d6d297ba",
      "is_shared" : false,
      "id" : "591ba510-8c62-41b8-a0c3-d94262ef97ef",
      "project_id" : "ed202955e111444e8ced21a1bd75fc59",
      "created_at" : "2022-06-02T11:15:26.29972+08:00",
      "updated_at" : "2022-06-02T11:15:26.29972+08:00"
    },
    "target_resource" : {
      "resource" : "https://www.fake.com"
    },
    "fail_messages" : 0,
    "success_messages" : 0,
    "delete_at" : 0
  }
}

Status Codes

Status Code

Description

201

Creation succeeded.

Error Codes

For details, see Error Codes.