Creating a Custom Event Source
Function
This API is used to create a custom event source, which must use a custom event channel.
URI
POST /v1/{project_id}/sources
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        project_id  | 
      
        Yes  | 
      
        String  | 
      
        Tenant resource space ID.  | 
     
Request Parameters
| 
        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.  | 
     
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        name  | 
      
        Yes  | 
      
        String  | 
      
        Name of the custom event source. The value must be unique under a tenant. Only lowercase letters, digits, periods (.), underscores (_), and hyphens (-) are allowed. It must start with a letter or digit and cannot start with hc..  | 
     
| 
        description  | 
      
        No  | 
      
        String  | 
      
        Description of the event source.  | 
     
| 
        channel_id  | 
      
        No  | 
      
        String  | 
      
        ID of the event channel to which the event source belongs.  | 
     
| 
        type  | 
      
        No  | 
      
        String  | 
      
        Type of the event source.  | 
     
| 
        detail  | 
      
        No  | 
      
        RocketMqDetail object  | 
      
        Message instance connection information encapsulated in JSON format.  | 
     
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        instance_id  | 
      
        No  | 
      
        String  | 
      
        RocketMQ instance ID.  | 
     
| 
        group  | 
      
        Yes  | 
      
        String  | 
      
        Consumer group.  | 
     
| 
        topic  | 
      
        Yes  | 
      
        String  | 
      
        Topic  | 
     
| 
        access_key  | 
      
        Yes  | 
      
        String  | 
      
        Username.  | 
     
| 
        secret_key  | 
      
        Yes  | 
      
        String  | 
      
        Secret key.  | 
     
| 
        vpc_id  | 
      
        No  | 
      
        String  | 
      
        VPC ID.  | 
     
| 
        subnet_id  | 
      
        No  | 
      
        String  | 
      
        Subnet ID.  | 
     
| 
        namesrv_address  | 
      
        No  | 
      
        String  | 
      
        Connection address.  | 
     
| 
        ssl_enable  | 
      
        No  | 
      
        Boolean  | 
      
        SSL  | 
     
| 
        enable_acl  | 
      
        No  | 
      
        Boolean  | 
      
        Indicates whether to enable ACL.  | 
     
Response Parameters
Status code: 200
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        X-Request-Id  | 
      
        String  | 
      
        This field is the request ID number for task tracking. Format is request_uuid-timestamp-hostname.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        id  | 
      
        String  | 
      
        ID of the event source.  | 
     
| 
        name  | 
      
        String  | 
      
        Name of the event source.  | 
     
| 
        label  | 
      
        String  | 
      
        Label of the event source.  | 
     
| 
        description  | 
      
        String  | 
      
        Description of the event source.  | 
     
| 
        provider_type  | 
      
        String  | 
      
        Type of the event source provider, which can be OFFICIAL (official cloud service event source), CUSTOM (custom event source), or PARTNER (partner event source).  | 
     
| 
        event_types  | 
      
        Array of event_types objects  | 
      
        List of event types provided by the event source. Only the official cloud service event source provides event types.  | 
     
| 
        created_time  | 
      
        String  | 
      
        UTC time when the event source is created.  | 
     
| 
        updated_time  | 
      
        String  | 
      
        UTC time when the event source is updated.  | 
     
| 
        channel_id  | 
      
        String  | 
      
        ID of the event channel to which the event source belongs.  | 
     
| 
        channel_name  | 
      
        String  | 
      
        Name of the event channel to which the event source belongs.  | 
     
| 
        type  | 
      
        String  | 
      
        Type of the event source.  | 
     
| 
        detail  | 
      
        Object  | 
      
        Connection information encapsulated in JSON format in the message instance, such as the instance_id field of the RabbitMQ instance, vhost field of the virtual host, queue field, username, and password.  | 
     
| 
        status  | 
      
        String  | 
      
        Status of the custom event source.  | 
     
| 
        error_info  | 
      
        ErrorInfo object  | 
      
        Error message.  | 
     
Example Requests
Create a custom event source.
POST https://{endpoint}/v1/{project_id}/sources
{
  "name" : "first-source",
  "description" : "first event source",
  "channel_id" : "bd14144e-8f3c-43d6-bdfd-bf09b52c2b96",
  "type" : "RABBITMQ"
}
 Example Responses
Status code: 200
Operation successful.
{
  "id" : "90e0b962-c6c1-438c-ba8a-3024fe592bda",
  "name" : "first-source",
  "label" : "first-source",
  "description" : "first event source",
  "provider_type" : "CUSTOM",
  "event_types" : [ {
    "name" : "OBS:CloudTrace:ApiCall",
    "description" : "Service API call type event."
  } ],
  "created_time" : "2021-12-09 09:00:00",
  "updated_time" : "2021-12-09 09:00:00",
  "channel_id" : "bd14144e-8f3c-43d6-bdfd-bf09b52c2b96",
  "channel_name" : "channel",
  "type" : "RABBITMQ",
  "detail" : "{\"instance_id\":\"ac14144e-9v3c-43d6-acfd-bf09b52c98uy\",\"user_name\":\"rabbitmq_user\",\"password\":\"changeme\",\"vhost_name\":\"vhost_name\",\"queue_name\":\"queue_name\"}",
  "status" : "RUNNING",
  "error_info" : { }
}
 Status Codes
| 
        Status Code  | 
      
        Description  | 
     
|---|---|
| 
        200  | 
      
        Operation successful.  | 
     
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.