This repository was archived by the owner on Apr 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
RFC: API-v2 - Standardized and Fully Documented API #224
Open
AleksandarCole
wants to merge
3
commits into
main
Choose a base branch
from
rfc/api-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
362 changes: 362 additions & 0 deletions
362
rfcs/0001-api-v2/resources/Semaphore API Design Guide.md
Large diffs are not rendered by default.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
rfcs/0001-api-v2/resources/endpoint-descriptions/dashboards.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| Dashboards | ||
|
|
||
| Standard Methods: | ||
|
|
||
| https://semaphore.semaphoreci.com/api/v2/dashboards | ||
| https://semaphore.semaphoreci.com/api/v2/dashboards/{name_or_id} | ||
|
|
||
| - list | ||
| - describe | ||
| - create | ||
| - update | ||
| - delete | ||
|
|
||
| Resource | ||
|
|
||
| ```json | ||
| { | ||
| "apiVersion": "v2", | ||
| "kind": "Dashboard", | ||
| "metadata": { | ||
| "id": "645d2d5b-603c-49b2-9022-594297b60aa1", | ||
| "organization": {"id": "02b7c528-b0f1-4266-8e5e-10b7b984e76a", "name": "Organization1"}, | ||
| "name": "my-dashboard", | ||
| "timeline": { | ||
| "created_at": "2024-07-12T11:02:50.108Z", | ||
| "created_by": { "id": "18b40eaf-ce10-49c3-93f2-e4fe72d5160b", "type": "USER" }, | ||
| "updated_at": "2024-07-12T11:02:50.108Z", | ||
| "updated_by": { "id": "18b40eaf-ce10-49c3-93f2-e4fe72d5160b", "type": "USER" }, | ||
| } | ||
| }, | ||
| "spec": { | ||
| "title": "My Dashboard", | ||
| "widgets": [ | ||
| { | ||
| "name": "My Pipelines", | ||
| "type": "PIPELINES", # PIPELINES, WORKFLOWS | ||
| "filters": { | ||
| "reference": "refs/heads/master", # suport only branches for now? | ||
| "project": {"id": "a44db728-f627-4560-a548-9f61d61e8780", "name": "Project1"}, # required for PIPELINES | ||
| "pipeline_file": ".semaphore/semaphore.yml" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` |
56 changes: 56 additions & 0 deletions
56
rfcs/0001-api-v2/resources/endpoint-descriptions/deployments.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| Deployments | ||
|
|
||
| Standard Methods | ||
|
|
||
| https://semaphore.semaphoreci.com/api/v2/projects/{name_or_id}/deployment_targets/{name_or_id}/deployments | ||
| https://semaphore.semaphoreci.com/api/v2/deployment_targets/{id}/deployments | ||
|
|
||
| https://semaphore.semaphoreci.com/api/v2/deployments | ||
|
|
||
| - list filter deployment_target_id =, reference = "refs/heads/master" "refs/heads/*", triggered_by.id = "" | ||
|
|
||
| Resource | ||
|
|
||
| ```json | ||
| { | ||
| "apiVersion": "v2", | ||
| "kind": "Deployment", | ||
| "metadata": { | ||
| "id": "a0424427-ff28-4f77-a893-0fdf5f50c380", | ||
| "organization": {"id": "02b7c528-b0f1-4266-8e5e-10b7b984e76a", "name": "organization1"}, | ||
| "project": {"id": "726dbefd-b30c-4c80-bc9a-c0613968a2ca", "name": "project1"}, | ||
| "environment": {"id": "9c777b65-213f-4fe1-bc6b-727d2cdde97d" }, | ||
| "timeline": { | ||
| "created_at": "2024-07-12T11:02:50.108Z", | ||
| "created_by": { "id": "18b40eaf-ce10-49c3-93f2-e4fe72d5160b", "type": "USER" }, | ||
| "updated_at": "2024-07-12T11:02:50.108Z", | ||
| "updated_by": { "id": "18b40eaf-ce10-49c3-93f2-e4fe72d5160b", "type": "USER" }, | ||
| } | ||
| }, | ||
|
|
||
| "spec": { | ||
| "git": { | ||
| "reference": "refs/heads/master", | ||
| } | ||
| "env_vars": [ | ||
| { | ||
| "name": "NAME", | ||
| "value": "VALUE" | ||
| } | ||
| ], | ||
|
|
||
| "origin_pipeline": {"id": "97ba55d1-90d7-40b9-a2dd-bdbd02389b58" }, | ||
| "promotion_name": "Sxmoon" | ||
| }, | ||
|
|
||
| "status": { | ||
| "state": "PENDING", | ||
| "state_message": "", | ||
| "deployment_pipeline": {"id": "adc5a26f-4077-47bc-8d4f-cb4467f2c103" }, | ||
| "timeline": { | ||
| "triggered_at": "2024-07-12T11:02:50.058Z", | ||
| "triggered_by": { "id": "18b40eaf-ce10-49c3-93f2-e4fe72d5160b", "name": "User1" } | ||
| } | ||
| } | ||
| } | ||
| ``` |
91 changes: 91 additions & 0 deletions
91
rfcs/0001-api-v2/resources/endpoint-descriptions/environments.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| Environments | ||
|
|
||
| Standard Methods: | ||
|
|
||
| https://semaphore.semaphoreci.com/api/v2/projects/{name_or_id}/environments | ||
| https://semaphore.semaphoreci.com/api/v2/projects/{name_or_id}/environments/{name_or_id} | ||
|
|
||
| https://semaphore.semaphoreci.com/api/v2/environments | ||
| https://semaphore.semaphoreci.com/api/v2/environments/{id} | ||
|
|
||
| - list | ||
| - describe | ||
| - update | ||
| - delete | ||
| - create | ||
|
|
||
| Custom Methods | ||
|
|
||
| - cordon POST on /projects/{name_or_id}/environments/{name_or_id}/cordon | ||
| - uncordon POST on /projects/{name_or_id}/environments/{name_or_id}/uncordon | ||
|
|
||
| Resource: | ||
|
|
||
| ```json | ||
| { | ||
| "apiVersion": "v2", | ||
| "kind": "Environment", | ||
| "metadata": { | ||
| "id": "9c777b65-213f-4fe1-bc6b-727d2cdde97d", | ||
| "organization": {"id": "02b7c528-b0f1-4266-8e5e-10b7b984e76a", "name": "Organization1"}, | ||
| "project": {"id": "726dbefd-b30c-4c80-bc9a-c0613968a2ca", "name": "Project1"}, | ||
| "name": "production", | ||
| "timeline": { | ||
| "created_at": "2024-07-12T11:02:50.108Z", | ||
| "created_by": { "id": "18b40eaf-ce10-49c3-93f2-e4fe72d5160b", "type": "USER" }, | ||
| "updated_at": "2024-07-12T11:02:50.108Z", | ||
| "updated_by": { "id": "18b40eaf-ce10-49c3-93f2-e4fe72d5160b", "type": "USER" }, | ||
| } | ||
| }, | ||
| "spec": { | ||
| "description": "string", | ||
| "url": "string", | ||
|
|
||
| "subject_rules": [ | ||
| { | ||
| "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", | ||
| "type": "USER", # USER, ROLE, ANY, AUTO | ||
| }, | ||
| { | ||
| "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", | ||
| "type": "ROLE", | ||
| "name": "Contributor" | ||
| } | ||
| ], | ||
| "object_rules": [ | ||
| { | ||
| "type": "BRANCH", # BRANCH, PR, TAG | ||
| "match_mode": "ALL", # REGEX | ||
| "pattern": "" | ||
| } | ||
| ], | ||
|
|
||
| "bookmark_parameters": ["string"], | ||
| "secrets": {} | ||
| "env_vars": [ | ||
| { | ||
| "name": "MY_SECRET", | ||
| "value": "secret" | ||
| } | ||
| ], | ||
| "files": [ | ||
| { | ||
| "content": "string", | ||
| "path": "/path/to/file" | ||
| } | ||
| ], | ||
| } | ||
|
|
||
| } | ||
|
|
||
| "status": { | ||
| "state": "SYNCING", | ||
|
|
||
| "last_deployment": { | ||
| "id": "a0424427-ff28-4f77-a893-0fdf5f50c380", | ||
| "deployment_pipeline": {"id": "adc5a26f-4077-47bc-8d4f-cb4467f2c103" } | ||
| }, | ||
|
|
||
| } | ||
| } | ||
| ``` |
25 changes: 25 additions & 0 deletions
25
rfcs/0001-api-v2/resources/endpoint-descriptions/init_jobs.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Init Jobs | ||
|
|
||
| Standard Methods | ||
|
|
||
| https://semaphore.semaphoreci.com/api/v2/init_job | ||
|
|
||
| - describe | ||
| - update | ||
|
|
||
| Resource | ||
|
|
||
| ```json | ||
| { | ||
| "apiVersion": "v2", | ||
| "kind": "InitJob", | ||
| "metadata": { | ||
| "organization": {"id": "02b7c528-b0f1-4266-8e5e-10b7b984e76a", "name": "Organization1"}, | ||
| }, | ||
| "spec": { | ||
| "agent": { | ||
| "os_image": "ubuntu2004", | ||
| "machine_type": "e1-standard-2" | ||
| } | ||
| } | ||
| ``` |
37 changes: 37 additions & 0 deletions
37
rfcs/0001-api-v2/resources/endpoint-descriptions/job_access.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| Job Access | ||
|
|
||
| Standard Methods | ||
|
|
||
| https://semaphore.semaphoreci.com/api/v2/job_access | ||
|
|
||
| - describe | ||
| - update | ||
|
|
||
| Resource | ||
|
|
||
| ```json | ||
| { | ||
| "apiVersion": "v2", | ||
| "kind": "JobAccess", | ||
| "metadata": { | ||
| "organization": {"id": "02b7c528-b0f1-4266-8e5e-10b7b984e76a", "name": "Organization1"} | ||
| }, | ||
| "spec": { | ||
| "debug": { | ||
| "project": false, | ||
| "default_branch": false, | ||
| "non_default_branch": false, | ||
| "pull_requests": false, | ||
| "forked_pull_requests": false, | ||
| "tags": false | ||
| }, | ||
| "attach": { | ||
| "default_branch": false, | ||
| "non_default_branch": false, | ||
| "pull_requests": false, | ||
| "forked_pull_requests": false, | ||
| "tags": false | ||
| } | ||
| } | ||
| } | ||
| ``` |
114 changes: 114 additions & 0 deletions
114
rfcs/0001-api-v2/resources/endpoint-descriptions/jobs.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| Jobs | ||
|
|
||
| Standard Methods | ||
|
|
||
| https://semaphore.semaphoreci.com/api/v2/jobs | ||
|
|
||
| - list filter state = , project_id = | ||
| - describe | ||
| - create | ||
|
|
||
| Custom Methods | ||
|
|
||
| - terminate POST on /jobs/{id}/terminate | ||
| - log_events GET on /jobs/{id}/log_events | ||
| - ssh_key GET on /jobs/{id}/ssh_key | ||
|
|
||
| - debug_job POST on /jobs/debug_job + job_id agent and execution_time_limit | ||
| - debug_project POST on /jobs/debug_project + project_id agent and execution_time_limit | ||
|
|
||
| Resource | ||
|
|
||
| ```json | ||
| HTTP status: 200 | ||
|
|
||
| { | ||
| "metadata": { | ||
| "id": "bc8826bd-dbb2-4d28-8c90-7f370ce478fe", | ||
| "organization": {"id": "02b7c528-b0f1-4266-8e5e-10b7b984e76a", "name": "Organization1"}, | ||
| "project": {"id": "726dbefd-b30c-4c80-bc9a-c0613968a2ca", "name": "Project1"}, | ||
| "workflow": {"id": "52f2847c-1817-48f2-95a8-b7e6b98c65e0" }, | ||
| "pipeline": {"id": "f850cdcf-d3de-4d50-91bf-b6190fa5f9c0" }, | ||
| "name": "Job #1", | ||
| "timeline": { | ||
| "created_at": "2024-07-12T11:02:50.108Z", | ||
| "created_by": { "id": "18b40eaf-ce10-49c3-93f2-e4fe72d5160b", "type": "USER" }, | ||
| "updated_at": "2024-07-12T11:02:50.108Z", | ||
| "updated_by": { "id": "18b40eaf-ce10-49c3-93f2-e4fe72d5160b", "type": "USER" }, | ||
| } | ||
| }, | ||
| "spec": { | ||
| "agent": { | ||
| "ports": [{ | ||
| "name": "ssh", | ||
| "number": 30000 | ||
| }], | ||
| "containers": [], | ||
| "machine": { | ||
| "type": "e1-standard-2", | ||
| "os_image": "ubuntu2004" | ||
| } | ||
| }, | ||
| "env_vars": [ | ||
| { | ||
| "name": "SEMAPHORE_WORKFLOW_ID", | ||
| "value": "59b32e16-3c4a-4940-899e-348c28396884" | ||
| }, | ||
| { | ||
| "name": "SEMAPHORE_WORKFLOW_NUMBER", | ||
| "value": "2" | ||
| }, | ||
| { | ||
| "name": "SEMAPHORE_PIPELINE_ARTEFACT_ID", | ||
| "value": "abb4fb87-309d-490a-bf0d-84972641b130" | ||
| }, | ||
| { | ||
| "name": "SEMAPHORE_PIPELINE_ID", | ||
| "value": "abb4fb87-309d-490a-bf0d-84972641b130" | ||
| }, | ||
| { | ||
| "name": "SEMAPHORE_PIPELINE_0_ARTEFACT_ID", | ||
| "value": "abb4fb87-309d-490a-bf0d-84972641b130" | ||
| } | ||
| ], | ||
| "secrets": [ | ||
| {"name": "DOCKERHUB_USERNAME"}, | ||
| {"name": "DOCKERHUB_PASSWORD"} | ||
| ], | ||
| "commands": [ | ||
| "sleep 3600" | ||
| ], | ||
| "epilogue_always_commands": [ | ||
| "echo 'Job finished'" | ||
| ], | ||
| "epilogue_on_fail_commands": [ | ||
| "echo 'Job failed'" | ||
| ], | ||
| "epilogue_on_pass_commands": [ | ||
| "echo 'Job passed'" | ||
| ], | ||
| "execution_time_limit": 3600, | ||
|
|
||
| }, | ||
|
|
||
| "status": { | ||
|
|
||
| "agent": { | ||
| "name": "", | ||
| "ip": "88.212.212.212" | ||
| } | ||
|
|
||
| "result": "STOPPED", | ||
| "state": "FINISHED" | ||
|
|
||
| "timeline": { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so we do not have the final decision here wether to put timeline in status or metadata?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for "live" resources timeline will be in status, and we will keep base timestamps in metadata |
||
| "created_at": "2024-07-12T11:02:50.116Z", | ||
| "enqueued_at": "2024-07-12T11:02:50.045Z", | ||
| "scheduled_at": "2024-07-12T11:02:50.045Z", | ||
| "started_at": "2024-07-12T11:02:50.045Z", | ||
| "finished_at": "2024-07-12T11:02:50.045Z" | ||
| } | ||
|
|
||
| } | ||
| } | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agent ports should be in status -> agent as is the ip address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to move it