From dbd91d38843f3325047d5fdd56a2c02d9642797d Mon Sep 17 00:00:00 2001 From: Anbraten <6918444+anbraten@users.noreply.github.com> Date: Wed, 1 May 2024 11:50:41 +0200 Subject: [PATCH] Cleanup api docs and ts api-client options (#3663) --- cli/common/flags.go | 4 +- cmd/server/docs/docs.go | 141 +++++++++--------- go.sum | 8 - server/api/agent.go | 11 +- server/api/badge.go | 2 +- server/api/cron.go | 8 +- server/api/global_secret.go | 4 +- server/api/hook.go | 4 +- server/api/org.go | 8 +- server/api/org_secret.go | 10 +- server/api/orgs.go | 4 +- server/api/pipeline.go | 25 ++-- server/api/registry.go | 10 +- server/api/repo.go | 22 +-- server/api/repo_secret.go | 10 +- server/api/stream.go | 6 +- server/api/user.go | 10 +- server/api/users.go | 4 +- .../admin/settings/AdminAgentsTab.vue | 2 +- .../admin/settings/AdminOrgsTab.vue | 2 +- .../admin/settings/AdminReposTab.vue | 2 +- .../admin/settings/AdminSecretsTab.vue | 2 +- .../admin/settings/AdminUsersTab.vue | 2 +- .../layout/popups/ManualPipelinePopup.vue | 2 +- .../components/org/settings/OrgSecretsTab.vue | 2 +- web/src/components/repo/settings/BadgeTab.vue | 2 +- web/src/components/repo/settings/CronTab.vue | 2 +- .../repo/settings/RegistriesTab.vue | 2 +- .../components/repo/settings/SecretsTab.vue | 6 +- web/src/components/user/UserSecretsTab.vue | 2 +- web/src/lib/api/index.ts | 69 +++++---- web/src/store/pipelines.ts | 4 +- web/src/views/repo/RepoBranches.vue | 2 +- web/src/views/repo/RepoPullRequests.vue | 2 +- 34 files changed, 207 insertions(+), 189 deletions(-) diff --git a/cli/common/flags.go b/cli/common/flags.go index 665b64578..14674c682 100644 --- a/cli/common/flags.go +++ b/cli/common/flags.go @@ -78,11 +78,11 @@ func FormatFlag(tmpl string, hidden ...bool) *cli.StringFlag { var RepoFlag = &cli.StringFlag{ Name: "repository", Aliases: []string{"repo"}, - Usage: "repository id or full-name (e.g. 134 or octocat/hello-world)", + Usage: "repository id or full name (e.g. 134 or octocat/hello-world)", } var OrgFlag = &cli.StringFlag{ Name: "organization", Aliases: []string{"org"}, - Usage: "organization id or full-name (e.g. 123 or octocat)", + Usage: "organization id or full name (e.g. 123 or octocat)", } diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index ffd410851..13ee5951a 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -26,7 +26,7 @@ const docTemplate = `{ "tags": [ "Agents" ], - "summary": "Get agent list", + "summary": "List agents", "parameters": [ { "type": "string", @@ -64,13 +64,14 @@ const docTemplate = `{ } }, "post": { + "description": "Creates a new agent with a random token", "produces": [ "application/json" ], "tags": [ "Agents" ], - "summary": "Create a new agent with a random token so a new agent can connect to the server", + "summary": "Create a new agent", "parameters": [ { "type": "string", @@ -108,7 +109,7 @@ const docTemplate = `{ "tags": [ "Agents" ], - "summary": "Get agent information", + "summary": "Get an agent", "parameters": [ { "type": "string", @@ -173,7 +174,7 @@ const docTemplate = `{ "tags": [ "Agents" ], - "summary": "Update agent information", + "summary": "Update an agent", "parameters": [ { "type": "string", @@ -218,7 +219,7 @@ const docTemplate = `{ "tags": [ "Agents" ], - "summary": "Get agent tasks", + "summary": "List agent tasks", "parameters": [ { "type": "string", @@ -283,7 +284,7 @@ const docTemplate = `{ "tags": [ "Badges" ], - "summary": "Get status badge, SVG format", + "summary": "Get status of pipeline as SVG badge", "parameters": [ { "type": "integer", @@ -744,7 +745,7 @@ const docTemplate = `{ "tags": [ "Organizations" ], - "summary": "Lookup organization by full-name", + "summary": "Lookup an organization by full name", "parameters": [ { "type": "string", @@ -756,7 +757,7 @@ const docTemplate = `{ }, { "type": "string", - "description": "the organizations full-name / slug", + "description": "the organizations full name / slug", "name": "org_full_name", "in": "path", "required": true @@ -781,7 +782,7 @@ const docTemplate = `{ "tags": [ "Orgs" ], - "summary": "Get all orgs", + "summary": "List organizations", "parameters": [ { "type": "string", @@ -828,7 +829,7 @@ const docTemplate = `{ "tags": [ "Orgs" ], - "summary": "Delete an org", + "summary": "Delete an organization", "parameters": [ { "type": "string", @@ -861,7 +862,7 @@ const docTemplate = `{ "tags": [ "Organization" ], - "summary": "Get organization by id", + "summary": "Get an organization", "parameters": [ { "type": "string", @@ -900,7 +901,7 @@ const docTemplate = `{ "tags": [ "Organization permissions" ], - "summary": "Get the permissions of the current user in the given organization", + "summary": "Get the permissions of the currently authenticated user for the given organization", "parameters": [ { "type": "string", @@ -939,7 +940,7 @@ const docTemplate = `{ "tags": [ "Organization secrets" ], - "summary": "Get the organization secret list", + "summary": "List organization secrets", "parameters": [ { "type": "string", @@ -990,7 +991,7 @@ const docTemplate = `{ "tags": [ "Organization secrets" ], - "summary": "Persist/create an organization secret", + "summary": "Create an organization secret", "parameters": [ { "type": "string", @@ -1035,7 +1036,7 @@ const docTemplate = `{ "tags": [ "Organization secrets" ], - "summary": "Get the named organization secret", + "summary": "Get a organization secret by name", "parameters": [ { "type": "string", @@ -1076,7 +1077,7 @@ const docTemplate = `{ "tags": [ "Organization secrets" ], - "summary": "Delete the named secret from an organization", + "summary": "Delete an organization secret by name", "parameters": [ { "type": "string", @@ -1114,7 +1115,7 @@ const docTemplate = `{ "tags": [ "Organization secrets" ], - "summary": "Update an organization secret", + "summary": "Update an organization secret by name", "parameters": [ { "type": "string", @@ -1166,7 +1167,7 @@ const docTemplate = `{ "tags": [ "Pipeline queues" ], - "summary": "List pipeline queues", + "summary": "List pipelines in queue", "parameters": [ { "type": "string", @@ -1257,7 +1258,7 @@ const docTemplate = `{ "tags": [ "Pipeline queues" ], - "summary": "Pause a pipeline queue", + "summary": "Pause the pipeline queue", "parameters": [ { "type": "string", @@ -1283,7 +1284,7 @@ const docTemplate = `{ "tags": [ "Pipeline queues" ], - "summary": "Resume a pipeline queue", + "summary": "Resume the pipeline queue", "parameters": [ { "type": "string", @@ -1303,13 +1304,14 @@ const docTemplate = `{ }, "/repos": { "get": { + "description": "Returns a list of all repositories. Requires admin rights.", "produces": [ "application/json" ], "tags": [ "Repositories" ], - "summary": "List all repositories on the server. Requires admin rights.", + "summary": "List all repositories on the server", "parameters": [ { "type": "string", @@ -1395,7 +1397,7 @@ const docTemplate = `{ "tags": [ "Repositories" ], - "summary": "Get repository by full-name", + "summary": "Lookup a repository by full name", "parameters": [ { "type": "string", @@ -1407,7 +1409,7 @@ const docTemplate = `{ }, { "type": "string", - "description": "the repository full-name / slug", + "description": "the repository full name / slug", "name": "repo_full_name", "in": "path", "required": true @@ -1425,13 +1427,14 @@ const docTemplate = `{ }, "/repos/repair": { "post": { + "description": "Executes a repair process on all repositories. Requires admin rights.", "produces": [ "text/plain" ], "tags": [ "Repositories" ], - "summary": "Repair all repositories on the server. Requires admin rights.", + "summary": "Repair all repositories on the server", "parameters": [ { "type": "string", @@ -1457,7 +1460,7 @@ const docTemplate = `{ "tags": [ "Repositories" ], - "summary": "Get repository information", + "summary": "Get a repository", "parameters": [ { "type": "string", @@ -1525,7 +1528,7 @@ const docTemplate = `{ "tags": [ "Repositories" ], - "summary": "Change a repository", + "summary": "Update a repository", "parameters": [ { "type": "string", @@ -1570,7 +1573,7 @@ const docTemplate = `{ "tags": [ "Repositories" ], - "summary": "Get repository branches", + "summary": "Get branches of a repository", "parameters": [ { "type": "string", @@ -1623,7 +1626,7 @@ const docTemplate = `{ "tags": [ "Repositories" ], - "summary": "Change a repository's owner, to the one holding the access token", + "summary": "Change a repository's owner to the currently authenticated user", "parameters": [ { "type": "string", @@ -1659,7 +1662,7 @@ const docTemplate = `{ "tags": [ "Repository cron jobs" ], - "summary": "Get the cron job list", + "summary": "List cron jobs", "parameters": [ { "type": "string", @@ -1710,7 +1713,7 @@ const docTemplate = `{ "tags": [ "Repository cron jobs" ], - "summary": "Persist/creat a cron job", + "summary": "Create a cron job", "parameters": [ { "type": "string", @@ -1755,7 +1758,7 @@ const docTemplate = `{ "tags": [ "Repository cron jobs" ], - "summary": "Get a cron job by id", + "summary": "Get a cron job", "parameters": [ { "type": "string", @@ -1837,7 +1840,7 @@ const docTemplate = `{ "tags": [ "Repository cron jobs" ], - "summary": "Delete a cron job by id", + "summary": "Delete a cron job", "parameters": [ { "type": "string", @@ -1927,7 +1930,7 @@ const docTemplate = `{ "tags": [ "Pipeline logs" ], - "summary": "Deletes log", + "summary": "Deletes all logs of a pipeline", "parameters": [ { "type": "string", @@ -1967,7 +1970,7 @@ const docTemplate = `{ "tags": [ "Pipeline logs" ], - "summary": "Log information", + "summary": "Get logs for a pipeline step", "parameters": [ { "type": "string", @@ -2020,7 +2023,7 @@ const docTemplate = `{ "tags": [ "Pipeline logs" ], - "summary": "Deletes step log", + "summary": "Delete step logs of a pipeline", "parameters": [ { "type": "string", @@ -2108,7 +2111,7 @@ const docTemplate = `{ "tags": [ "Repositories" ], - "summary": "Repository permission information", + "summary": "Check current authenticated users access to the repository", "parameters": [ { "type": "string", @@ -2138,13 +2141,14 @@ const docTemplate = `{ }, "/repos/{repo_id}/pipelines": { "get": { + "description": "Get a list of pipelines for a repository.", "produces": [ "application/json" ], "tags": [ "Pipelines" ], - "summary": "Get pipelines, current running and past ones", + "summary": "List repository pipelines", "parameters": [ { "type": "string", @@ -2207,7 +2211,7 @@ const docTemplate = `{ "tags": [ "Pipelines" ], - "summary": "Run/trigger a pipelines", + "summary": "Trigger a manual pipeline", "parameters": [ { "type": "string", @@ -2252,7 +2256,7 @@ const docTemplate = `{ "tags": [ "Pipelines" ], - "summary": "Pipeline information by number", + "summary": "Get a repositories pipeline", "parameters": [ { "type": "string", @@ -2347,7 +2351,7 @@ const docTemplate = `{ "tags": [ "Pipelines" ], - "summary": "Delete pipeline", + "summary": "Delete a pipeline", "parameters": [ { "type": "string", @@ -2387,7 +2391,7 @@ const docTemplate = `{ "tags": [ "Pipelines" ], - "summary": "Start pipelines in gated repos", + "summary": "Approve and start a pipeline", "parameters": [ { "type": "string", @@ -2430,7 +2434,7 @@ const docTemplate = `{ "tags": [ "Pipelines" ], - "summary": "Cancels a pipeline", + "summary": "Cancel a pipeline", "parameters": [ { "type": "string", @@ -2470,7 +2474,7 @@ const docTemplate = `{ "tags": [ "Pipelines" ], - "summary": "Pipeline configuration", + "summary": "Get configuration files for a pipeline", "parameters": [ { "type": "string", @@ -2516,7 +2520,7 @@ const docTemplate = `{ "tags": [ "Pipelines" ], - "summary": "Decline pipelines in gated repos", + "summary": "Decline a pipeline", "parameters": [ { "type": "string", @@ -2559,7 +2563,7 @@ const docTemplate = `{ "tags": [ "Repositories" ], - "summary": "List active pull requests", + "summary": "List active pull requests of a repository", "parameters": [ { "type": "string", @@ -2612,7 +2616,7 @@ const docTemplate = `{ "tags": [ "Repository registries" ], - "summary": "Get the registry list", + "summary": "List registries", "parameters": [ { "type": "string", @@ -2663,7 +2667,7 @@ const docTemplate = `{ "tags": [ "Repository registries" ], - "summary": "Persist/create a registry", + "summary": "Create a registry", "parameters": [ { "type": "string", @@ -2708,7 +2712,7 @@ const docTemplate = `{ "tags": [ "Repository registries" ], - "summary": "Get a named registry", + "summary": "Get a registry by name", "parameters": [ { "type": "string", @@ -2749,7 +2753,7 @@ const docTemplate = `{ "tags": [ "Repository registries" ], - "summary": "Delete a named registry", + "summary": "Delete a registry by name", "parameters": [ { "type": "string", @@ -2787,7 +2791,7 @@ const docTemplate = `{ "tags": [ "Repository registries" ], - "summary": "Update a named registry", + "summary": "Update a registry by name", "parameters": [ { "type": "string", @@ -2872,7 +2876,7 @@ const docTemplate = `{ "tags": [ "Repository secrets" ], - "summary": "Get the secret list", + "summary": "List repository secrets", "parameters": [ { "type": "string", @@ -2923,7 +2927,7 @@ const docTemplate = `{ "tags": [ "Repository secrets" ], - "summary": "Persist/create a secret", + "summary": "Create a repository secret", "parameters": [ { "type": "string", @@ -2968,7 +2972,7 @@ const docTemplate = `{ "tags": [ "Repository secrets" ], - "summary": "Get a named secret", + "summary": "Get a repository secret by name", "parameters": [ { "type": "string", @@ -3009,7 +3013,7 @@ const docTemplate = `{ "tags": [ "Repository secrets" ], - "summary": "Delete a named secret", + "summary": "Delete a repository secret by name", "parameters": [ { "type": "string", @@ -3047,7 +3051,7 @@ const docTemplate = `{ "tags": [ "Repository secrets" ], - "summary": "Update a named secret", + "summary": "Update a repository secret by name", "parameters": [ { "type": "string", @@ -3099,7 +3103,7 @@ const docTemplate = `{ "tags": [ "Secrets" ], - "summary": "Get the global secret list", + "summary": "List global secrets", "parameters": [ { "type": "string", @@ -3143,7 +3147,7 @@ const docTemplate = `{ "tags": [ "Secrets" ], - "summary": "Persist/create a global secret", + "summary": "Create a global secret", "parameters": [ { "type": "string", @@ -3311,14 +3315,14 @@ const docTemplate = `{ }, "/stream/events": { "get": { - "description": "event source streaming for compatibility with quic and http2", + "description": "With quic and http2 support", "produces": [ "text/plain" ], "tags": [ "Events" ], - "summary": "Event stream", + "summary": "Stream events like pipeline updates", "responses": { "200": { "description": "OK" @@ -3334,7 +3338,7 @@ const docTemplate = `{ "tags": [ "Pipeline logs" ], - "summary": "Log stream", + "summary": "Stream logs of a pipeline step", "parameters": [ { "type": "integer", @@ -3373,7 +3377,7 @@ const docTemplate = `{ "tags": [ "User" ], - "summary": "Returns the currently authenticated user.", + "summary": "Get the currently authenticated user", "parameters": [ { "type": "string", @@ -3396,14 +3400,14 @@ const docTemplate = `{ }, "/user/feed": { "get": { - "description": "Feed entries can be used to display information on the latest builds.", + "description": "The feed lists the most recent pipeline for the currently authenticated user.", "produces": [ "application/json" ], "tags": [ "User" ], - "summary": "A feed entry for a build.", + "summary": "Get the currently authenticaed users pipeline feed", "parameters": [ { "type": "string", @@ -3418,7 +3422,10 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/Feed" + "type": "array", + "items": { + "$ref": "#/definitions/Feed" + } } } } @@ -3433,7 +3440,7 @@ const docTemplate = `{ "tags": [ "User" ], - "summary": "Get user's repos", + "summary": "Get user's repositories", "parameters": [ { "type": "string", @@ -3523,7 +3530,7 @@ const docTemplate = `{ "tags": [ "Users" ], - "summary": "Get all users", + "summary": "List users", "parameters": [ { "type": "string", @@ -3677,7 +3684,7 @@ const docTemplate = `{ "tags": [ "Users" ], - "summary": "Change a user", + "summary": "Update a user", "parameters": [ { "type": "string", diff --git a/go.sum b/go.sum index 6a6fe5978..e7d3f62f6 100644 --- a/go.sum +++ b/go.sum @@ -540,8 +540,6 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -575,8 +573,6 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -623,8 +619,6 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= @@ -633,8 +627,6 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/server/api/agent.go b/server/api/agent.go index 7ce9a760d..7b2d5f8d6 100644 --- a/server/api/agent.go +++ b/server/api/agent.go @@ -30,7 +30,7 @@ import ( // GetAgents // -// @Summary Get agent list +// @Summary List agents // @Router /agents [get] // @Produce json // @Success 200 {array} Agent @@ -49,7 +49,7 @@ func GetAgents(c *gin.Context) { // GetAgent // -// @Summary Get agent information +// @Summary Get an agent // @Router /agents/{agent} [get] // @Produce json // @Success 200 {object} Agent @@ -73,7 +73,7 @@ func GetAgent(c *gin.Context) { // GetAgentTasks // -// @Summary Get agent tasks +// @Summary List agent tasks // @Router /agents/{agent}/tasks [get] // @Produce json // @Success 200 {array} Task @@ -106,7 +106,7 @@ func GetAgentTasks(c *gin.Context) { // PatchAgent // -// @Summary Update agent information +// @Summary Update an agent // @Router /agents/{agent} [patch] // @Produce json // @Success 200 {object} Agent @@ -152,7 +152,8 @@ func PatchAgent(c *gin.Context) { // PostAgent // -// @Summary Create a new agent with a random token so a new agent can connect to the server +// @Summary Create a new agent +// @Description Creates a new agent with a random token // @Router /agents [post] // @Produce json // @Success 200 {object} Agent diff --git a/server/api/badge.go b/server/api/badge.go index 898dd2126..f3e8d2a03 100644 --- a/server/api/badge.go +++ b/server/api/badge.go @@ -37,7 +37,7 @@ import ( // GetBadge // -// @Summary Get status badge, SVG format +// @Summary Get status of pipeline as SVG badge // @Router /badges/{repo_id}/status.svg [get] // @Produce image/svg+xml // @Success 200 diff --git a/server/api/cron.go b/server/api/cron.go index 7a9f797fc..7a3909ec9 100644 --- a/server/api/cron.go +++ b/server/api/cron.go @@ -32,7 +32,7 @@ import ( // GetCron // -// @Summary Get a cron job by id +// @Summary Get a cron job // @Router /repos/{repo_id}/cron/{cron} [get] // @Produce json // @Success 200 {object} Cron @@ -98,7 +98,7 @@ func RunCron(c *gin.Context) { // PostCron // -// @Summary Persist/creat a cron job +// @Summary Create a cron job // @Router /repos/{repo_id}/cron [post] // @Produce json // @Success 200 {object} Cron @@ -233,7 +233,7 @@ func PatchCron(c *gin.Context) { // GetCronList // -// @Summary Get the cron job list +// @Summary List cron jobs // @Router /repos/{repo_id}/cron [get] // @Produce json // @Success 200 {array} Cron @@ -254,7 +254,7 @@ func GetCronList(c *gin.Context) { // DeleteCron // -// @Summary Delete a cron job by id +// @Summary Delete a cron job // @Router /repos/{repo_id}/cron/{cron} [delete] // @Produce plain // @Success 204 diff --git a/server/api/global_secret.go b/server/api/global_secret.go index b01de72e5..3ede60d7f 100644 --- a/server/api/global_secret.go +++ b/server/api/global_secret.go @@ -26,7 +26,7 @@ import ( // GetGlobalSecretList // -// @Summary Get the global secret list +// @Summary List global secrets // @Router /secrets [get] // @Produce json // @Success 200 {array} Secret @@ -71,7 +71,7 @@ func GetGlobalSecret(c *gin.Context) { // PostGlobalSecret // -// @Summary Persist/create a global secret +// @Summary Create a global secret // @Router /secrets [post] // @Produce json // @Success 200 {object} Secret diff --git a/server/api/hook.go b/server/api/hook.go index b2e7251ba..8046d289f 100644 --- a/server/api/hook.go +++ b/server/api/hook.go @@ -52,7 +52,7 @@ func GetQueueInfo(c *gin.Context) { // PauseQueue // -// @Summary Pause a pipeline queue +// @Summary Pause the pipeline queue // @Router /queue/pause [post] // @Produce plain // @Success 204 @@ -65,7 +65,7 @@ func PauseQueue(c *gin.Context) { // ResumeQueue // -// @Summary Resume a pipeline queue +// @Summary Resume the pipeline queue // @Router /queue/resume [post] // @Produce plain // @Success 204 diff --git a/server/api/org.go b/server/api/org.go index c30d55ebe..828728c90 100644 --- a/server/api/org.go +++ b/server/api/org.go @@ -30,7 +30,7 @@ import ( // GetOrg // -// @Summary Get organization by id +// @Summary Get an organization // @Router /orgs/{org_id} [get] // @Produce json // @Success 200 {array} Org @@ -57,7 +57,7 @@ func GetOrg(c *gin.Context) { // GetOrgPermissions // -// @Summary Get the permissions of the current user in the given organization +// @Summary Get the permissions of the currently authenticated user for the given organization // @Router /orgs/{org_id}/permissions [get] // @Produce json // @Success 200 {array} OrgPerm @@ -114,13 +114,13 @@ func GetOrgPermissions(c *gin.Context) { // LookupOrg // -// @Summary Lookup organization by full-name +// @Summary Lookup an organization by full name // @Router /org/lookup/{org_full_name} [get] // @Produce json // @Success 200 {object} Org // @Tags Organizations // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param org_full_name path string true "the organizations full-name / slug" +// @Param org_full_name path string true "the organizations full name / slug" func LookupOrg(c *gin.Context) { _store := store.FromContext(c) user := session.User(c) diff --git a/server/api/org_secret.go b/server/api/org_secret.go index 579820bc9..98f67e089 100644 --- a/server/api/org_secret.go +++ b/server/api/org_secret.go @@ -27,7 +27,7 @@ import ( // GetOrgSecret // -// @Summary Get the named organization secret +// @Summary Get a organization secret by name // @Router /orgs/{org_id}/secrets/{secret} [get] // @Produce json // @Success 200 {object} Secret @@ -55,7 +55,7 @@ func GetOrgSecret(c *gin.Context) { // GetOrgSecretList // -// @Summary Get the organization secret list +// @Summary List organization secrets // @Router /orgs/{org_id}/secrets [get] // @Produce json // @Success 200 {array} Secret @@ -87,7 +87,7 @@ func GetOrgSecretList(c *gin.Context) { // PostOrgSecret // -// @Summary Persist/create an organization secret +// @Summary Create an organization secret // @Router /orgs/{org_id}/secrets [post] // @Produce json // @Success 200 {object} Secret @@ -129,7 +129,7 @@ func PostOrgSecret(c *gin.Context) { // PatchOrgSecret // -// @Summary Update an organization secret +// @Summary Update an organization secret by name // @Router /orgs/{org_id}/secrets/{secret} [patch] // @Produce json // @Success 200 {object} Secret @@ -183,7 +183,7 @@ func PatchOrgSecret(c *gin.Context) { // DeleteOrgSecret // -// @Summary Delete the named secret from an organization +// @Summary Delete an organization secret by name // @Router /orgs/{org_id}/secrets/{secret} [delete] // @Produce plain // @Success 204 diff --git a/server/api/orgs.go b/server/api/orgs.go index 80d00c0a9..8c0b1bd75 100644 --- a/server/api/orgs.go +++ b/server/api/orgs.go @@ -26,7 +26,7 @@ import ( // GetOrgs // -// @Summary Get all orgs +// @Summary List organizations // @Description Returns all registered orgs in the system. Requires admin rights. // @Router /orgs [get] // @Produce json @@ -46,7 +46,7 @@ func GetOrgs(c *gin.Context) { // DeleteOrg // -// @Summary Delete an org +// @Summary Delete an organization // @Description Deletes the given org. Requires admin rights. // @Router /orgs/{id} [delete] // @Produce plain diff --git a/server/api/pipeline.go b/server/api/pipeline.go index b7af59956..d8bc8fb67 100644 --- a/server/api/pipeline.go +++ b/server/api/pipeline.go @@ -38,7 +38,7 @@ import ( // CreatePipeline // -// @Summary Run/trigger a pipelines +// @Summary Trigger a manual pipeline // @Router /repos/{repo_id}/pipelines [post] // @Produce json // @Success 200 {object} Pipeline @@ -100,7 +100,8 @@ func createTmpPipeline(event model.WebhookEvent, commit *model.Commit, user *mod // GetPipelines // -// @Summary Get pipelines, current running and past ones +// @Summary List repository pipelines +// @Description Get a list of pipelines for a repository. // @Router /repos/{repo_id}/pipelines [get] // @Produce json // @Success 200 {array} Pipeline @@ -146,7 +147,7 @@ func GetPipelines(c *gin.Context) { // DeletePipeline // -// @Summary Delete pipeline +// @Summary Delete a pipeline // @Router /repos/{repo_id}/pipelines/{number} [delete] // @Produce plain // @Success 204 @@ -186,7 +187,7 @@ func DeletePipeline(c *gin.Context) { // GetPipeline // -// @Summary Pipeline information by number +// @Summary Get a repositories pipeline // @Router /repos/{repo_id}/pipelines/{number} [get] // @Produce json // @Success 200 {object} Pipeline @@ -241,7 +242,7 @@ func GetPipelineLast(c *gin.Context) { // GetStepLogs // -// @Summary Log information +// @Summary Get logs for a pipeline step // @Router /repos/{repo_id}/logs/{number}/{stepID} [get] // @Produce json // @Success 200 {array} LogEntry @@ -297,7 +298,7 @@ func GetStepLogs(c *gin.Context) { // DeleteStepLogs // -// @Summary Deletes step log +// @Summary Delete step logs of a pipeline // @Router /repos/{repo_id}/logs/{number}/{stepId} [delete] // @Produce plain // @Success 204 @@ -357,7 +358,7 @@ func DeleteStepLogs(c *gin.Context) { // GetPipelineConfig // -// @Summary Pipeline configuration +// @Summary Get configuration files for a pipeline // @Router /repos/{repo_id}/pipelines/{number}/config [get] // @Produce json // @Success 200 {array} Config @@ -391,7 +392,7 @@ func GetPipelineConfig(c *gin.Context) { // CancelPipeline // -// @Summary Cancels a pipeline +// @Summary Cancel a pipeline // @Router /repos/{repo_id}/pipelines/{number}/cancel [post] // @Produce plain // @Success 200 @@ -427,7 +428,7 @@ func CancelPipeline(c *gin.Context) { // PostApproval // -// @Summary Start pipelines in gated repos +// @Summary Approve and start a pipeline // @Router /repos/{repo_id}/pipelines/{number}/approve [post] // @Produce json // @Success 200 {object} Pipeline @@ -459,7 +460,7 @@ func PostApproval(c *gin.Context) { // PostDecline // -// @Summary Decline pipelines in gated repos +// @Summary Decline a pipeline // @Router /repos/{repo_id}/pipelines/{number}/decline [post] // @Produce json // @Success 200 {object} Pipeline @@ -491,7 +492,7 @@ func PostDecline(c *gin.Context) { // GetPipelineQueue // -// @Summary List pipeline queues +// @Summary List pipelines in queue // @Router /pipelines [get] // @Produce json // @Success 200 {array} Feed @@ -588,7 +589,7 @@ func PostPipeline(c *gin.Context) { // DeletePipelineLogs // -// @Summary Deletes log +// @Summary Deletes all logs of a pipeline // @Router /repos/{repo_id}/logs/{number} [delete] // @Produce plain // @Success 204 diff --git a/server/api/registry.go b/server/api/registry.go index be2cc6b76..c26ea42b7 100644 --- a/server/api/registry.go +++ b/server/api/registry.go @@ -26,7 +26,7 @@ import ( // GetRegistry // -// @Summary Get a named registry +// @Summary Get a registry by name // @Router /repos/{repo_id}/registry/{registry} [get] // @Produce json // @Success 200 {object} Registry @@ -49,7 +49,7 @@ func GetRegistry(c *gin.Context) { // PostRegistry // -// @Summary Persist/create a registry +// @Summary Create a registry // @Router /repos/{repo_id}/registry [post] // @Produce json // @Success 200 {object} Registry @@ -86,7 +86,7 @@ func PostRegistry(c *gin.Context) { // PatchRegistry // -// @Summary Update a named registry +// @Summary Update a registry by name // @Router /repos/{repo_id}/registry/{registry} [patch] // @Produce json // @Success 200 {object} Registry @@ -134,7 +134,7 @@ func PatchRegistry(c *gin.Context) { // GetRegistryList // -// @Summary Get the registry list +// @Summary List registries // @Router /repos/{repo_id}/registry [get] // @Produce json // @Success 200 {array} Registry @@ -161,7 +161,7 @@ func GetRegistryList(c *gin.Context) { // DeleteRegistry // -// @Summary Delete a named registry +// @Summary Delete a registry by name // @Router /repos/{repo_id}/registry/{registry} [delete] // @Produce plain // @Success 204 diff --git a/server/api/repo.go b/server/api/repo.go index 6d03dcede..e7b46faf1 100644 --- a/server/api/repo.go +++ b/server/api/repo.go @@ -199,7 +199,7 @@ func PostRepo(c *gin.Context) { // PatchRepo // -// @Summary Change a repository +// @Summary Update a repository // @Router /repos/{repo_id} [patch] // @Produce json // @Success 200 {object} Repo @@ -273,7 +273,7 @@ func PatchRepo(c *gin.Context) { // ChownRepo // -// @Summary Change a repository's owner, to the one holding the access token +// @Summary Change a repository's owner to the currently authenticated user // @Router /repos/{repo_id}/chown [post] // @Produce json // @Success 200 {object} Repo @@ -296,20 +296,20 @@ func ChownRepo(c *gin.Context) { // LookupRepo // -// @Summary Get repository by full-name +// @Summary Lookup a repository by full name // @Router /repos/lookup/{repo_full_name} [get] // @Produce json // @Success 200 {object} Repo // @Tags Repositories // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param repo_full_name path string true "the repository full-name / slug" +// @Param repo_full_name path string true "the repository full name / slug" func LookupRepo(c *gin.Context) { c.JSON(http.StatusOK, session.Repo(c)) } // GetRepo // -// @Summary Get repository information +// @Summary Get a repository // @Router /repos/{repo_id} [get] // @Produce json // @Success 200 {object} Repo @@ -322,7 +322,7 @@ func GetRepo(c *gin.Context) { // GetRepoPermissions // -// @Summary Repository permission information +// @Summary Check current authenticated users access to the repository // @Description The repository permission, according to the used access token. // @Router /repos/{repo_id}/permissions [get] // @Produce json @@ -337,7 +337,7 @@ func GetRepoPermissions(c *gin.Context) { // GetRepoBranches // -// @Summary Get repository branches +// @Summary Get branches of a repository // @Router /repos/{repo_id}/branches [get] // @Produce json // @Success 200 {array} string @@ -367,7 +367,7 @@ func GetRepoBranches(c *gin.Context) { // GetRepoPullRequests // -// @Summary List active pull requests +// @Summary List active pull requests of a repository // @Router /repos/{repo_id}/pull_requests [get] // @Produce json // @Success 200 {array} PullRequest @@ -547,7 +547,8 @@ func MoveRepo(c *gin.Context) { // GetAllRepos // -// @Summary List all repositories on the server. Requires admin rights. +// @Summary List all repositories on the server +// @Description Returns a list of all repositories. Requires admin rights. // @Router /repos [get] // @Produce json // @Success 200 {array} Repo @@ -572,7 +573,8 @@ func GetAllRepos(c *gin.Context) { // RepairAllRepos // -// @Summary Repair all repositories on the server. Requires admin rights. +// @Summary Repair all repositories on the server +// @Description Executes a repair process on all repositories. Requires admin rights. // @Router /repos/repair [post] // @Produce plain // @Success 204 diff --git a/server/api/repo_secret.go b/server/api/repo_secret.go index 7557dfb9a..cdc58876d 100644 --- a/server/api/repo_secret.go +++ b/server/api/repo_secret.go @@ -26,7 +26,7 @@ import ( // GetSecret // -// @Summary Get a named secret +// @Summary Get a repository secret by name // @Router /repos/{repo_id}/secrets/{secretName} [get] // @Produce json // @Success 200 {object} Secret @@ -49,7 +49,7 @@ func GetSecret(c *gin.Context) { // PostSecret // -// @Summary Persist/create a secret +// @Summary Create a repository secret // @Router /repos/{repo_id}/secrets [post] // @Produce json // @Success 200 {object} Secret @@ -87,7 +87,7 @@ func PostSecret(c *gin.Context) { // PatchSecret // -// @Summary Update a named secret +// @Summary Update a repository secret by name // @Router /repos/{repo_id}/secrets/{secretName} [patch] // @Produce json // @Success 200 {object} Secret @@ -138,7 +138,7 @@ func PatchSecret(c *gin.Context) { // GetSecretList // -// @Summary Get the secret list +// @Summary List repository secrets // @Router /repos/{repo_id}/secrets [get] // @Produce json // @Success 200 {array} Secret @@ -165,7 +165,7 @@ func GetSecretList(c *gin.Context) { // DeleteSecret // -// @Summary Delete a named secret +// @Summary Delete a repository secret by name // @Router /repos/{repo_id}/secrets/{secretName} [delete] // @Produce plain // @Success 204 diff --git a/server/api/stream.go b/server/api/stream.go index 361c2a4f4..6189cfc3d 100644 --- a/server/api/stream.go +++ b/server/api/stream.go @@ -36,8 +36,8 @@ import ( // EventStreamSSE // -// @Summary Event stream -// @Description event source streaming for compatibility with quic and http2 +// @Summary Stream events like pipeline updates +// @Description With quic and http2 support // @Router /stream/events [get] // @Produce plain // @Success 200 @@ -124,7 +124,7 @@ func EventStreamSSE(c *gin.Context) { // LogStreamSSE // -// @Summary Log stream +// @Summary Stream logs of a pipeline step // @Router /stream/logs/{repo_id}/{pipeline}/{stepID} [get] // @Produce plain // @Success 200 diff --git a/server/api/user.go b/server/api/user.go index d24849bf3..ac8863953 100644 --- a/server/api/user.go +++ b/server/api/user.go @@ -32,7 +32,7 @@ import ( // GetSelf // -// @Summary Returns the currently authenticated user. +// @Summary Get the currently authenticated user // @Router /user [get] // @Produce json // @Success 200 {object} User @@ -44,11 +44,11 @@ func GetSelf(c *gin.Context) { // GetFeed // -// @Summary A feed entry for a build. -// @Description Feed entries can be used to display information on the latest builds. +// @Summary Get the currently authenticaed users pipeline feed +// @Description The feed lists the most recent pipeline for the currently authenticated user. // @Router /user/feed [get] // @Produce json -// @Success 200 {object} Feed +// @Success 200 {array} Feed // @Tags User // @Param Authorization header string true "Insert your personal access token" default(Bearer ) func GetFeed(c *gin.Context) { @@ -77,7 +77,7 @@ func GetFeed(c *gin.Context) { // GetRepos // -// @Summary Get user's repos +// @Summary Get user's repositories // @Description Retrieve the currently authenticated User's Repository list // @Router /user/repos [get] // @Produce json diff --git a/server/api/users.go b/server/api/users.go index c35339eef..1a591d127 100644 --- a/server/api/users.go +++ b/server/api/users.go @@ -28,7 +28,7 @@ import ( // GetUsers // -// @Summary Get all users +// @Summary List users // @Description Returns all registered, active users in the system. Requires admin rights. // @Router /users [get] // @Produce json @@ -67,7 +67,7 @@ func GetUser(c *gin.Context) { // PatchUser // -// @Summary Change a user +// @Summary Update a user // @Description Changes the data of an existing user. Requires admin rights. // @Router /users/{login} [patch] // @Produce json diff --git a/web/src/components/admin/settings/AdminAgentsTab.vue b/web/src/components/admin/settings/AdminAgentsTab.vue index 20371e5f3..60f160455 100644 --- a/web/src/components/admin/settings/AdminAgentsTab.vue +++ b/web/src/components/admin/settings/AdminAgentsTab.vue @@ -158,7 +158,7 @@ const selectedAgent = ref>(); const isEditingAgent = computed(() => !!selectedAgent.value?.id); async function loadAgents(page: number): Promise { - return apiClient.getAgents(page); + return apiClient.getAgents({ page }); } const { resetPage, data: agents } = usePagination(loadAgents, () => !selectedAgent.value); diff --git a/web/src/components/admin/settings/AdminOrgsTab.vue b/web/src/components/admin/settings/AdminOrgsTab.vue index 6d54b8585..dbcea42b7 100644 --- a/web/src/components/admin/settings/AdminOrgsTab.vue +++ b/web/src/components/admin/settings/AdminOrgsTab.vue @@ -50,7 +50,7 @@ const notifications = useNotifications(); const { t } = useI18n(); async function loadOrgs(page: number): Promise { - return apiClient.getOrgs(page); + return apiClient.getOrgs({ page }); } const { resetPage, data: orgs } = usePagination(loadOrgs); diff --git a/web/src/components/admin/settings/AdminReposTab.vue b/web/src/components/admin/settings/AdminReposTab.vue index c131d1962..bc37d460f 100644 --- a/web/src/components/admin/settings/AdminReposTab.vue +++ b/web/src/components/admin/settings/AdminReposTab.vue @@ -56,7 +56,7 @@ const notifications = useNotifications(); const i18n = useI18n(); async function loadRepos(page: number): Promise { - return apiClient.getAllRepos(page); + return apiClient.getAllRepos({ page }); } const { data: repos } = usePagination(loadRepos); diff --git a/web/src/components/admin/settings/AdminSecretsTab.vue b/web/src/components/admin/settings/AdminSecretsTab.vue index 43a59d6a7..3cdfba59c 100644 --- a/web/src/components/admin/settings/AdminSecretsTab.vue +++ b/web/src/components/admin/settings/AdminSecretsTab.vue @@ -65,7 +65,7 @@ const selectedSecret = ref>(); const isEditingSecret = computed(() => !!selectedSecret.value?.id); async function loadSecrets(page: number): Promise { - return apiClient.getGlobalSecretList(page); + return apiClient.getGlobalSecretList({ page }); } const { resetPage, data: secrets } = usePagination(loadSecrets, () => !selectedSecret.value); diff --git a/web/src/components/admin/settings/AdminUsersTab.vue b/web/src/components/admin/settings/AdminUsersTab.vue index 62c35c8e6..626a6a21e 100644 --- a/web/src/components/admin/settings/AdminUsersTab.vue +++ b/web/src/components/admin/settings/AdminUsersTab.vue @@ -107,7 +107,7 @@ const selectedUser = ref>(); const isEditingUser = computed(() => !!selectedUser.value?.id); async function loadUsers(page: number): Promise { - return apiClient.getUsers(page); + return apiClient.getUsers({ page }); } const { resetPage, data: users } = usePagination(loadUsers, () => !selectedUser.value); diff --git a/web/src/components/layout/popups/ManualPipelinePopup.vue b/web/src/components/layout/popups/ManualPipelinePopup.vue index 5c5bdd455..49909319f 100644 --- a/web/src/components/layout/popups/ManualPipelinePopup.vue +++ b/web/src/components/layout/popups/ManualPipelinePopup.vue @@ -90,7 +90,7 @@ const pipelineOptions = computed(() => { const loading = ref(true); onMounted(async () => { - const data = await usePaginate((page) => apiClient.getRepoBranches(repo.value.id, page)); + const data = await usePaginate((page) => apiClient.getRepoBranches(repo.value.id, { page })); branches.value = data.map((e) => ({ text: e, value: e, diff --git a/web/src/components/org/settings/OrgSecretsTab.vue b/web/src/components/org/settings/OrgSecretsTab.vue index c6f1b32a6..4bb9b318c 100644 --- a/web/src/components/org/settings/OrgSecretsTab.vue +++ b/web/src/components/org/settings/OrgSecretsTab.vue @@ -69,7 +69,7 @@ async function loadSecrets(page: number): Promise { throw new Error("Unexpected: Can't load org"); } - return apiClient.getOrgSecretList(org.value.id, page); + return apiClient.getOrgSecretList(org.value.id, { page }); } const { resetPage, data: secrets } = usePagination(loadSecrets, () => !selectedSecret.value); diff --git a/web/src/components/repo/settings/BadgeTab.vue b/web/src/components/repo/settings/BadgeTab.vue index 8583d5b03..ab939e56e 100644 --- a/web/src/components/repo/settings/BadgeTab.vue +++ b/web/src/components/repo/settings/BadgeTab.vue @@ -70,7 +70,7 @@ async function loadBranches() { throw new Error('Unexpected: "repo" should be provided at this place'); } - branches.value = (await usePaginate((page) => apiClient.getRepoBranches(repo.value.id, page))) + branches.value = (await usePaginate((page) => apiClient.getRepoBranches(repo.value.id, { page }))) .map((b) => ({ value: b, text: b, diff --git a/web/src/components/repo/settings/CronTab.vue b/web/src/components/repo/settings/CronTab.vue index 604a452b2..75d827309 100644 --- a/web/src/components/repo/settings/CronTab.vue +++ b/web/src/components/repo/settings/CronTab.vue @@ -121,7 +121,7 @@ async function loadCrons(page: number): Promise { throw new Error("Unexpected: Can't load repo"); } - return apiClient.getCronList(repo.value.id, page); + return apiClient.getCronList(repo.value.id, { page }); } const { resetPage, data: crons } = usePagination(loadCrons, () => !selectedCron.value); diff --git a/web/src/components/repo/settings/RegistriesTab.vue b/web/src/components/repo/settings/RegistriesTab.vue index 675bc79c4..13934dc86 100644 --- a/web/src/components/repo/settings/RegistriesTab.vue +++ b/web/src/components/repo/settings/RegistriesTab.vue @@ -104,7 +104,7 @@ async function loadRegistries(page: number): Promise { throw new Error("Unexpected: Can't load repo"); } - return apiClient.getRegistryList(repo.value.id, page); + return apiClient.getRegistryList(repo.value.id, { page }); } const { resetPage, data: registries } = usePagination(loadRegistries, () => !selectedRegistry.value); diff --git a/web/src/components/repo/settings/SecretsTab.vue b/web/src/components/repo/settings/SecretsTab.vue index 9f17a2f9f..58012b0bc 100644 --- a/web/src/components/repo/settings/SecretsTab.vue +++ b/web/src/components/repo/settings/SecretsTab.vue @@ -71,11 +71,11 @@ async function loadSecrets(page: number, level: 'repo' | 'org' | 'global'): Prom switch (level) { case 'repo': - return apiClient.getSecretList(repo.value.id, page); + return apiClient.getSecretList(repo.value.id, { page }); case 'org': - return apiClient.getOrgSecretList(repo.value.org_id, page); + return apiClient.getOrgSecretList(repo.value.org_id, { page }); case 'global': - return apiClient.getGlobalSecretList(page); + return apiClient.getGlobalSecretList({ page }); default: throw new Error(`Unexpected level: ${level}`); } diff --git a/web/src/components/user/UserSecretsTab.vue b/web/src/components/user/UserSecretsTab.vue index e5593a51e..1288a5a8c 100644 --- a/web/src/components/user/UserSecretsTab.vue +++ b/web/src/components/user/UserSecretsTab.vue @@ -78,7 +78,7 @@ async function loadSecrets(page: number): Promise { throw new Error('Unexpected: Unauthenticated'); } - return apiClient.getOrgSecretList(user.org_id, page); + return apiClient.getOrgSecretList(user.org_id, { page }); } const { resetPage, data: secrets } = usePagination(loadSecrets, () => !selectedSecret.value); diff --git a/web/src/lib/api/index.ts b/web/src/lib/api/index.ts index e7e628550..6c994ed7b 100644 --- a/web/src/lib/api/index.ts +++ b/web/src/lib/api/index.ts @@ -34,6 +34,11 @@ type DeploymentOptions = { variables: Record; }; +type PaginationOptions = { + page?: number; + perPage?: number; +}; + export default class WoodpeckerClient extends ApiClient { getRepoList(opts?: RepoListOptions): Promise { const query = encodeQueryString(opts); @@ -52,12 +57,14 @@ export default class WoodpeckerClient extends ApiClient { return this._get(`/api/repos/${repoId}/permissions`) as Promise; } - getRepoBranches(repoId: number, page: number): Promise { - return this._get(`/api/repos/${repoId}/branches?page=${page}`) as Promise; + getRepoBranches(repoId: number, opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/repos/${repoId}/branches?${query}`) as Promise; } - getRepoPullRequests(repoId: number, page: number): Promise { - return this._get(`/api/repos/${repoId}/pull_requests?page=${page}`) as Promise; + getRepoPullRequests(repoId: number, opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/repos/${repoId}/pull_requests?${query}`) as Promise; } activateRepo(forgeRemoteId: string): Promise { @@ -93,7 +100,7 @@ export default class WoodpeckerClient extends ApiClient { return this._post(`/api/repos/${repoId}/pipelines/${pipelineNumber}?${query}`) as Promise; } - getPipelineList(repoId: number, opts?: Record): Promise { + getPipelineList(repoId: number, opts?: PaginationOptions & { before?: string; after?: string }): Promise { const query = encodeQueryString(opts); return this._get(`/api/repos/${repoId}/pipelines?${query}`) as Promise; } @@ -106,9 +113,8 @@ export default class WoodpeckerClient extends ApiClient { return this._get(`/api/repos/${repoId}/pipelines/${pipelineNumber}/config`) as Promise; } - getPipelineFeed(opts?: Record): Promise { - const query = encodeQueryString(opts); - return this._get(`/api/user/feed?${query}`) as Promise; + getPipelineFeed(): Promise { + return this._get(`/api/user/feed`) as Promise; } cancelPipeline(repoId: number, pipelineNumber: number): Promise { @@ -126,7 +132,7 @@ export default class WoodpeckerClient extends ApiClient { restartPipeline( repoId: number, pipeline: string, - opts?: Record, + opts?: { event?: string; deploy_to?: string; fork?: boolean }, ): Promise { const query = encodeQueryString(opts); return this._post(`/api/repos/${repoId}/pipelines/${pipeline}?${query}`) as Promise; @@ -140,8 +146,9 @@ export default class WoodpeckerClient extends ApiClient { return this._delete(`/api/repos/${repoId}/logs/${pipeline}/${step}`); } - getSecretList(repoId: number, page: number): Promise { - return this._get(`/api/repos/${repoId}/secrets?page=${page}`) as Promise; + getSecretList(repoId: number, opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/repos/${repoId}/secrets?${query}`) as Promise; } createSecret(repoId: number, secret: Partial): Promise { @@ -158,8 +165,9 @@ export default class WoodpeckerClient extends ApiClient { return this._delete(`/api/repos/${repoId}/secrets/${name}`); } - getRegistryList(repoId: number, page: number): Promise { - return this._get(`/api/repos/${repoId}/registry?page=${page}`) as Promise; + getRegistryList(repoId: number, opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/repos/${repoId}/registry?${query}`) as Promise; } createRegistry(repoId: number, registry: Partial): Promise { @@ -174,8 +182,9 @@ export default class WoodpeckerClient extends ApiClient { return this._delete(`/api/repos/${repoId}/registry/${registryAddress}`); } - getCronList(repoId: number, page: number): Promise { - return this._get(`/api/repos/${repoId}/cron?page=${page}`) as Promise; + getCronList(repoId: number, opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/repos/${repoId}/cron?${query}`) as Promise; } createCron(repoId: number, cron: Partial): Promise { @@ -206,8 +215,9 @@ export default class WoodpeckerClient extends ApiClient { return this._get(`/api/orgs/${orgId}/permissions`) as Promise; } - getOrgSecretList(orgId: number, page: number): Promise { - return this._get(`/api/orgs/${orgId}/secrets?page=${page}`) as Promise; + getOrgSecretList(orgId: number, opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/orgs/${orgId}/secrets?${query}`) as Promise; } createOrgSecret(orgId: number, secret: Partial): Promise { @@ -224,8 +234,9 @@ export default class WoodpeckerClient extends ApiClient { return this._delete(`/api/orgs/${orgId}/secrets/${name}`); } - getGlobalSecretList(page: number): Promise { - return this._get(`/api/secrets?page=${page}`) as Promise; + getGlobalSecretList(opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/secrets?${query}`) as Promise; } createGlobalSecret(secret: Partial): Promise { @@ -250,8 +261,9 @@ export default class WoodpeckerClient extends ApiClient { return this._post('/api/user/token') as Promise; } - getAgents(page: number): Promise { - return this._get(`/api/agents?page=${page}`) as Promise; + getAgents(opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/agents?${query}`) as Promise; } getAgent(agentId: Agent['id']): Promise { @@ -282,8 +294,9 @@ export default class WoodpeckerClient extends ApiClient { return this._post('/api/queue/resume'); } - getUsers(page: number): Promise { - return this._get(`/api/users?page=${page}`) as Promise; + getUsers(opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/users?${query}`) as Promise; } getUser(username: string): Promise { @@ -306,16 +319,18 @@ export default class WoodpeckerClient extends ApiClient { return this._delete('/api/user/token') as Promise; } - getOrgs(page: number): Promise { - return this._get(`/api/orgs?page=${page}`) as Promise; + getOrgs(opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/orgs?${query}`) as Promise; } deleteOrg(org: Org): Promise { return this._delete(`/api/orgs/${org.id}`); } - getAllRepos(page: number): Promise { - return this._get(`/api/repos?page=${page}`) as Promise; + getAllRepos(opts?: PaginationOptions): Promise { + const query = encodeQueryString(opts); + return this._get(`/api/repos?${query}`) as Promise; } repairAllRepos(): Promise { diff --git a/web/src/store/pipelines.ts b/web/src/store/pipelines.ts index 41c2a4473..9c388c9ee 100644 --- a/web/src/store/pipelines.ts +++ b/web/src/store/pipelines.ts @@ -46,8 +46,8 @@ export const usePipelineStore = defineStore('pipelines', () => { setPipeline(repoId, pipeline); } - async function loadRepoPipelines(repoId: number) { - const _pipelines = await apiClient.getPipelineList(repoId); + async function loadRepoPipelines(repoId: number, page?: number) { + const _pipelines = await apiClient.getPipelineList(repoId, { page }); _pipelines.forEach((pipeline) => { setPipeline(repoId, pipeline); }); diff --git a/web/src/views/repo/RepoBranches.vue b/web/src/views/repo/RepoBranches.vue index 8c65eb70e..f26a23277 100644 --- a/web/src/views/repo/RepoBranches.vue +++ b/web/src/views/repo/RepoBranches.vue @@ -41,7 +41,7 @@ async function loadBranches(page: number): Promise { throw new Error('Unexpected: "repo" should be provided at this place'); } - return apiClient.getRepoBranches(repo.value.id, page); + return apiClient.getRepoBranches(repo.value.id, { page }); } const { resetPage, data: branches, loading } = usePagination(loadBranches); diff --git a/web/src/views/repo/RepoPullRequests.vue b/web/src/views/repo/RepoPullRequests.vue index d6c7407bc..d20f33fde 100644 --- a/web/src/views/repo/RepoPullRequests.vue +++ b/web/src/views/repo/RepoPullRequests.vue @@ -48,7 +48,7 @@ async function loadPullRequests(page: number): Promise { throw new Error('Unexpected: "repo" should be provided at this place'); } - return apiClient.getRepoPullRequests(repo.value.id, page); + return apiClient.getRepoPullRequests(repo.value.id, { page }); } const { resetPage, data: pullRequests, loading } = usePagination(loadPullRequests);