Trigger APIs
Prerequisites
- Successfully [Create Enterprise Edition Instance](CCR/Enterprise Edition API Reference/Enterprise Edition Instance APIs.md).
Retrieve trigger policy list
API description
Retrieve the list of trigger policies.
Request structure
1GET /v1/instances/{instanceId}/triggers/policies?policyName={policyName}&pageNo={pageNo}&pageSize={pageSize} HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: authorization string
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| instanceId | String | Yes | Path | Instance ID |
| policyName | String | No | Query | Trigger policy name, supporting fuzzy query |
| pageNo | Integer | No | Query | Current page, defaulting to 1 |
| pageSize | Integer | No | Query | Record count per page, defaulting to 10 |
Response headers
There are no special headers required beyond the common headers.
Response parameters
| Parameter name | Types | Description |
|---|---|---|
| total | Integer | Total trigger policies |
| pageNo | Integer | Current page |
| pageSize | Integer | Records count per page |
| policies | List<[TriggerPolicy](CCR/Enterprise Edition API Reference/Appendix.md#TriggerPolicy)> | Trigger policy object list |
Request example
1GET /v1/instances/ccr-test/triggers/policies?policyName=trigger-test&pageNo=1&pageSize=10 HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: bce-auth-v1/123456/2022-08-01T08:26:41Z/1800/host/0a859ce949951fe15a4eb6874a9765f9e8a6f7147f206cf47e270c34c862b8c6
Response example
1HTTP/1.1 200 OK
2Content-Type: application/json; charset=utf-8
3Date: Fri, 05 Aug 2022 07:23:56 GMT
4X-Bce-Gateway-Region: BJ
5X-Bce-Request-Id: 9de1d766-a5de-46c0-a40c-29e916410d22
6
7{
8 "total": 1,
9 "pageNo": 1,
10 "pageSize": 10,
11 "policies": [
12 {
13 "creationTime": "2022-08-05T07:20:32.098378Z",
14 "description": "trigger-test",
15 "enabled": true,
16 "eventTypes": [
17 "UPLOAD_CHART",
18 "DOWNLOAD_CHART",
19 "DELETE_CHART"
20 ],
21 "filters": [
22 {
23 "type": "project_name",
24 "value": "ns-test"
25 },
26 {
27 "type": "repository_name",
28 "value": "ubuntu"
29 },
30 {
31 "type": "tag_name",
32 "value": "18.02"
33 }
34 ],
35 "id": 2,
36 "name": "trigger-test",
37 "targets": [
38 {
39 "address": "http://baidu.com",
40 "headers": {
41 "Authorization": "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
42 }
43 }
44 ],
45 "updateTime": "2022-08-05T07:20:32.098378Z"
46 }
47 ]
48}
Query trigger policy details
API description
Query details of a specific trigger policy.
Request structure
1GET /v1/instances/{instanceId}/triggers/policies/{policyId} HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: authorization string
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| instanceId | String | Yes | Path | CCR instance ID |
| policyId | String | Yes | Path | Trigger policy ID |
Response headers
There are no special headers required beyond the common headers.
Response parameters
| Parameter name | Types | Description |
|---|---|---|
| creationTime | String | Trigger creation time |
| description | String | Trigger policy notes |
| enabled | Boolean | Enabling status |
| eventTypes | List |
Trigger event list, response value definitions: UPLOAD_CHART (Push Helm Chart) DOWNLOAD_CHART (Pull Helm Chart) DELETE_CHART (Delete Helm Chart) PUSH_ARTIFACT (Push Artifact) PULL_ARTIFACT (Pull Artifact) DELETE_ARTIFACT (Delete Artifact) |
| filters | List<[TriggerFilter](CCR/Enterprise Edition API Reference/Appendix.md#TriggerFilter)> | Trigger rules |
| id | Integer | Trigger ID |
| name | String | Trigger name |
| targets | List<[TriggerTarget](CCR/Enterprise Edition API Reference/Appendix.md#TriggerTarget)> | Access configuration |
| updateTime | String | Trigger update time |
Request example
1GET /v1/instances/ccr-test/triggers/policies/1 HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: bce-auth-v1/123456/2022-08-01T13:07:36Z/1800/host/0a859ce949951fe15a4eb6874a9765f9e8a6f7147f206cf47e270c34c862b8c6
Response example
1HTTP/1.1 200 OK
2Content-Type: application/json; charset=utf-8
3Date: Fri, 05 Aug 2022 13:04:25 GMT
4X-Bce-Gateway-Region: BJ
5X-Bce-Request-Id: 847e178c-474a-4083-9b45-02b2bc34c925
6
7{
8 "creationTime": "2022-08-05T07:19:05.797801Z",
9 "description": "Trigger test",
10 "enabled": true,
11 "eventTypes": [
12 "PUSH_ARTIFACT",
13 "PULL_ARTIFACT",
14 "DELETE_ARTIFACT"
15 ],
16 "filters": [
17 {
18 "type": "project_name",
19 "value": "ns-test"
20 },
21 {
22 "type": "repository_name",
23 "value": "ubuntu"
24 },
25 {
26 "type": "tag_name",
27 "value": "18.052"
28 }
29 ],
30 "id": 1,
31 "name": "trigger-test1",
32 "targets": [
33 {
34 "address": "http://baidu.com",
35 "headers": {
36 "Authorization": "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
37 }
38 }
39 ],
40 "updateTime": "2022-08-05T07:19:05.797801Z"
41}
Create trigger policy
API description
Create a trigger policy.
Request structure
1POST /v1/instances/{instanceId}/triggers/policies HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: authorization string
4
5{
6 "description": {description},
7 "eventTypes": {eventTypes},
8 "filters": {filters},
9 "name": {name},
10 "targets": {targets}
11}
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| instanceId | String | Yes | Path | CCR instance ID |
| description | String | No | Body | Trigger policy notes |
| eventTypes | List |
Yes | Body | Trigger event list, valid values are: UPLOAD_CHART (Push Helm Chart) DOWNLOAD_CHART (Pull Helm Chart) DELETE_CHART (Delete Helm Chart) PUSH_ARTIFACT (Push Artifact) PULL_ARTIFACT (Pull Artifact) DELETE_ARTIFACT (Delete Artifact) |
| filters | List<[TriggerFilter](CCR/Enterprise Edition API Reference/Appendix.md#TriggerFilter)> | No | Body | Trigger rules |
| name | String | Yes | Body | Trigger name |
| targets | List<[TriggerTarget](CCR/Enterprise Edition API Reference/Appendix.md#TriggerTarget)> | No | Body | Access configuration |
Response headers
There are no special headers required beyond the common headers.
Response parameters
If the request is successful, no response parameters are returned. In case of failure, a standard error structure is provided.
Request example
1POST /v1/instances/ccr-test/triggers/policies HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: bce-auth-v1/123456/2022-08-01T13:07:36Z/1800/host/0a859ce949951fe15a4eb6874a9765f9e8a6f7147f206cf47e270c34c862b8c6
4
5{
6 "description": "Trigger test",
7 "eventTypes": [
8 "PUSH_ARTIFACT"
9 ],
10 "filters": [
11 {
12 "type": "project_name",
13 "value": "ns-test"
14 }
15 ],
16 "name": "trigger-test",
17 "targets": [
18 {
19 "address": "http://baidu.com",
20 "headers": {
21 "Authorization": "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
22 }
23 }
24 ]
25}
Response example
1HTTP/1.1 200 OK
2Content-Type: text/plain; charset=utf-8
3Date: Mon, 08 Aug 2022 06:48:43 GMT
4X-Bce-Gateway-Region: BJ
5X-Bce-Request-Id: a89e0780-2b4c-44d2-84e8-ce55883a5cb7
Modify trigger policy
API description
Modify an existing trigger policy.
Request structure
1PUT /v1/instances/{instanceId}/triggers/policies/{policyId} HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: authorization string
4
5{
6 "description": {description},
7 "eventTypes": {eventTypes},
8 "filters": {filters},
9 "name": {name},
10 "targets": {targets}
11}
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| instanceId | String | Yes | Path | CCR instance ID |
| policyId | String | Yes | Path | Trigger policy ID |
| description | String | No | Body | Trigger policy notes |
| eventTypes | List |
Yes | Body | Trigger event list, valid values are: UPLOAD_CHART (Push Helm Chart) DOWNLOAD_CHART (Pull Helm Chart) DELETE_CHART (Delete Helm Chart) PUSH_ARTIFACT (Push Artifact) PULL_ARTIFACT (Pull Artifact) DELETE_ARTIFACT (Delete Artifact) |
| filters | List<[TriggerFilter](CCR/Enterprise Edition API Reference/Appendix.md#TriggerFilter)> | No | Body | Trigger rules |
| name | String | Yes | Body | Trigger name |
| targets | List<[TriggerTarget](CCR/Enterprise Edition API Reference/Appendix.md#TriggerTarget)> | No | Body | Access configuration |
Response headers
There are no special headers required beyond the common headers.
Response parameters
If the request is successful, no response parameters are returned. In case of failure, a standard error structure is provided.
Request example
1PUT /v1/instances/ccr-test/triggers/policies/3 HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: bce-auth-v1/123456/2022-08-01T13:07:36Z/1800/host/0a859ce949951fe15a4eb6874a9765f9e8a6f7147f206cf47e270c34c862b8c6
4
5{
6 "description": "Trigger test-modify",
7 "eventTypes": [
8 "PUSH_ARTIFACT",
9 "DELETE_CHART"
10 ],
11 "filters": [
12 {
13 "type": "project_name",
14 "value": "ns-test"
15 }
16 ],
17 "name": "trigger-test",
18 "targets": [
19 {
20 "address": "http://baidu.com",
21 "headers": {
22 "Authorization": "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
23 }
24 }
25 ]
26}
Response example
1HTTP/1.1 200 OK
2Content-Type: text/plain; charset=utf-8
3Date: Mon, 08 Aug 2022 06:48:43 GMT
4X-Bce-Gateway-Region: BJ
5X-Bce-Request-Id: a89e0780-2b4c-44d2-84e8-ce55883a5cb7
Delete trigger policy in batch
API description
Delete trigger policies in bulk.
Request structure
1DELETE /v1/instances/{instanceId}/triggers/policies HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: authorization string
4
5{
6 "items": {items}
7}
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| instanceId | String | Yes | Path | CCR instance ID |
| items | List |
Yes | Body | Array of trigger policy IDs |
Response headers
There are no special headers required beyond the common headers.
Response parameters
If the request is successful, no response parameters are returned. In case of failure, a standard error structure is provided.
Request example
1DELETE /v1/instances/ccr-test/triggers/policies HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: bce-auth-v1/123456/2022-08-01T08:26:41Z/1800/host/0a859ce949951fe15a4eb6874a9765f9e8a6f7147f206cf47e270c34c862b8c6
4
5{
6 "items": [
7 1,
8 2
9 ]
10}
Response example
1HTTP/1.1 200 OK
2Content-Type: application/json; charset=utf-8
3Date: Mon, 08 Aug 2022 07:28:25 GMT
4X-Bce-Gateway-Region: BJ
5X-Bce-Request-Id: 8f21c375-ce7e-4ed7-b9a9-9499e9e1262d
Delete trigger policy
API description
Delete a single trigger policy.
Request structure
1DELETE /v1/instances/{instanceId}/triggers/policies/{policyId} HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: authorization string
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| instanceId | String | Yes | Path | CCR instance ID |
| policyId | String | Yes | Path | Trigger policy ID |
Response headers
There are no special headers required beyond the common headers.
Response parameters
If the request is successful, no response parameters are returned. In case of failure, a standard error structure is provided.
Request example
1DELETE /v1/instances/ccr-test/triggers/policies/1 HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: bce-auth-v1/123456/2022-08-01T08:26:41Z/1800/host/0a859ce949951fe15a4eb6874a9765f9e8a6f7147f206cf47e270c34c862b8c6
Response example
1HTTP/1.1 200 OK
2Content-Type: application/json; charset=utf-8
3Date: Mon, 08 Aug 2022 07:37:59 GMT
4X-Bce-Gateway-Region: BJ
5X-Bce-Request-Id: d422ac7a-298a-42c5-ab51-00d6beb78396
Test trigger policy target address
API description
Test the accessibility of the target address for a trigger policy.
Request structure
1POST /v1/instances/{instanceId}/triggers/policies/targets HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: authorization string
4
5{
6 "address": {address},
7 "headers": {headers}
8}
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| instanceId | String | Yes | Path | CCR instance ID |
| address | String | Yes | Body | Target URL |
| headers | Object | No | Body | Header key only supports "Authorization" |
Response headers
There are no special headers required beyond the common headers.
Response parameters
If the request is successful, no response parameters are returned. In case of failure, a standard error structure is provided.
Request example
1POST /v1/instances/ccr-test/triggers/policies/targets HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: bce-auth-v1/123456/2022-08-01T13:07:36Z/1800/host/0a859ce949951fe15a4eb6874a9765f9e8a6f7147f206cf47e270c34c862b8c6
4
5{
6 "address": "http://baidu.com",
7 "headers": {
8 "Authorization": "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
9 }
10}
Response example
1HTTP/1.1 200 OK
2Content-Type: text/plain; charset=utf-8
3Date: Mon, 08 Aug 2022 06:48:43 GMT
4X-Bce-Gateway-Region: BJ
5X-Bce-Request-Id: a89e0780-2b4c-44d2-84e8-ce55883a5cb7
Enable or disable trigger policy
API description
Enable or disable a specific trigger policy.
Request structure
1PUT /v1/instances/{instanceId}/triggers/policies/{policyId}/enable?enabled={enabled} HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: authorization string
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| instanceId | String | Yes | Path | CCR instance ID |
| policyId | String | Yes | Path | Trigger policy ID |
| enabled | String | Yes | Query | Enabled or not |
Response headers
There are no special headers required beyond the common headers.
Response parameters
If the request is successful, no response parameters are returned. In case of failure, a standard error structure is provided.
Request example
1PUT /v1/instances/ccr-test/triggers/policies/1/enable?enabled=false HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: bce-auth-v1/123456/2022-08-01T13:07:36Z/1800/host/0a859ce949951fe15a4eb6874a9765f9e8a6f7147f206cf47e270c34c862b8c6
Response example
1HTTP/1.1 200 OK
2Content-Type: application/json; charset=utf-8
3Date: Mon, 08 Aug 2022 08:07:21 GMT
4X-Bce-Gateway-Region: BJ
5X-Bce-Request-Id: 518d789f-013d-4bf1-ade5-4e7fd1f33dd4
Retrieve trigger task list
API description
Retrieve the list of executed trigger tasks.
Request structure
1GET /v1/instances/{instanceId}/triggers/policies/{policyId}/jobs?pageNo={pageNo}&pageSize={pageSize} HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: authorization string
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| instanceId | String | Yes | Path | CCR instance ID |
| policyId | String | Yes | Path | Trigger policy ID |
| pageNo | Integer | No | Query | Current page |
| pageSize | Integer | No | Query | Records count per page |
Response headers
There are no special headers required beyond the common headers.
Response parameters
| Parameter name | Types | Description |
|---|---|---|
| total | Integer | Total trigger tasks |
| pageNo | Integer | Current page |
| pageSize | Integer | Records count per page |
| jobs | List<[TriggerJob](CCR/Enterprise Edition API Reference/Appendix.md#TriggerJob)> | Trigger task list |
Request example
1GET /v1/instances/ccr-test/triggers/policies/1/jobs?pageNo=1&pageSize=10 HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: bce-auth-v1/123456/2022-08-01T13:07:36Z/1800/host/0a859ce949951fe15a4eb6874a9765f9e8a6f7147f206cf47e270c34c862b8c6
Response example
1HTTP/1.1 200 OK
2Content-Type: application/json; charset=utf-8
3Date: Mon, 08 Aug 2022 08:32:05 GMT
4X-Bce-Gateway-Region: BJ
5X-Bce-Request-Id: dc60c252-5bc5-4d98-96c4-14473048dc9f
6
7{
8 "total": 2,
9 "pageNo": 1,
10 "pageSize": 10,
11 "jobs": [
12 {
13 "creationTime": "2022-08-12T03:01:12.458882Z",
14 "eventType": "PUSH_ARTIFACT",
15 "id": 4,
16 "notifyType": "trigger",
17 "status": "finished",
18 "operator": "xiaoming",
19 "image": "ns1/pause:3.4",
20 "images": [
21 "ns1/pause:3.4"
22 ],
23 "updateTime": "2022-08-12T03:01:13.005546Z"
24 },
25 {
26 "creationTime": "2022-08-08T09:29:32.032588Z",
27 "eventType": "PULL_ARTIFACT",
28 "id": 1,
29 "notifyType": "trigger",
30 "status": "finished",
31 "image": "ns1/ubuntu:18.04-tools",
32 "images": [
33 "ns1/ubuntu:18.04-tools"
34 ],
35 "updateTime": "2022-08-08T09:29:32.231975Z"
36 }
37 ]
38}
Re-execute trigger task
API description
Re-execute a specific trigger task.
Request structure
1PUT /v1/instances/{instanceId}/triggers/policies/{policyId}/jobs/{jobId}/retry HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: authorization string
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| instanceId | String | Yes | Path | CCR instance ID |
| policyId | String | Yes | Path | Trigger policy ID |
| jobId | String | Yes | Path | Trigger task ID |
Response headers
There are no special headers required beyond the common headers.
Response parameters
If the request is successful, no response parameters are returned. In case of failure, a standard error structure is provided.
Request example
1PUT /v1/instances/ccr-test/triggers/policies/1/jobs/2/retry HTTP/1.1
2Host: ccr.bd.baidubce.com
3Authorization: bce-auth-v1/123456/2022-08-01T13:07:36Z/1800/host/0a859ce949951fe15a4eb6874a9765f9e8a6f7147f206cf47e270c34c862b8c6
Response example
1HTTP/1.1 200 OK
2Content-Type: application/json; charset=utf-8
3Date: Mon, 08 Aug 2022 08:32:05 GMT
4X-Bce-Gateway-Region: BJ
5X-Bce-Request-Id: dc60c252-5bc5-4d98-96c4-14473048dc9f
