差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

下次修改
前次修改
tech:alpine_semaphore:api [2024/01/02 17:35] – 建立 jonathantech:alpine_semaphore:api [2024/01/02 19:45] (目前版本) – [5. Get template] jonathan
行 1: 行 1:
-====== Ansible Semaphore API 整理 ======+====== Ansible Semaphore API 手動執行整理 ======
   * API Swagger - https://www.semui.co/api-docs/   * API Swagger - https://www.semui.co/api-docs/
  
行 46: 行 46:
 -rw-r--r--    1 root     root           344 Jan  2 17:31 semaphore-cookie -rw-r--r--    1 root     root           344 Jan  2 17:31 semaphore-cookie
 </cli>++ </cli>++
 +
 +==== 2. Generate an API token ====
 +  * 需要使用到 cookie 檔 ./semaphore-cookie
 +  * <cli>
 +curl -v -b ./semaphore-cookie -XPOST \
 +-H 'Content-Type: application/json' \
 +-H 'Accept: application/json' \
 +http://localhost:3000/api/user/tokens
 +</cli>
 +    * ++實際操作畫面|<cli>
 +semaphore-44:~/cli-work# curl -v -b ./semaphore-cookie -XPOST \
 +> -H 'Content-Type: application/json' \
 +> -H 'Accept: application/json' \
 +> http://localhost:3000/api/user/tokens
 +* Host localhost:3000 was resolved.
 +* IPv6: ::1
 +* IPv4: 127.0.0.1
 +*   Trying [::1]:3000...
 +* Connected to localhost (::1) port 3000
 +> POST /api/user/tokens HTTP/1.1
 +> Host: localhost:3000
 +> User-Agent: curl/8.5.0
 +> Cookie: semaphore=MTcwNDE4NzkwOXw2UlByZHVXdkhIMU5wN2ROZTg1VGdvOEp5SGpXTGpqZEMzM3pIcjNUVmVpQ0ZOb0JwdjBHYmlwLWlsRnpDNDF5MlVSd1ZXdlB4N3k5Y3RFbzhhSlVGUWs9fIEdaH9kKEep32Acl8S5j3WF_LHbfojgVQPs_oJMu9Cw
 +> Content-Type: application/json
 +> Accept: application/json
 +>
 +< HTTP/1.1 201 Created
 +< Content-Type: application/json
 +< Date: Tue, 02 Jan 2024 11:31:12 GMT
 +< Content-Length: 115
 +<
 +{"id":"p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg=","created":"2024-01-02T11:31:12Z","expired":false,"user_id":1}
 +* Connection #0 to host localhost left intact
 +
 +API token 就是所回傳的 id 值 : p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg=
 +</cli>++
 +
 +==== 3. Remove task ====
 +  * 需要使用到 API token : p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg=
 +  * 預計刪除 task : 18
 +  * <cli>
 +curl -v -X 'DELETE' 'http://localhost:3000/api/project/1/tasks/18' -H 'accept: application/json' -H 'Authorization: Bearer p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg='
 +</cli>
 +    * ++實際操作畫面|<cli>
 +semaphore-44:~/cli-work# curl -v -X 'DELETE' 'http://localhost:3000/api/project/1/tasks/18' -H 'accept: application/json' -H 'Authorization: Bearer p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg='
 +* Host localhost:3000 was resolved.
 +* IPv6: ::1
 +* IPv4: 127.0.0.1
 +*   Trying [::1]:3000...
 +* Connected to localhost (::1) port 3000
 +> DELETE /api/project/1/tasks/18 HTTP/1.1
 +> Host: localhost:3000
 +> User-Agent: curl/8.5.0
 +> accept: application/json
 +> Authorization: Bearer p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg=
 +>
 +< HTTP/1.1 204 No Content
 +< Content-Type: application/json
 +< Date: Tue, 02 Jan 2024 11:36:34 GMT
 +<
 +* Connection #0 to host localhost left intact
 +</cli>++
 +
 +==== 4. Remove template ====
 +  * 需要使用到 API token : p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg=
 +  * 預計刪除 template : 1
 +  * 屬於這 template 的所有 task 都會一併刪除
 +  * <cli>
 +curl -X 'DELETE' 'http://localhost:3000/api/project/1/templates/1' -H 'accept: application/json' -H 'Authorization: Bearer p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg='
 +</cli>
 +    * ++實際操作畫面|<cli>
 +semaphore-44:~/cli-work# curl -X 'DELETE' 'http://localhost:3000/api/project/1/templates/1' -H 'accept: application/json' -H 'Authorization: Bearer p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg='
 +</cli>++
 +
 +==== 5. Get template ====
 +  * 需要使用到 API token : p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg=
 +  * 預計取得 template : 2
 +  * <cli>
 +curl -X 'GET' 'http://localhost:3000/api/project/1/templates/2' -H 'accept: application/json' -H 'Authorization: Bearer p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg='
 +</cli>
 +    * ++實際操作畫面|<cli>
 +semaphore-44:~/cli-work# curl -X 'GET' 'http://localhost:3000/api/project/1/templates/2' -H 'accept: application/json' -H 'Authorization: Bearer p5wyfpx9wge4wu57ytfkx9msmu0efke6yqvzapfd3hg='
 +{
 +  "id": 2,
 +  "project_id": 1,
 +  "inventory_id": 2,
 +  "repository_id": 1,
 +  "environment_id": 1,
 +  "name": "daliy-update-ubuntu",
 +  "playbook": "upgrade.yml",
 +  "arguments": null,
 +  "allow_override_args_in_task": false,
 +  "description": null,
 +  "vault_key_id": null,
 +  "type": "",
 +  "start_version": null,
 +  "build_template_id": null,
 +  "view_id": 1,
 +  "last_task": {
 +    "id": 28,
 +    "template_id": 2,
 +    "project_id": 1,
 +    "status": "success",
 +    "debug": false,
 +    "dry_run": false,
 +    "diff": false,
 +    "playbook": "",
 +    "environment": "",
 +    "limit": "",
 +    "user_id": null,
 +    "created": "2024-01-02T10:35:00.001752Z",
 +    "start": "2024-01-02T10:35:03.218576Z",
 +    "end": "2024-01-02T10:35:32.726596Z",
 +    "message": "",
 +    "commit_hash": null,
 +    "commit_message": "",
 +    "build_task_id": null,
 +    "version": null,
 +    "arguments": null,
 +    "tpl_playbook": "upgrade.yml",
 +    "tpl_alias": "daliy-update-ubuntu",
 +    "tpl_type": "",
 +    "user_name": null,
 +    "build_task": null
 +  },
 +  "autorun": false,
 +  "survey_vars": null,
 +  "suppress_success_alerts": false
 +}
 +</cli>++
 +
  
  
 {{tag>ansible semaphore}} {{tag>ansible semaphore}}
  
  • tech/alpine_semaphore/api.1704188156.txt.gz
  • 上一次變更: 2024/01/02 17:35
  • jonathan