From 95e7ef1f64dc129fafc4114f4b8d6fa67fdfb5f5 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Mon, 1 Jul 2024 12:35:24 -0400 Subject: chore: pull swagger file from `v8.next.forgejo.org` --- swagger.v1.json | 1635 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 1565 insertions(+), 70 deletions(-) diff --git a/swagger.v1.json b/swagger.v1.json index 6611d2a..a32491a 100644 --- a/swagger.v1.json +++ b/swagger.v1.json @@ -10,10 +10,61 @@ "name": "MIT", "url": "http://opensource.org/licenses/MIT" }, - "version": "7.0.1+gitea-1.22.0" + "version": "8.0.0-dev-1514-f9ad844fd6+gitea-1.22.0" }, "basePath": "/api/v1", "paths": { + "/activitypub/repository-id/{repository-id}": { + "get": { + "produces": ["application/json"], + "tags": ["activitypub"], + "summary": "Returns the Repository actor for a repo", + "operationId": "activitypubRepository", + "parameters": [ + { + "type": "integer", + "description": "repository ID of the repo", + "name": "repository-id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/ActivityPub" + } + } + } + }, + "/activitypub/repository-id/{repository-id}/inbox": { + "post": { + "produces": ["application/json"], + "tags": ["activitypub"], + "summary": "Send to the inbox", + "operationId": "activitypubRepositoryInbox", + "parameters": [ + { + "type": "integer", + "description": "repository ID of the repo", + "name": "repository-id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/ForgeLike" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, "/activitypub/user-id/{user-id}": { "get": { "produces": ["application/json"], @@ -1511,6 +1562,208 @@ } } }, + "/orgs/{org}/actions/variables": { + "get": { + "produces": ["application/json"], + "tags": ["organization"], + "summary": "Get an org-level variables list", + "operationId": "getOrgVariablesList", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/VariableList" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/actions/variables/{variablename}": { + "get": { + "produces": ["application/json"], + "tags": ["organization"], + "summary": "Get an org-level variable", + "operationId": "getOrgVariable", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/ActionVariable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "put": { + "consumes": ["application/json"], + "produces": ["application/json"], + "tags": ["organization"], + "summary": "Update an org-level variable", + "operationId": "updateOrgVariable", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/UpdateVariableOption" + } + } + ], + "responses": { + "201": { + "description": "response when updating an org-level variable" + }, + "204": { + "description": "response when updating an org-level variable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": ["application/json"], + "produces": ["application/json"], + "tags": ["organization"], + "summary": "Create an org-level variable", + "operationId": "createOrgVariable", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateVariableOption" + } + } + ], + "responses": { + "201": { + "description": "response when creating an org-level variable" + }, + "204": { + "description": "response when creating an org-level variable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": ["application/json"], + "tags": ["organization"], + "summary": "Delete an org-level variable", + "operationId": "deleteOrgVariable", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/ActionVariable" + }, + "201": { + "description": "response when deleting a variable" + }, + "204": { + "description": "response when deleting a variable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, "/orgs/{org}/activities/feeds": { "get": { "produces": ["application/json"], @@ -2977,7 +3230,7 @@ }, { "type": "string", - "description": "sort repos by attribute. Supported values are \"alpha\", \"created\", \"updated\", \"size\", and \"id\". Default is \"alpha\"", + "description": "sort repos by attribute. Supported values are \"alpha\", \"created\", \"updated\", \"size\", \"git_size\", \"lfs_size\", \"stars\", \"forks\" and \"id\". Default is \"alpha\"", "name": "sort", "in": "query" }, @@ -3121,17 +3374,397 @@ } } }, + "/repos/{owner}/{repo}/actions/secrets": { + "get": { + "produces": ["application/json"], + "tags": ["repository"], + "summary": "List an repo's actions secrets", + "operationId": "repoListActionsSecrets", + "parameters": [ + { + "type": "string", + "description": "owner of the repository", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repository", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/SecretList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, "/repos/{owner}/{repo}/actions/secrets/{secretname}": { "put": { "consumes": ["application/json"], "produces": ["application/json"], "tags": ["repository"], - "summary": "Create or Update a secret value in a repository", - "operationId": "updateRepoSecret", + "summary": "Create or Update a secret value in a repository", + "operationId": "updateRepoSecret", + "parameters": [ + { + "type": "string", + "description": "owner of the repository", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repository", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the secret", + "name": "secretname", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateOrUpdateSecretOption" + } + } + ], + "responses": { + "201": { + "description": "response when creating a secret" + }, + "204": { + "description": "response when updating a secret" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "consumes": ["application/json"], + "produces": ["application/json"], + "tags": ["repository"], + "summary": "Delete a secret in a repository", + "operationId": "deleteRepoSecret", + "parameters": [ + { + "type": "string", + "description": "owner of the repository", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repository", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the secret", + "name": "secretname", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "delete one secret of the organization" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/actions/tasks": { + "get": { + "produces": ["application/json"], + "tags": ["repository"], + "summary": "List a repository's action tasks", + "operationId": "ListActionTasks", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results, default maximum page size is 50", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/TasksList" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "$ref": "#/responses/conflict" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/actions/variables": { + "get": { + "produces": ["application/json"], + "tags": ["repository"], + "summary": "Get repo-level variables list", + "operationId": "getRepoVariablesList", + "parameters": [ + { + "type": "string", + "description": "name of the owner", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repository", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/VariableList" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/actions/variables/{variablename}": { + "get": { + "produces": ["application/json"], + "tags": ["repository"], + "summary": "Get a repo-level variable", + "operationId": "getRepoVariable", + "parameters": [ + { + "type": "string", + "description": "name of the owner", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repository", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/ActionVariable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "put": { + "produces": ["application/json"], + "tags": ["repository"], + "summary": "Update a repo-level variable", + "operationId": "updateRepoVariable", + "parameters": [ + { + "type": "string", + "description": "name of the owner", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repository", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/UpdateVariableOption" + } + } + ], + "responses": { + "201": { + "description": "response when updating a repo-level variable" + }, + "204": { + "description": "response when updating a repo-level variable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "produces": ["application/json"], + "tags": ["repository"], + "summary": "Create a repo-level variable", + "operationId": "createRepoVariable", + "parameters": [ + { + "type": "string", + "description": "name of the owner", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repository", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateVariableOption" + } + } + ], + "responses": { + "201": { + "description": "response when creating a repo-level variable" + }, + "204": { + "description": "response when creating a repo-level variable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": ["application/json"], + "tags": ["repository"], + "summary": "Delete a repo-level variable", + "operationId": "deleteRepoVariable", "parameters": [ { "type": "string", - "description": "owner of the repository", + "description": "name of the owner", "name": "owner", "in": "path", "required": true @@ -3145,25 +3778,21 @@ }, { "type": "string", - "description": "name of the secret", - "name": "secretname", + "description": "name of the variable", + "name": "variablename", "in": "path", "required": true - }, - { - "name": "body", - "in": "body", - "schema": { - "$ref": "#/definitions/CreateOrUpdateSecretOption" - } } ], "responses": { + "200": { + "$ref": "#/responses/ActionVariable" + }, "201": { - "description": "response when creating a secret" + "description": "response when deleting a variable" }, "204": { - "description": "response when updating a secret" + "description": "response when deleting a variable" }, "400": { "$ref": "#/responses/error" @@ -3172,42 +3801,47 @@ "$ref": "#/responses/notFound" } } - }, - "delete": { + } + }, + "/repos/{owner}/{repo}/actions/workflows/{workflowname}/dispatches": { + "post": { "consumes": ["application/json"], - "produces": ["application/json"], "tags": ["repository"], - "summary": "Delete a secret in a repository", - "operationId": "deleteRepoSecret", + "summary": "Dispatches a workflow", + "operationId": "DispatchWorkflow", "parameters": [ { "type": "string", - "description": "owner of the repository", + "description": "owner of the repo", "name": "owner", "in": "path", "required": true }, { "type": "string", - "description": "name of the repository", + "description": "name of the repo", "name": "repo", "in": "path", "required": true }, { "type": "string", - "description": "name of the secret", - "name": "secretname", + "description": "name of the workflow", + "name": "workflowname", "in": "path", "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/DispatchWorkflowOption" + } } ], "responses": { "204": { - "description": "delete one secret of the organization" - }, - "400": { - "$ref": "#/responses/error" + "$ref": "#/responses/empty" }, "404": { "$ref": "#/responses/notFound" @@ -4263,6 +4897,45 @@ } } }, + "/repos/{owner}/{repo}/compare/{basehead}": { + "get": { + "produces": ["application/json"], + "tags": ["repository"], + "summary": "Get commit comparison information", + "operationId": "repoCompareDiff", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "compare two branches or commits", + "name": "basehead", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Compare" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, "/repos/{owner}/{repo}/contents": { "get": { "produces": ["application/json"], @@ -6310,6 +6983,9 @@ "404": { "$ref": "#/responses/error" }, + "422": { + "$ref": "#/responses/validationError" + }, "423": { "$ref": "#/responses/repoArchivedError" } @@ -6878,6 +7554,9 @@ "404": { "$ref": "#/responses/error" }, + "422": { + "$ref": "#/responses/validationError" + }, "423": { "$ref": "#/responses/repoArchivedError" } @@ -11407,6 +12086,9 @@ }, "409": { "$ref": "#/responses/error" + }, + "422": { + "$ref": "#/responses/validationError" } } } @@ -11515,8 +12197,8 @@ "404": { "$ref": "#/responses/notFound" }, - "405": { - "$ref": "#/responses/empty" + "422": { + "$ref": "#/responses/validationError" } } } @@ -11595,8 +12277,8 @@ "404": { "$ref": "#/responses/notFound" }, - "405": { - "$ref": "#/responses/empty" + "422": { + "$ref": "#/responses/validationError" } } }, @@ -12220,17 +12902,191 @@ ], "responses": { "200": { - "$ref": "#/responses/WatchInfo" + "$ref": "#/responses/WatchInfo" + }, + "404": { + "description": "User is not watching this repo or repo do not exist" + } + } + }, + "put": { + "tags": ["repository"], + "summary": "Watch a repo", + "operationId": "userCurrentPutSubscription", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/WatchInfo" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": ["repository"], + "summary": "Unwatch a repo", + "operationId": "userCurrentDeleteSubscription", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/tag_protections": { + "get": { + "produces": ["application/json"], + "tags": ["repository"], + "summary": "List tag protections for a repository", + "operationId": "repoListTagProtection", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/TagProtectionList" + } + } + }, + "post": { + "consumes": ["application/json"], + "produces": ["application/json"], + "tags": ["repository"], + "summary": "Create a tag protections for a repository", + "operationId": "repoCreateTagProtection", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateTagProtectionOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/TagProtection" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + }, + "423": { + "$ref": "#/responses/repoArchivedError" + } + } + } + }, + "/repos/{owner}/{repo}/tag_protections/{id}": { + "get": { + "produces": ["application/json"], + "tags": ["repository"], + "summary": "Get a specific tag protection for the repository", + "operationId": "repoGetTagProtection", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "id of the tag protect to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/TagProtection" }, "404": { - "description": "User is not watching this repo or repo do not exist" + "$ref": "#/responses/notFound" } } }, - "put": { + "delete": { + "produces": ["application/json"], "tags": ["repository"], - "summary": "Watch a repo", - "operationId": "userCurrentPutSubscription", + "summary": "Delete a specific tag protection for the repository", + "operationId": "repoDeleteTagProtection", "parameters": [ { "type": "string", @@ -12245,21 +13101,30 @@ "name": "repo", "in": "path", "required": true + }, + { + "type": "integer", + "description": "id of protected tag", + "name": "id", + "in": "path", + "required": true } ], "responses": { - "200": { - "$ref": "#/responses/WatchInfo" + "204": { + "$ref": "#/responses/empty" }, "404": { "$ref": "#/responses/notFound" } } }, - "delete": { + "patch": { + "consumes": ["application/json"], + "produces": ["application/json"], "tags": ["repository"], - "summary": "Unwatch a repo", - "operationId": "userCurrentDeleteSubscription", + "summary": "Edit a tag protections for a repository. Only fields that are set will be changed", + "operationId": "repoEditTagProtection", "parameters": [ { "type": "string", @@ -12274,14 +13139,34 @@ "name": "repo", "in": "path", "required": true + }, + { + "type": "integer", + "description": "id of protected tag", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditTagProtectionOption" + } } ], "responses": { - "204": { - "$ref": "#/responses/empty" + "200": { + "$ref": "#/responses/TagProtection" }, "404": { "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + }, + "423": { + "$ref": "#/responses/repoArchivedError" } } } @@ -12372,6 +13257,9 @@ "409": { "$ref": "#/responses/conflict" }, + "422": { + "$ref": "#/responses/validationError" + }, "423": { "$ref": "#/responses/repoArchivedError" } @@ -12457,6 +13345,9 @@ "409": { "$ref": "#/responses/conflict" }, + "422": { + "$ref": "#/responses/validationError" + }, "423": { "$ref": "#/responses/repoArchivedError" } @@ -14002,6 +14893,170 @@ } } }, + "/user/actions/variables": { + "get": { + "produces": ["application/json"], + "tags": ["user"], + "summary": "Get the user-level list of variables which is created by current doer", + "operationId": "getUserVariablesList", + "parameters": [ + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/VariableList" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user/actions/variables/{variablename}": { + "get": { + "produces": ["application/json"], + "tags": ["user"], + "summary": "Get a user-level variable which is created by current doer", + "operationId": "getUserVariable", + "parameters": [ + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/ActionVariable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "put": { + "consumes": ["application/json"], + "produces": ["application/json"], + "tags": ["user"], + "summary": "Update a user-level variable which is created by current doer", + "operationId": "updateUserVariable", + "parameters": [ + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/UpdateVariableOption" + } + } + ], + "responses": { + "201": { + "description": "response when updating a variable" + }, + "204": { + "description": "response when updating a variable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": ["application/json"], + "produces": ["application/json"], + "tags": ["user"], + "summary": "Create a user-level variable", + "operationId": "createUserVariable", + "parameters": [ + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateVariableOption" + } + } + ], + "responses": { + "201": { + "description": "response when creating a variable" + }, + "204": { + "description": "response when creating a variable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": ["application/json"], + "tags": ["user"], + "summary": "Delete a user-level variable which is created by current doer", + "operationId": "deleteUserVariable", + "parameters": [ + { + "type": "string", + "description": "name of the variable", + "name": "variablename", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "response when deleting a variable" + }, + "204": { + "description": "response when deleting a variable" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, "/user/applications/oauth2": { "get": { "produces": ["application/json"], @@ -15871,42 +16926,154 @@ "properties": { "message": { "type": "string", - "x-go-name": "Message" + "x-go-name": "Message" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "AccessToken": { + "type": "object", + "title": "AccessToken represents an API access token.", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "scopes": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Scopes" + }, + "sha1": { + "type": "string", + "x-go-name": "Token" + }, + "token_last_eight": { + "type": "string", + "x-go-name": "TokenLastEight" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ActionTask": { + "description": "ActionTask represents a ActionTask", + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "CreatedAt" + }, + "display_title": { + "type": "string", + "x-go-name": "DisplayTitle" + }, + "event": { + "type": "string", + "x-go-name": "Event" + }, + "head_branch": { + "type": "string", + "x-go-name": "HeadBranch" + }, + "head_sha": { + "type": "string", + "x-go-name": "HeadSHA" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "run_number": { + "type": "integer", + "format": "int64", + "x-go-name": "RunNumber" + }, + "run_started_at": { + "type": "string", + "format": "date-time", + "x-go-name": "RunStartedAt" + }, + "status": { + "type": "string", + "x-go-name": "Status" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "UpdatedAt" }, "url": { "type": "string", "x-go-name": "URL" + }, + "workflow_id": { + "type": "string", + "x-go-name": "WorkflowID" } }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, - "AccessToken": { + "ActionTaskResponse": { + "description": "ActionTaskResponse returns a ActionTask", "type": "object", - "title": "AccessToken represents an API access token.", "properties": { - "id": { + "total_count": { "type": "integer", "format": "int64", - "x-go-name": "ID" - }, - "name": { - "type": "string", - "x-go-name": "Name" + "x-go-name": "TotalCount" }, - "scopes": { + "workflow_runs": { "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/ActionTask" }, - "x-go-name": "Scopes" - }, - "sha1": { + "x-go-name": "Entries" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ActionVariable": { + "description": "ActionVariable return value of the query API", + "type": "object", + "properties": { + "data": { + "description": "the value of the variable", "type": "string", - "x-go-name": "Token" + "x-go-name": "Data" }, - "token_last_eight": { + "name": { + "description": "the name of the variable", "type": "string", - "x-go-name": "TokenLastEight" + "x-go-name": "Name" + }, + "owner_id": { + "description": "the owner to which the variable belongs", + "type": "integer", + "format": "int64", + "x-go-name": "OwnerID" + }, + "repo_id": { + "description": "the repository to which the variable belongs", + "type": "integer", + "format": "int64", + "x-go-name": "RepoID" } }, "x-go-package": "code.gitea.io/gitea/modules/structs" @@ -15949,7 +17116,37 @@ "x-go-name": "IsPrivate" }, "op_type": { + "description": "the type of action", "type": "string", + "enum": [ + "create_repo", + "rename_repo", + "star_repo", + "watch_repo", + "commit_repo", + "create_issue", + "create_pull_request", + "transfer_repo", + "push_tag", + "comment_issue", + "merge_pull_request", + "close_issue", + "reopen_issue", + "close_pull_request", + "reopen_pull_request", + "delete_tag", + "delete_branch", + "mirror_sync_push", + "mirror_sync_create", + "mirror_sync_delete", + "approve_pull_request", + "reject_pull_request", + "comment_pull", + "publish_release", + "pull_review_dismissed", + "pull_request_ready_for_review", + "auto_merge_pull_request" + ], "x-go-name": "OpType" }, "ref_name": { @@ -16022,6 +17219,9 @@ "description": "AnnotatedTag represents an annotated tag", "type": "object", "properties": { + "archive_download_count": { + "$ref": "#/definitions/TagArchiveDownloadCount" + }, "message": { "type": "string", "x-go-name": "Message" @@ -16723,6 +17923,25 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "Compare": { + "type": "object", + "title": "Compare represents a comparison between two commits.", + "properties": { + "commits": { + "type": "array", + "items": { + "$ref": "#/definitions/Commit" + }, + "x-go-name": "Commits" + }, + "total_commits": { + "type": "integer", + "format": "int64", + "x-go-name": "TotalCommits" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "ContentsResponse": { "description": "ContentsResponse contains information about a repo's entry's (dir, file, symlink, submodule) metadata and content", "type": "object", @@ -17507,6 +18726,10 @@ "type": "boolean", "x-go-name": "IsDraft" }, + "hide_archive_links": { + "type": "boolean", + "x-go-name": "HideArchiveLinks" + }, "name": { "type": "string", "x-go-name": "Title" @@ -17641,6 +18864,31 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "CreateTagProtectionOption": { + "description": "CreateTagProtectionOption options for creating a tag protection", + "type": "object", + "properties": { + "name_pattern": { + "type": "string", + "x-go-name": "NamePattern" + }, + "whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "WhitelistTeams" + }, + "whitelist_usernames": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "WhitelistUsernames" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "CreateTeamOption": { "description": "CreateTeamOption options for creating a team", "type": "object", @@ -17753,6 +19001,19 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "CreateVariableOption": { + "description": "CreateVariableOption the option when creating variable", + "type": "object", + "required": ["value"], + "properties": { + "value": { + "description": "Value of the variable to create", + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "CreateWikiPageOptions": { "description": "CreateWikiPageOptions form for creating wiki", "type": "object", @@ -17938,6 +19199,27 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "DispatchWorkflowOption": { + "description": "DispatchWorkflowOption options when dispatching a workflow", + "type": "object", + "required": ["ref"], + "properties": { + "inputs": { + "description": "Input keys and values configured in the workflow file.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Inputs" + }, + "ref": { + "description": "Git reference for the workflow", + "type": "string", + "x-go-name": "Ref" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "EditAttachmentOptions": { "description": "EditAttachmentOptions options for editing attachments", "type": "object", @@ -18372,6 +19654,10 @@ "type": "boolean", "x-go-name": "IsDraft" }, + "hide_archive_links": { + "type": "boolean", + "x-go-name": "HideArchiveLinks" + }, "name": { "type": "string", "x-go-name": "Title" @@ -18464,7 +19750,7 @@ "x-go-name": "Description" }, "enable_prune": { - "description": "enable prune - remove obsolete remote-tracking references", + "description": "enable prune - remove obsolete remote-tracking references when mirroring", "type": "boolean", "x-go-name": "EnablePrune" }, @@ -18474,6 +19760,11 @@ "external_wiki": { "$ref": "#/definitions/ExternalWiki" }, + "globally_editable_wiki": { + "description": "set the globally editable state of the wiki", + "type": "boolean", + "x-go-name": "GloballyEditableWiki" + }, "has_actions": { "description": "either `true` to enable actions unit, or `false` to disable them.", "type": "boolean", @@ -18551,6 +19842,31 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "EditTagProtectionOption": { + "description": "EditTagProtectionOption options for editing a tag protection", + "type": "object", + "properties": { + "name_pattern": { + "type": "string", + "x-go-name": "NamePattern" + }, + "whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "WhitelistTeams" + }, + "whitelist_usernames": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "WhitelistUsernames" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "EditTeamOption": { "description": "EditTeamOption options for editing a team", "type": "object", @@ -18617,7 +19933,6 @@ "EditUserOption": { "description": "EditUserOption edit user options", "type": "object", - "required": ["source_id", "login_name"], "properties": { "active": { "type": "boolean", @@ -18884,6 +20199,11 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "ForgeLike": { + "description": "ForgeLike activity data type", + "type": "object", + "x-go-package": "code.gitea.io/gitea/modules/forgefed" + }, "GPGKey": { "description": "GPGKey a user GPG key to sign commit and tag in repository", "type": "object", @@ -19625,12 +20945,9 @@ "type": "object", "properties": { "labels": { - "description": "list of label IDs", + "description": "Labels can be a list of integers representing label IDs\nor a list of strings representing label names", "type": "array", - "items": { - "type": "integer", - "format": "int64" - }, + "items": {}, "x-go-name": "Labels" }, "updated_at": { @@ -20702,6 +22019,11 @@ "description": "PullRequest represents a pull request", "type": "object", "properties": { + "additions": { + "type": "integer", + "format": "int64", + "x-go-name": "Additions" + }, "allow_maintainer_edit": { "type": "boolean", "x-go-name": "AllowMaintainerEdit" @@ -20723,6 +22045,11 @@ "type": "string", "x-go-name": "Body" }, + "changed_files": { + "type": "integer", + "format": "int64", + "x-go-name": "ChangedFiles" + }, "closed_at": { "type": "string", "format": "date-time", @@ -20738,10 +22065,19 @@ "format": "date-time", "x-go-name": "Created" }, + "deletions": { + "type": "integer", + "format": "int64", + "x-go-name": "Deletions" + }, "diff_url": { "type": "string", "x-go-name": "DiffURL" }, + "draft": { + "type": "boolean", + "x-go-name": "Draft" + }, "due_date": { "type": "string", "format": "date-time", @@ -20818,6 +22154,12 @@ }, "x-go-name": "RequestedReviewers" }, + "review_comments": { + "description": "number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)", + "type": "integer", + "format": "int64", + "x-go-name": "ReviewComments" + }, "state": { "$ref": "#/definitions/StateType" }, @@ -20851,6 +22193,10 @@ "type": "boolean", "x-go-name": "IsWorkInProgress" }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, "merged": { "type": "boolean", "x-go-name": "HasMerged" @@ -21101,6 +22447,9 @@ "description": "Release represents a repository release", "type": "object", "properties": { + "archive_download_count": { + "$ref": "#/definitions/TagArchiveDownloadCount" + }, "assets": { "type": "array", "items": { @@ -21124,6 +22473,10 @@ "type": "boolean", "x-go-name": "IsDraft" }, + "hide_archive_links": { + "type": "boolean", + "x-go-name": "HideArchiveLinks" + }, "html_url": { "type": "string", "x-go-name": "HTMLURL" @@ -21373,6 +22726,10 @@ "type": "string", "x-go-name": "FullName" }, + "globally_editable_wiki": { + "type": "boolean", + "x-go-name": "GloballyEditableWiki" + }, "has_actions": { "type": "boolean", "x-go-name": "HasActions" @@ -21506,6 +22863,13 @@ "type": "boolean", "x-go-name": "Template" }, + "topics": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Topics" + }, "updated_at": { "type": "string", "format": "date-time", @@ -21671,6 +23035,9 @@ "description": "Tag represents a repository tag", "type": "object", "properties": { + "archive_download_count": { + "$ref": "#/definitions/TagArchiveDownloadCount" + }, "commit": { "$ref": "#/definitions/CommitMeta" }, @@ -21697,6 +23064,63 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "TagArchiveDownloadCount": { + "description": "TagArchiveDownloadCount counts how many times a archive was downloaded", + "type": "object", + "properties": { + "tar_gz": { + "type": "integer", + "format": "int64", + "x-go-name": "TarGz" + }, + "zip": { + "type": "integer", + "format": "int64", + "x-go-name": "Zip" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "TagProtection": { + "description": "TagProtection represents a tag protection", + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name_pattern": { + "type": "string", + "x-go-name": "NamePattern" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "WhitelistTeams" + }, + "whitelist_usernames": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "WhitelistUsernames" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "Team": { "description": "Team represents a team in an organization", "type": "object", @@ -22077,6 +23501,24 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "UpdateVariableOption": { + "description": "UpdateVariableOption the option when updating variable", + "type": "object", + "required": ["value"], + "properties": { + "name": { + "description": "New name for the variable. If the field is empty, the variable name won't be updated.", + "type": "string", + "x-go-name": "Name" + }, + "value": { + "description": "Value of the variable to update", + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "User": { "description": "User represents a user", "type": "object", @@ -22122,6 +23564,11 @@ "type": "string", "x-go-name": "FullName" }, + "html_url": { + "description": "URL to the user's gitea page", + "type": "string", + "x-go-name": "HTMLURL" + }, "id": { "description": "the user's id", "type": "integer", @@ -22174,6 +23621,12 @@ "type": "boolean", "x-go-name": "Restricted" }, + "source_id": { + "description": "The ID of the user's Authentication Source", + "type": "integer", + "format": "int64", + "x-go-name": "SourceID" + }, "starred_repos_count": { "type": "integer", "format": "int64", @@ -22461,6 +23914,12 @@ } } }, + "ActionVariable": { + "description": "ActionVariable", + "schema": { + "$ref": "#/definitions/ActionVariable" + } + }, "ActivityFeedsList": { "description": "ActivityFeedsList", "schema": { @@ -22648,6 +24107,12 @@ } } }, + "Compare": { + "description": "", + "schema": { + "$ref": "#/definitions/Compare" + } + }, "ContentsListResponse": { "description": "ContentsListResponse", "schema": { @@ -23257,6 +24722,27 @@ } } }, + "TagProtection": { + "description": "TagProtection", + "schema": { + "$ref": "#/definitions/TagProtection" + } + }, + "TagProtectionList": { + "description": "TagProtectionList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/TagProtection" + } + } + }, + "TasksList": { + "description": "TasksList", + "schema": { + "$ref": "#/definitions/ActionTaskResponse" + } + }, "Team": { "description": "Team", "schema": { @@ -23341,6 +24827,15 @@ "$ref": "#/definitions/UserSettings" } }, + "VariableList": { + "description": "VariableList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ActionVariable" + } + } + }, "WatchInfo": { "description": "WatchInfo", "schema": { @@ -23416,7 +24911,7 @@ "parameterBodies": { "description": "parameterBodies", "schema": { - "$ref": "#/definitions/CreateOrUpdateSecretOption" + "$ref": "#/definitions/DispatchWorkflowOption" } }, "redirect": { -- cgit v1.2.3 From b2886d9c9e567e10362a68e5bf42d1cd8267d5ca Mon Sep 17 00:00:00 2001 From: Cyborus Date: Mon, 1 Jul 2024 13:03:00 -0400 Subject: fix: only wrap return values in `Option` once --- generator/src/methods.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/generator/src/methods.rs b/generator/src/methods.rs index 8039f96..93d5f57 100644 --- a/generator/src/methods.rs +++ b/generator/src/methods.rs @@ -555,14 +555,18 @@ impl ResponseType { fn merge(self, other: Self) -> eyre::Result { let headers = match (self.headers, other.headers) { (Some(a), Some(b)) if a != b => eyre::bail!("incompatible header types in response"), - (Some(a), None) => Some(format!("Option<{a}>")), - (None, Some(b)) => Some(format!("Option<{b}>")), + (Some(a), None) if !a.starts_with("Option<") => Some(format!("Option<{a}>")), + (None, Some(b)) if !b.starts_with("Option<") => Some(format!("Option<{b}>")), (a, b) => a.or(b), }; let body = match (self.body.as_deref(), other.body.as_deref()) { (Some(a), Some(b)) if a != b => eyre::bail!("incompatible header types in response"), - (Some(a), Some("()") | None) => Some(format!("Option<{a}>")), - (Some("()") | None, Some(b)) => Some(format!("Option<{b}>")), + (Some(a), Some("()") | None) if !a.starts_with("Option<") => { + Some(format!("Option<{a}>")) + } + (Some("()") | None, Some(b)) if !b.starts_with("Option<") => { + Some(format!("Option<{b}>")) + } (_, _) => self.body.or(other.body), }; use ResponseKind::*; -- cgit v1.2.3 From dd8f3da3576acca599a86b58630521eb59e18c3d Mon Sep 17 00:00:00 2001 From: Cyborus Date: Sun, 14 Jul 2024 11:55:28 -0400 Subject: fix(tests): add `hide_archive_links` to `CreateReleaseOption` --- tests/repo.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/repo.rs b/tests/repo.rs index c9d6894..f75c1c5 100644 --- a/tests/repo.rs +++ b/tests/repo.rs @@ -232,6 +232,7 @@ async fn release() { prerelease: Some(false), tag_name: "v1.0".into(), target_commitish: None, + hide_archive_links: None, }; let release = api .repo_create_release("TestingAdmin", "release-test", release_opt) @@ -244,6 +245,7 @@ async fn release() { prerelease: None, tag_name: None, target_commitish: None, + hide_archive_links: None, }; api.repo_edit_release( "TestingAdmin", -- cgit v1.2.3 From dc5d2ae9ad952e5b707b73c7cb008eb8d1571bc4 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Sun, 14 Jul 2024 14:06:11 -0400 Subject: test: tag protections --- tests/repo.rs | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/repo.rs b/tests/repo.rs index f75c1c5..a626b59 100644 --- a/tests/repo.rs +++ b/tests/repo.rs @@ -392,3 +392,57 @@ async fn team_pr_review_request() { .expect("couldn't get pr"); assert_eq!(pr.requested_reviewers, Some(Vec::new())); } + +#[tokio::test] +async fn tag_protection() { + let api = common::login(); + let git = Git::new("./test_repos/tag-protect"); + let _ = basic_repo(&api, &git, "tag-protect").await; + + let tag_protections = api + .repo_list_tag_protection("TestingAdmin", "tag-protect") + .await + .expect("failed to list tag protections"); + assert!(tag_protections.is_empty()); + + let protection_opt = CreateTagProtectionOption { + name_pattern: Some("v*".into()), + whitelist_teams: None, + whitelist_usernames: Some(vec!["TestingAdmin".into()]), + }; + let new_protection = api + .repo_create_tag_protection("TestingAdmin", "tag-protect", protection_opt) + .await + .expect("failed to create tag protection"); + let pattern = new_protection + .name_pattern + .as_deref() + .expect("protection does not have pattern"); + assert_eq!(pattern, "v*"); + let id = new_protection.id.expect("protection does not have id") as u32; + + let protection_get = api + .repo_get_tag_protection("TestingAdmin", "tag-protect", id) + .await + .expect("failed to get tag protection"); + assert_eq!(new_protection, protection_get); + + let edit_opt = EditTagProtectionOption { + name_pattern: Some("v*.*.*".into()), + whitelist_teams: None, + whitelist_usernames: Some(vec![]), + }; + let edited = api + .repo_edit_tag_protection("TestingAdmin", "tag-protect", id, edit_opt) + .await + .expect("failed to edit tag protection"); + let pattern = edited + .name_pattern + .as_deref() + .expect("protection does not have pattern"); + assert_eq!(pattern, "v*.*.*"); + + api.repo_delete_tag_protection("TestingAdmin", "tag-protect", id) + .await + .expect("failed to delete tag protection"); +} -- cgit v1.2.3 From 5c44d07cdb7918f19694be69803b9145acdc2988 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Sun, 14 Jul 2024 15:30:09 -0400 Subject: test: repo variables --- tests/repo.rs | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/repo.rs b/tests/repo.rs index a626b59..3a0377c 100644 --- a/tests/repo.rs +++ b/tests/repo.rs @@ -446,3 +446,50 @@ async fn tag_protection() { .await .expect("failed to delete tag protection"); } + +#[tokio::test] +async fn repo_vars() { + let api = common::login(); + let git = Git::new("./test_repos/repo-vars"); + let _ = basic_repo(&api, &git, "repo-vars").await; + + let query = GetRepoVariablesListQuery::default(); + let var_list = api + .get_repo_variables_list("TestingAdmin", "repo-vars", query) + .await + .expect("failed to list repo vars"); + assert!(var_list.is_empty()); + + let opt = CreateVariableOption { + value: "false".into(), + }; + api.create_repo_variable("TestingAdmin", "repo-vars", "very_cool", opt) + .await + .expect("failed to create repo var"); + + let new_var = api + .get_repo_variable("TestingAdmin", "repo-vars", "very_cool") + .await + .expect("failed to get repo var"); + assert_eq!(new_var.data.as_deref(), Some("false")); + + // wait, that's not right. you ARE very cool! + // gotta fix that + let opt = UpdateVariableOption { + name: Some("extremely_cool".into()), + value: "true".into(), + }; + api.update_repo_variable("TestingAdmin", "repo-vars", "very_cool", opt) + .await + .expect("failed to update repo variable"); + + let new_var = api + .get_repo_variable("TestingAdmin", "repo-vars", "extremely_cool") + .await + .expect("failed to get repo var"); + assert_eq!(new_var.data.as_deref(), Some("true")); + + api.delete_repo_variable("TestingAdmin", "repo-vars", "extremely_cool") + .await + .expect("failed to delete repo var"); +} -- cgit v1.2.3 From 40528973bec5cd4bf0a2a151f24f03b3679fc940 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Sun, 14 Jul 2024 16:33:58 -0400 Subject: chore: generate --- src/generated/methods.rs | 547 +++++++++++++++++++++++++++++++++++++++++++++++ src/generated/structs.rs | 318 ++++++++++++++++++++++++++- 2 files changed, 858 insertions(+), 7 deletions(-) diff --git a/src/generated/methods.rs b/src/generated/methods.rs index 7eeb1b0..b9657c5 100644 --- a/src/generated/methods.rs +++ b/src/generated/methods.rs @@ -3,6 +3,43 @@ use crate::ForgejoError; use std::collections::BTreeMap; impl crate::Forgejo { + /// Returns the Repository actor for a repo + /// + /// - `repository-id`: repository ID of the repo + pub async fn activitypub_repository( + &self, + repository_id: u32, + ) -> Result { + let request = self + .get(&format!("activitypub/repository-id/{repository_id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Send to the inbox + /// + /// - `repository-id`: repository ID of the repo + /// - `body`: See [`ForgeLike`] + pub async fn activitypub_repository_inbox( + &self, + repository_id: u32, + body: ForgeLike, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!("activitypub/repository-id/{repository_id}/inbox")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// Returns the Person actor for a user /// /// - `user-id`: user ID of the user @@ -749,6 +786,110 @@ impl crate::Forgejo { } } + /// Get an org-level variables list + /// + /// - `org`: name of the organization + pub async fn get_org_variables_list( + &self, + org: &str, + query: GetOrgVariablesListQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("orgs/{org}/actions/variables?{query}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get an org-level variable + /// + /// - `org`: name of the organization + /// - `variablename`: name of the variable + pub async fn get_org_variable( + &self, + org: &str, + variablename: &str, + ) -> Result { + let request = self + .get(&format!("orgs/{org}/actions/variables/{variablename}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update an org-level variable + /// + /// - `org`: name of the organization + /// - `variablename`: name of the variable + /// - `body`: See [`UpdateVariableOption`] + pub async fn update_org_variable( + &self, + org: &str, + variablename: &str, + body: UpdateVariableOption, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("orgs/{org}/actions/variables/{variablename}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(()), + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create an org-level variable + /// + /// - `org`: name of the organization + /// - `variablename`: name of the variable + /// - `body`: See [`CreateVariableOption`] + pub async fn create_org_variable( + &self, + org: &str, + variablename: &str, + body: CreateVariableOption, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!("orgs/{org}/actions/variables/{variablename}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(()), + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete an org-level variable + /// + /// - `org`: name of the organization + /// - `variablename`: name of the variable + pub async fn delete_org_variable( + &self, + org: &str, + variablename: &str, + ) -> Result, ForgejoError> { + let request = self + .delete(&format!("orgs/{org}/actions/variables/{variablename}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(Some(response.json().await?)), + 201 => Ok(None), + 204 => Ok(None), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// List an organization's activity feeds /// /// - `org`: name of the org @@ -1392,6 +1533,26 @@ impl crate::Forgejo { } } + /// List an repo's actions secrets + /// + /// - `owner`: owner of the repository + /// - `repo`: name of the repository + pub async fn repo_list_actions_secrets( + &self, + owner: &str, + repo: &str, + query: RepoListActionsSecretsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("repos/{owner}/{repo}/actions/secrets?{query}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// Create or Update a secret value in a repository /// /// - `owner`: owner of the repository @@ -1442,6 +1603,174 @@ impl crate::Forgejo { } } + /// List a repository's action tasks + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn list_action_tasks( + &self, + owner: &str, + repo: &str, + query: ListActionTasksQuery, + ) -> Result { + let request = self + .get(&format!("repos/{owner}/{repo}/actions/tasks?{query}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get repo-level variables list + /// + /// - `owner`: name of the owner + /// - `repo`: name of the repository + pub async fn get_repo_variables_list( + &self, + owner: &str, + repo: &str, + query: GetRepoVariablesListQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("repos/{owner}/{repo}/actions/variables?{query}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a repo-level variable + /// + /// - `owner`: name of the owner + /// - `repo`: name of the repository + /// - `variablename`: name of the variable + pub async fn get_repo_variable( + &self, + owner: &str, + repo: &str, + variablename: &str, + ) -> Result { + let request = self + .get(&format!( + "repos/{owner}/{repo}/actions/variables/{variablename}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a repo-level variable + /// + /// - `owner`: name of the owner + /// - `repo`: name of the repository + /// - `variablename`: name of the variable + /// - `body`: See [`UpdateVariableOption`] + pub async fn update_repo_variable( + &self, + owner: &str, + repo: &str, + variablename: &str, + body: UpdateVariableOption, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!( + "repos/{owner}/{repo}/actions/variables/{variablename}" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(()), + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a repo-level variable + /// + /// - `owner`: name of the owner + /// - `repo`: name of the repository + /// - `variablename`: name of the variable + /// - `body`: See [`CreateVariableOption`] + pub async fn create_repo_variable( + &self, + owner: &str, + repo: &str, + variablename: &str, + body: CreateVariableOption, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!( + "repos/{owner}/{repo}/actions/variables/{variablename}" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(()), + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a repo-level variable + /// + /// - `owner`: name of the owner + /// - `repo`: name of the repository + /// - `variablename`: name of the variable + pub async fn delete_repo_variable( + &self, + owner: &str, + repo: &str, + variablename: &str, + ) -> Result, ForgejoError> { + let request = self + .delete(&format!( + "repos/{owner}/{repo}/actions/variables/{variablename}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(Some(response.json().await?)), + 201 => Ok(None), + 204 => Ok(None), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Dispatches a workflow + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `workflowname`: name of the workflow + /// - `body`: See [`DispatchWorkflowOption`] + pub async fn dispatch_workflow( + &self, + owner: &str, + repo: &str, + workflowname: &str, + body: DispatchWorkflowOption, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!( + "repos/{owner}/{repo}/actions/workflows/{workflowname}/dispatches" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// List a repository's activity feeds /// /// - `owner`: owner of the repo @@ -1934,6 +2263,27 @@ impl crate::Forgejo { } } + /// Get commit comparison information + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `basehead`: compare two branches or commits + pub async fn repo_compare_diff( + &self, + owner: &str, + repo: &str, + basehead: &str, + ) -> Result { + let request = self + .get(&format!("repos/{owner}/{repo}/compare/{basehead}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// Gets the metadata of all the entries of the root dir /// /// - `owner`: owner of the repo @@ -5745,6 +6095,113 @@ impl crate::Forgejo { } } + /// List tag protections for a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_tag_protection( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("repos/{owner}/{repo}/tag_protections")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a tag protections for a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body`: See [`CreateTagProtectionOption`] + pub async fn repo_create_tag_protection( + &self, + owner: &str, + repo: &str, + body: CreateTagProtectionOption, + ) -> Result { + let request = self + .post(&format!("repos/{owner}/{repo}/tag_protections")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a specific tag protection for the repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the tag protect to get + pub async fn repo_get_tag_protection( + &self, + owner: &str, + repo: &str, + id: u32, + ) -> Result { + let request = self + .get(&format!("repos/{owner}/{repo}/tag_protections/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a specific tag protection for the repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of protected tag + pub async fn repo_delete_tag_protection( + &self, + owner: &str, + repo: &str, + id: u32, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("repos/{owner}/{repo}/tag_protections/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a tag protections for a repository. Only fields that are set will be changed + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of protected tag + /// - `body`: See [`EditTagProtectionOption`] + pub async fn repo_edit_tag_protection( + &self, + owner: &str, + repo: &str, + id: u32, + body: EditTagProtectionOption, + ) -> Result { + let request = self + .patch(&format!("repos/{owner}/{repo}/tag_protections/{id}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// List a repository's tags /// /// - `owner`: owner of the repo @@ -6592,6 +7049,96 @@ impl crate::Forgejo { } } + /// Get the user-level list of variables which is created by current doer + /// + pub async fn get_user_variables_list( + &self, + query: GetUserVariablesListQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("user/actions/variables?{query}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a user-level variable which is created by current doer + /// + /// - `variablename`: name of the variable + pub async fn get_user_variable( + &self, + variablename: &str, + ) -> Result { + let request = self + .get(&format!("user/actions/variables/{variablename}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a user-level variable which is created by current doer + /// + /// - `variablename`: name of the variable + /// - `body`: See [`UpdateVariableOption`] + pub async fn update_user_variable( + &self, + variablename: &str, + body: UpdateVariableOption, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("user/actions/variables/{variablename}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(()), + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a user-level variable + /// + /// - `variablename`: name of the variable + /// - `body`: See [`CreateVariableOption`] + pub async fn create_user_variable( + &self, + variablename: &str, + body: CreateVariableOption, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!("user/actions/variables/{variablename}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(()), + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a user-level variable which is created by current doer + /// + /// - `variablename`: name of the variable + pub async fn delete_user_variable(&self, variablename: &str) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("user/actions/variables/{variablename}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(()), + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// List the authenticated user's oauth2 applications /// pub async fn user_get_oauth2_applications( diff --git a/src/generated/structs.rs b/src/generated/structs.rs index b08b0ee..48d1326 100644 --- a/src/generated/structs.rs +++ b/src/generated/structs.rs @@ -17,6 +17,48 @@ pub struct AccessToken { pub token_last_eight: Option, } +/// ActionTask represents a ActionTask +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct ActionTask { + #[serde(with = "time::serde::rfc3339::option")] + pub created_at: Option, + pub display_title: Option, + pub event: Option, + pub head_branch: Option, + pub head_sha: Option, + pub id: Option, + pub name: Option, + pub run_number: Option, + #[serde(with = "time::serde::rfc3339::option")] + pub run_started_at: Option, + pub status: Option, + #[serde(with = "time::serde::rfc3339::option")] + pub updated_at: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + pub workflow_id: Option, +} + +/// ActionTaskResponse returns a ActionTask +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct ActionTaskResponse { + pub total_count: Option, + pub workflow_runs: Option>, +} + +/// ActionVariable return value of the query API +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct ActionVariable { + /// the value of the variable + pub data: Option, + /// the name of the variable + pub name: Option, + /// the owner to which the variable belongs + pub owner_id: Option, + /// the repository to which the variable belongs + pub repo_id: Option, +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Activity { pub act_user: Option, @@ -28,13 +70,73 @@ pub struct Activity { pub created: Option, pub id: Option, pub is_private: Option, - pub op_type: Option, + /// the type of action + pub op_type: Option, pub ref_name: Option, pub repo: Option, pub repo_id: Option, pub user_id: Option, } +/// the type of action + +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub enum ActivityOpType { + #[serde(rename = "create_repo")] + CreateRepo, + #[serde(rename = "rename_repo")] + RenameRepo, + #[serde(rename = "star_repo")] + StarRepo, + #[serde(rename = "watch_repo")] + WatchRepo, + #[serde(rename = "commit_repo")] + CommitRepo, + #[serde(rename = "create_issue")] + CreateIssue, + #[serde(rename = "create_pull_request")] + CreatePullRequest, + #[serde(rename = "transfer_repo")] + TransferRepo, + #[serde(rename = "push_tag")] + PushTag, + #[serde(rename = "comment_issue")] + CommentIssue, + #[serde(rename = "merge_pull_request")] + MergePullRequest, + #[serde(rename = "close_issue")] + CloseIssue, + #[serde(rename = "reopen_issue")] + ReopenIssue, + #[serde(rename = "close_pull_request")] + ClosePullRequest, + #[serde(rename = "reopen_pull_request")] + ReopenPullRequest, + #[serde(rename = "delete_tag")] + DeleteTag, + #[serde(rename = "delete_branch")] + DeleteBranch, + #[serde(rename = "mirror_sync_push")] + MirrorSyncPush, + #[serde(rename = "mirror_sync_create")] + MirrorSyncCreate, + #[serde(rename = "mirror_sync_delete")] + MirrorSyncDelete, + #[serde(rename = "approve_pull_request")] + ApprovePullRequest, + #[serde(rename = "reject_pull_request")] + RejectPullRequest, + #[serde(rename = "comment_pull")] + CommentPull, + #[serde(rename = "publish_release")] + PublishRelease, + #[serde(rename = "pull_review_dismissed")] + PullReviewDismissed, + #[serde(rename = "pull_request_ready_for_review")] + PullRequestReadyForReview, + #[serde(rename = "auto_merge_pull_request")] + AutoMergePullRequest, +} /// ActivityPub type #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ActivityPub { @@ -62,6 +164,7 @@ pub struct AddTimeOption { /// AnnotatedTag represents an annotated tag #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct AnnotatedTag { + pub archive_download_count: Option, pub message: Option, pub object: Option, pub sha: Option, @@ -331,6 +434,12 @@ pub struct CommitUser { pub name: Option, } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct Compare { + pub commits: Option>, + pub total_commits: Option, +} + /// ContentsResponse contains information about a repo's entry's (dir, file, symlink, submodule) metadata and content #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ContentsResponse { @@ -665,6 +774,7 @@ pub struct CreatePushMirrorOption { pub struct CreateReleaseOption { pub body: Option, pub draft: Option, + pub hide_archive_links: Option, pub name: Option, pub prerelease: Option, pub tag_name: String, @@ -730,6 +840,14 @@ pub struct CreateTagOption { pub target: Option, } +/// CreateTagProtectionOption options for creating a tag protection +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct CreateTagProtectionOption { + pub name_pattern: Option, + pub whitelist_teams: Option>, + pub whitelist_usernames: Option>, +} + /// CreateTeamOption options for creating a team #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CreateTeamOption { @@ -773,6 +891,13 @@ pub struct CreateUserOption { pub visibility: Option, } +/// CreateVariableOption the option when creating variable +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct CreateVariableOption { + /// Value of the variable to create + pub value: String, +} + /// CreateWikiPageOptions form for creating wiki #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CreateWikiPageOptions { @@ -866,6 +991,16 @@ pub struct DismissPullReviewOptions { pub priors: Option, } +/// DispatchWorkflowOption options when dispatching a workflow +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct DispatchWorkflowOption { + /// Input keys and values configured in the workflow file. + pub inputs: Option>, + /// Git reference for the workflow + #[serde(rename = "ref")] + pub r#ref: String, +} + /// EditAttachmentOptions options for editing attachments #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EditAttachmentOptions { @@ -1022,6 +1157,7 @@ pub struct EditReactionOption { pub struct EditReleaseOption { pub body: Option, pub draft: Option, + pub hide_archive_links: Option, pub name: Option, pub prerelease: Option, pub tag_name: Option, @@ -1058,10 +1194,12 @@ pub struct EditRepoOption { pub default_merge_style: Option, /// a short description of the repository. pub description: Option, - /// enable prune - remove obsolete remote-tracking references + /// enable prune - remove obsolete remote-tracking references when mirroring pub enable_prune: Option, pub external_tracker: Option, pub external_wiki: Option, + /// set the globally editable state of the wiki + pub globally_editable_wiki: Option, /// either `true` to enable actions unit, or `false` to disable them. pub has_actions: Option, /// either `true` to enable issues for this repository or `false` to disable them. @@ -1097,6 +1235,14 @@ pub struct EditRepoOption { pub wiki_branch: Option, } +/// EditTagProtectionOption options for editing a tag protection +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct EditTagProtectionOption { + pub name_pattern: Option, + pub whitelist_teams: Option>, + pub whitelist_usernames: Option>, +} + /// EditTeamOption options for editing a team #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EditTeamOption { @@ -1130,14 +1276,14 @@ pub struct EditUserOption { pub email: Option, pub full_name: Option, pub location: Option, - pub login_name: String, + pub login_name: Option, pub max_repo_creation: Option, pub must_change_password: Option, pub password: Option, pub prohibit_login: Option, pub pronouns: Option, pub restricted: Option, - pub source_id: i64, + pub source_id: Option, pub visibility: Option, pub website: Option, } @@ -1223,6 +1369,10 @@ pub struct FilesResponse { pub verification: Option, } +/// ForgeLike activity data type +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct ForgeLike {} + /// GPGKey a user GPG key to sign commit and tag in repository #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct GPGKey { @@ -1502,8 +1652,10 @@ pub struct IssueFormFieldVisible {} /// IssueLabelsOption a collection of labels #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct IssueLabelsOption { - /// list of label IDs - pub labels: Option>, + /// Labels can be a list of integers representing label IDs + /// + /// or a list of strings representing label names + pub labels: Option>, #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, } @@ -2002,18 +2154,22 @@ pub struct PublicKey { /// PullRequest represents a pull request #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct PullRequest { + pub additions: Option, pub allow_maintainer_edit: Option, pub assignee: Option, pub assignees: Option>, pub base: Option, pub body: Option, + pub changed_files: Option, #[serde(with = "time::serde::rfc3339::option")] pub closed_at: Option, pub comments: Option, #[serde(with = "time::serde::rfc3339::option")] pub created_at: Option, + pub deletions: Option, #[serde(deserialize_with = "crate::none_if_blank_url")] pub diff_url: Option, + pub draft: Option, #[serde(with = "time::serde::rfc3339::option")] pub due_date: Option, pub head: Option, @@ -2036,6 +2192,8 @@ pub struct PullRequest { pub pin_order: Option, #[serde(deserialize_with = "crate::requested_reviewers_ignore_null")] pub requested_reviewers: Option>, + /// number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR) + pub review_comments: Option, pub state: Option, pub title: Option, #[serde(with = "time::serde::rfc3339::option")] @@ -2049,6 +2207,8 @@ pub struct PullRequest { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct PullRequestMeta { pub draft: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, pub merged: Option, #[serde(with = "time::serde::rfc3339::option")] pub merged_at: Option, @@ -2144,12 +2304,14 @@ pub struct Reference { /// Release represents a repository release #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Release { + pub archive_download_count: Option, pub assets: Option>, pub author: Option, pub body: Option, #[serde(with = "time::serde::rfc3339::option")] pub created_at: Option, pub draft: Option, + pub hide_archive_links: Option, #[serde(deserialize_with = "crate::none_if_blank_url")] pub html_url: Option, pub id: Option, @@ -2245,6 +2407,7 @@ pub struct Repository { pub fork: Option, pub forks_count: Option, pub full_name: Option, + pub globally_editable_wiki: Option, pub has_actions: Option, pub has_issues: Option, pub has_packages: Option, @@ -2283,6 +2446,7 @@ pub struct Repository { pub ssh_url: Option, pub stars_count: Option, pub template: Option, + pub topics: Option>, #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, #[serde(deserialize_with = "crate::none_if_blank_url")] @@ -2359,6 +2523,7 @@ pub struct SubmitPullReviewOptions { /// Tag represents a repository tag #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Tag { + pub archive_download_count: Option, pub commit: Option, pub id: Option, pub message: Option, @@ -2369,6 +2534,26 @@ pub struct Tag { pub zipball_url: Option, } +/// TagArchiveDownloadCount counts how many times a archive was downloaded +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct TagArchiveDownloadCount { + pub tar_gz: Option, + pub zip: Option, +} + +/// TagProtection represents a tag protection +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct TagProtection { + #[serde(with = "time::serde::rfc3339::option")] + pub created_at: Option, + pub id: Option, + pub name_pattern: Option, + #[serde(with = "time::serde::rfc3339::option")] + pub updated_at: Option, + pub whitelist_teams: Option>, + pub whitelist_usernames: Option>, +} + /// Team represents a team in an organization #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Team { @@ -2522,6 +2707,15 @@ pub struct UpdateUserAvatarOption { pub image: Option, } +/// UpdateVariableOption the option when updating variable +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct UpdateVariableOption { + /// New name for the variable. If the field is empty, the variable name won't be updated. + pub name: Option, + /// Value of the variable to update + pub value: String, +} + /// User represents a user #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct User { @@ -2540,6 +2734,9 @@ pub struct User { pub following_count: Option, /// the user's full name pub full_name: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + /// URL to the user's gitea page + pub html_url: Option, /// the user's id pub id: Option, /// Is the user an administrator @@ -2560,6 +2757,8 @@ pub struct User { pub pronouns: Option, /// Is user restricted pub restricted: Option, + /// The ID of the user's Authentication Source + pub source_id: Option, pub starred_repos_count: Option, /// User visibility level option: public, limited, private pub visibility: Option, @@ -3322,6 +3521,27 @@ impl std::fmt::Display for OrgListActionsSecretsQuery { } } +#[derive(Debug, Clone, PartialEq, Default)] +pub struct GetOrgVariablesListQuery { + /// page number of results to return (1-based) + pub page: Option, + /// page size of results + pub limit: Option, +} + +impl std::fmt::Display for GetOrgVariablesListQuery { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if let Some(page) = &self.page { + write!(f, "page={page}&")?; + } + if let Some(limit) = &self.limit { + write!(f, "limit={limit}&")?; + } + + Ok(()) + } +} + #[derive(Debug, Clone, PartialEq, Default)] pub struct OrgListActivityFeedsQuery { /// the date of the activities to be found @@ -3777,7 +3997,7 @@ pub struct RepoSearchQuery { pub mode: Option, /// if `uid` is given, search only for repos that the user owns pub exclusive: Option, - /// sort repos by attribute. Supported values are "alpha", "created", "updated", "size", and "id". Default is "alpha" + /// sort repos by attribute. Supported values are "alpha", "created", "updated", "size", "git_size", "lfs_size", "stars", "forks" and "id". Default is "alpha" pub sort: Option, /// sort order, either "asc" (ascending) or "desc" (descending). Default is "asc", ignored if "sort" is not specified. pub order: Option, @@ -3845,6 +4065,69 @@ impl std::fmt::Display for RepoSearchQuery { } } +#[derive(Debug, Clone, PartialEq, Default)] +pub struct RepoListActionsSecretsQuery { + /// page number of results to return (1-based) + pub page: Option, + /// page size of results + pub limit: Option, +} + +impl std::fmt::Display for RepoListActionsSecretsQuery { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if let Some(page) = &self.page { + write!(f, "page={page}&")?; + } + if let Some(limit) = &self.limit { + write!(f, "limit={limit}&")?; + } + + Ok(()) + } +} + +#[derive(Debug, Clone, PartialEq, Default)] +pub struct ListActionTasksQuery { + /// page number of results to return (1-based) + pub page: Option, + /// page size of results, default maximum page size is 50 + pub limit: Option, +} + +impl std::fmt::Display for ListActionTasksQuery { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if let Some(page) = &self.page { + write!(f, "page={page}&")?; + } + if let Some(limit) = &self.limit { + write!(f, "limit={limit}&")?; + } + + Ok(()) + } +} + +#[derive(Debug, Clone, PartialEq, Default)] +pub struct GetRepoVariablesListQuery { + /// page number of results to return (1-based) + pub page: Option, + /// page size of results + pub limit: Option, +} + +impl std::fmt::Display for GetRepoVariablesListQuery { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if let Some(page) = &self.page { + write!(f, "page={page}&")?; + } + if let Some(limit) = &self.limit { + write!(f, "limit={limit}&")?; + } + + Ok(()) + } +} + #[derive(Debug, Clone, PartialEq, Default)] pub struct RepoListActivityFeedsQuery { /// the date of the activities to be found @@ -5592,6 +5875,27 @@ impl std::fmt::Display for TopicSearchQuery { } } +#[derive(Debug, Clone, PartialEq, Default)] +pub struct GetUserVariablesListQuery { + /// page number of results to return (1-based) + pub page: Option, + /// page size of results + pub limit: Option, +} + +impl std::fmt::Display for GetUserVariablesListQuery { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if let Some(page) = &self.page { + write!(f, "page={page}&")?; + } + if let Some(limit) = &self.limit { + write!(f, "limit={limit}&")?; + } + + Ok(()) + } +} + #[derive(Debug, Clone, PartialEq, Default)] pub struct UserGetOAuth2ApplicationsQuery { /// page number of results to return (1-based) -- cgit v1.2.3 From 19ba6897d10aba91642ae28aacd88980ed16e3cb Mon Sep 17 00:00:00 2001 From: Cyborus Date: Mon, 15 Jul 2024 12:14:53 -0400 Subject: test: org variables --- tests/organization.rs | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/organization.rs diff --git a/tests/organization.rs b/tests/organization.rs new file mode 100644 index 0000000..c5ced99 --- /dev/null +++ b/tests/organization.rs @@ -0,0 +1,58 @@ +use forgejo_api::structs::*; + +mod common; + +#[tokio::test] +async fn org_vars() { + let api = common::login(); + let org_opt = CreateOrgOption { + description: Some("Testing organization variables".into()), + email: None, + full_name: Some("Org Variables".into()), + location: Some("The Lab".into()), + repo_admin_change_team_access: None, + username: "org-vars".into(), + visibility: None, + website: None, + }; + api.org_create(org_opt).await.expect("failed to create org"); + + let query = GetOrgVariablesListQuery::default(); + let var_list = api + .get_org_variables_list("org-vars", query) + .await + .expect("failed to list org vars"); + assert!(var_list.is_empty()); + + let opt = CreateVariableOption { + value: "false".into(), + }; + api.create_org_variable("org-vars", "want_pizza", opt) + .await + .expect("failed to create org var"); + + let new_var = api + .get_org_variable("org-vars", "want_pizza") + .await + .expect("failed to get org var"); + assert_eq!(new_var.data.as_deref(), Some("false")); + + // no no no we definitely do want pizza + let opt = UpdateVariableOption { + name: Some("really_want_pizza".into()), + value: "true".into(), + }; + api.update_org_variable("org-vars", "want_pizza", opt) + .await + .expect("failed to update org variable"); + + let new_var = api + .get_org_variable("org-vars", "really_want_pizza") + .await + .expect("failed to get org var"); + assert_eq!(new_var.data.as_deref(), Some("true")); + + api.delete_org_variable("org-vars", "really_want_pizza") + .await + .expect("failed to delete org var"); +} -- cgit v1.2.3 From 5d9e84b579b8abc2e16acf32dbb2c468968574ed Mon Sep 17 00:00:00 2001 From: Cyborus Date: Mon, 15 Jul 2024 12:21:21 -0400 Subject: test: user vars --- tests/user.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/user.rs b/tests/user.rs index 9ca808d..3b6e0e3 100644 --- a/tests/user.rs +++ b/tests/user.rs @@ -191,3 +191,47 @@ async fn oauth2_login() { let myself = token_api.user_get_current().await.unwrap(); assert_eq!(myself.login.as_deref(), Some("TestingAdmin")); } + +#[tokio::test] +async fn user_vars() { + let api = common::login(); + + let query = GetUserVariablesListQuery::default(); + let var_list = api + .get_user_variables_list(query) + .await + .expect("failed to list user vars"); + assert!(var_list.is_empty()); + + let opt = CreateVariableOption { + value: "false".into(), + }; + api.create_user_variable("likes_dogs", opt) + .await + .expect("failed to create user var"); + + let new_var = api + .get_user_variable("likes_dogs") + .await + .expect("failed to get user var"); + assert_eq!(new_var.data.as_deref(), Some("false")); + + // what??? totally wrong. I love dogs! + let opt = UpdateVariableOption { + name: Some("loves_dogs".into()), + value: "true".into(), + }; + api.update_user_variable("likes_dogs", opt) + .await + .expect("failed to update user variable"); + + let new_var = api + .get_user_variable("loves_dogs") + .await + .expect("failed to get user var"); + assert_eq!(new_var.data.as_deref(), Some("true")); + + api.delete_user_variable("loves_dogs") + .await + .expect("failed to delete user var"); +} -- cgit v1.2.3 From d298d20a32a1aa0bf25110b13e54c9b43f69dafc Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 30 Jul 2024 13:21:51 -0400 Subject: ci: use forgejo 8 --- .woodpecker/integration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.woodpecker/integration.yml b/.woodpecker/integration.yml index 5ace7f7..d8c3695 100644 --- a/.woodpecker/integration.yml +++ b/.woodpecker/integration.yml @@ -5,10 +5,10 @@ steps: image: rust environment: - "FORGEJO_API_CI_INSTANCE_URL=http://forgejo-testing:3000/" - - FORGEJO_API_CI_TOKEN=3906093e3d85cf0402623eb4a5287bc0f828e820 + - FORGEJO_API_CI_TOKEN=52dffd1ab4cc935087bc71a557b2f777ec1cc969 commands: - cargo test services: forgejo-testing: - image: code.cartoon-aa.xyz/cyborus/ci-forgejo:7.0.1 + image: code.cartoon-aa.xyz/cyborus/ci-forgejo:8.0.0 -- cgit v1.2.3 From f20fc5c4f1d17477771c1dc494b3b8a88f90c33b Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 30 Jul 2024 13:32:35 -0400 Subject: ci: pull `ci-forgejo` always --- .woodpecker/integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker/integration.yml b/.woodpecker/integration.yml index d8c3695..e09710c 100644 --- a/.woodpecker/integration.yml +++ b/.woodpecker/integration.yml @@ -11,4 +11,5 @@ steps: services: forgejo-testing: + pull: true image: code.cartoon-aa.xyz/cyborus/ci-forgejo:8.0.0 -- cgit v1.2.3 From e46a406ff181235521b87dc60bb47ceb39cf99e9 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 30 Jul 2024 13:33:41 -0400 Subject: ci: update token --- .woodpecker/integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/integration.yml b/.woodpecker/integration.yml index e09710c..8dd4e3e 100644 --- a/.woodpecker/integration.yml +++ b/.woodpecker/integration.yml @@ -5,7 +5,7 @@ steps: image: rust environment: - "FORGEJO_API_CI_INSTANCE_URL=http://forgejo-testing:3000/" - - FORGEJO_API_CI_TOKEN=52dffd1ab4cc935087bc71a557b2f777ec1cc969 + - FORGEJO_API_CI_TOKEN=e4f301dffd4993a3389f601761c0103291e58d85 commands: - cargo test -- cgit v1.2.3