From b9ba6e60d15dd061576a51ae9299613182d12e6b Mon Sep 17 00:00:00 2001 From: Cyborus Date: Wed, 10 Jan 2024 22:09:06 -0500 Subject: [PATCH 01/86] add openapi parsing --- Cargo.lock | 54 +- Cargo.toml | 1 + generator/Cargo.toml | 12 + generator/src/main.rs | 17 + generator/src/openapi.rs | 338 + swagger.v1.json | 24321 +++++++++++++++++++++++++++++++++++++ 6 files changed, 24721 insertions(+), 22 deletions(-) create mode 100644 generator/Cargo.toml create mode 100644 generator/src/main.rs create mode 100644 generator/src/openapi.rs create mode 100644 swagger.v1.json diff --git a/Cargo.lock b/Cargo.lock index 7360368..47254d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,9 +136,9 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f656be11ddf91bd709454d15d5bd896fbaf4cc3314e69349e4d1569f5b46cd" +checksum = "b6267a1fa6f59179ea4afc8e50fd8612a3cc60bc858f786ff877a4a8cb042799" dependencies = [ "indenter", "once_cell", @@ -191,9 +191,9 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -237,6 +237,16 @@ dependencies = [ "pin-utils", ] +[[package]] +name = "generator" +version = "0.1.0" +dependencies = [ + "eyre", + "serde", + "serde_json", + "url", +] + [[package]] name = "gimli" version = "0.28.0" @@ -341,9 +351,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -531,9 +541,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" @@ -561,18 +571,18 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -684,18 +694,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.192" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", @@ -704,9 +714,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -762,9 +772,9 @@ checksum = "b5097ec7ea7218135541ad96348f1441d0c616537dd4ed9c47205920c35d7d97" [[package]] name = "syn" -version = "2.0.39" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -983,9 +993,9 @@ dependencies = [ [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", diff --git a/Cargo.toml b/Cargo.toml index c53d74d..7590571 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,4 @@ +workspace = { members = ["generator"] } [package] name = "forgejo-api" version = "0.1.0" diff --git a/generator/Cargo.toml b/generator/Cargo.toml new file mode 100644 index 0000000..91f832e --- /dev/null +++ b/generator/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "generator" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +eyre = "0.6.11" +serde = { version = "1.0.195", features = ["derive"] } +serde_json = "1.0.111" +url = { version = "2.5.0", features = ["serde"] } diff --git a/generator/src/main.rs b/generator/src/main.rs new file mode 100644 index 0000000..3d5900c --- /dev/null +++ b/generator/src/main.rs @@ -0,0 +1,17 @@ +use std::ffi::OsString; + +mod openapi; + +fn main() -> eyre::Result<()> { + let spec = get_spec()?; + dbg!(spec); + Ok(()) +} + +fn get_spec() -> eyre::Result { + let path = std::env::var_os("FORGEJO_API_SPEC_PATH") + .unwrap_or_else(|| OsString::from("./api_spec.json")); + let file = std::fs::read(path)?; + let spec = serde_json::from_slice::(&file)?; + Ok(spec) +} diff --git a/generator/src/openapi.rs b/generator/src/openapi.rs new file mode 100644 index 0000000..effe561 --- /dev/null +++ b/generator/src/openapi.rs @@ -0,0 +1,338 @@ +use std::collections::BTreeMap; + +use url::Url; + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct OpenApiV2 { + pub swagger: String, + pub info: SpecInfo, + pub host: Option, + pub base_path: Option, + pub schemes: Option>, + pub consumes: Option>, + pub produces: Option>, + pub paths: BTreeMap, + pub definitions: Option>, + pub parameters: Option>, + pub responses: Option>, + pub security_definitions: Option>, + pub security: Option>>>, + pub tags: Option>, + pub external_docs: Option, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct SpecInfo { + pub title: String, + pub description: Option, + pub terms_of_service: Option, + pub contact: Option, + pub license: Option, + pub version: String, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct Contact { + pub name: Option, + pub url: Option, + pub email: Option, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct License { + pub name: String, + pub url: Option, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct PathItem { + #[serde(rename = "$ref")] + pub _ref: Option, + pub get: Option, + pub put: Option, + pub post: Option, + pub delete: Option, + pub options: Option, + pub head: Option, + pub patch: Option, + pub parameters: Option>>, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct Operation { + pub tags: Option>, + pub summary: Option, + pub description: Option, + pub external_docs: Option, + pub operation_id: Option, + pub consumes: Option>, + pub produces: Option>, + pub parameters: Option>>, + pub responses: Responses, + pub schemes: Option>, + pub deprecated: Option, + pub security: Option>>>, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct ExternalDocs { + pub description: Option, + pub url: Url, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct Parameter { + pub name: String, + #[serde(rename = "in")] + pub _in: String, + pub description: Option, + pub required: Option, + pub schema: Option>, + #[serde(rename = "type")] + pub _type: Option, + pub format: Option, + pub allow_empty_value: Option, + pub items: Option, + pub collection_format: Option, + pub default: Option, + pub maximum: Option, + pub exclusive_maximum: Option, + pub minimum: Option, + pub exclusive_minimum: Option, + pub max_length: Option, + pub min_length: Option, + pub pattern: Option, // should be regex + pub max_items: Option, + pub min_items: Option, + pub unique_items: Option, + #[serde(rename = "enum")] + pub _enum: Option>, + pub multiple_of: Option, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub enum ParameterType { + String, + Number, + Integer, + Boolean, + Array, + File, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub enum CollectionFormat { + Csv, + Ssv, + Tsv, + Pipes, + Multi, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct Items { + #[serde(rename = "type")] + pub _type: ParameterType, + pub format: Option, + pub items: Option>, + pub collection_format: Option, + pub default: Option, + pub maximum: Option, + pub exclusive_maximum: Option, + pub minimum: Option, + pub exclusive_minimum: Option, + pub max_length: Option, + pub min_length: Option, + pub pattern: Option, // should be regex + pub max_items: Option, + pub min_items: Option, + pub unique_items: Option, + #[serde(rename = "enum")] + pub _enum: Option>, + pub multiple_of: Option, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct Responses { + pub default: Option>, + #[serde(flatten)] + pub http_codes: BTreeMap>, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct Response { + pub description: String, + pub schema: Option, + pub headers: Option>, + pub examples: Option>, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct Header { + pub description: Option, + #[serde(rename = "type")] + pub _type: ParameterType, + pub format: Option, + pub items: Option, + pub collection_format: Option, + pub default: Option, + pub maximum: Option, + pub exclusive_maximum: Option, + pub minimum: Option, + pub exclusive_minimum: Option, + pub max_length: Option, + pub min_length: Option, + pub pattern: Option, // should be regex + pub max_items: Option, + pub min_items: Option, + pub unique_items: Option, + #[serde(rename = "enum")] + pub _enum: Option>, + pub multiple_of: Option, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct Tag { + pub name: String, + pub description: Option, + pub external_docs: Option, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct Schema { + pub format: Option, + pub title: Option, + pub description: Option, + pub default: Option, + pub multiple_of: Option, + pub maximum: Option, + pub exclusive_maximum: Option, + pub minimum: Option, + pub exclusive_minimum: Option, + pub max_length: Option, + pub min_length: Option, + pub pattern: Option, // should be regex + pub max_items: Option, + pub min_items: Option, + pub unique_items: Option, + pub max_properties: Option, + pub min_properties: Option, + pub required: Option>, + #[serde(rename = "enum")] + pub _enum: Option>, + #[serde(rename = "type")] + pub _type: Option, + + pub discriminator: Option, + pub read_only: Option, + pub xml: Option, + pub external_docs: Option, + pub example: Option, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(untagged)] +pub enum SchemaType { + One(Primitive), + List(Vec), +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub enum Primitive { + Array, + Boolean, + Integer, + Number, + Null, + Object, + String, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct Xml { + pub name: Option, + pub namespace: Option, + pub prefix: Option, + pub attribute: Option, + pub wrapped: Option, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub struct SecurityScheme { + #[serde(flatten)] + pub _type: SecurityType, + pub description: Option, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"), tag = "type")] +pub enum SecurityType { + Basic, + ApiKey { + name: String, + #[serde(rename = "in")] + _in: KeyIn, + }, + OAuth2 { + #[serde(flatten)] + flow: OAuth2Flow, + scopes: BTreeMap, + } +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub enum KeyIn { + Query, + Header, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"), tag = "flow")] +pub enum OAuth2Flow { + Implicit { + authorization_url: Url, + }, + Password{ + token_url: Url, + }, + Application{ + token_url: Url, + }, + AccessCode{ + authorization_url: Url, + token_url: Url, + }, +} + +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(untagged)] +pub enum MaybeRef { + Value { + #[serde(flatten)] + value: T, + }, + Ref { + #[serde(rename = "$ref")] + _ref: String, + } +} diff --git a/swagger.v1.json b/swagger.v1.json new file mode 100644 index 0000000..c3be7d6 --- /dev/null +++ b/swagger.v1.json @@ -0,0 +1,24321 @@ +{ + "consumes": [ + "application/json", + "text/plain" + ], + "produces": [ + "application/json", + "text/html" + ], + "schemes": [ + "http", + "https" + ], + "swagger": "2.0", + "info": { + "description": "This documentation describes the Forgejo API.", + "title": "Forgejo API", + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.21.2+1-73-gfedce17" + }, + "basePath": "/api/v1", + "paths": { + "/activitypub/user-id/{user-id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "activitypub" + ], + "summary": "Returns the Person actor for a user", + "operationId": "activitypubPerson", + "parameters": [ + { + "type": "integer", + "description": "user ID of the user", + "name": "user-id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/ActivityPub" + } + } + } + }, + "/activitypub/user-id/{user-id}/inbox": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "activitypub" + ], + "summary": "Send to the inbox", + "operationId": "activitypubPersonInbox", + "parameters": [ + { + "type": "integer", + "description": "user ID of the user", + "name": "user-id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, + "/admin/cron": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "List cron tasks", + "operationId": "adminCronList", + "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/CronList" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, + "/admin/cron/{task}": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Run cron task", + "operationId": "adminCronRun", + "parameters": [ + { + "type": "string", + "description": "task to run", + "name": "task", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/admin/emails": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "List all emails", + "operationId": "adminGetAllEmails", + "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/EmailList" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, + "/admin/emails/search": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Search all emails", + "operationId": "adminSearchEmails", + "parameters": [ + { + "type": "string", + "description": "keyword", + "name": "q", + "in": "query" + }, + { + "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/EmailList" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, + "/admin/hooks": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "List system's webhooks", + "operationId": "adminListHooks", + "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/HookList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Create a hook", + "operationId": "adminCreateHook", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateHookOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Hook" + } + } + } + }, + "/admin/hooks/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Get a hook", + "operationId": "adminGetHook", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the hook to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Hook" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Delete a hook", + "operationId": "adminDeleteHook", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the hook to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Update a hook", + "operationId": "adminEditHook", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the hook to update", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditHookOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Hook" + } + } + } + }, + "/admin/orgs": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "List all organizations", + "operationId": "adminGetAllOrgs", + "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/OrganizationList" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, + "/admin/unadopted": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "List unadopted repositories", + "operationId": "adminUnadoptedList", + "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" + }, + { + "type": "string", + "description": "pattern of repositories to search for", + "name": "pattern", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/StringSlice" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, + "/admin/unadopted/{owner}/{repo}": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Adopt unadopted files as a repository", + "operationId": "adminAdoptRepository", + "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" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Delete unadopted files", + "operationId": "adminDeleteUnadoptedRepository", + "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" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, + "/admin/users": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Search users according filter conditions", + "operationId": "adminSearchUsers", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "ID of the user's login source to search for", + "name": "source_id", + "in": "query" + }, + { + "type": "string", + "description": "user's login name to search for", + "name": "login_name", + "in": "query" + }, + { + "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/UserList" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Create a user", + "operationId": "adminCreateUser", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateUserOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/User" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/admin/users/{username}": { + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Delete a user", + "operationId": "adminDeleteUser", + "parameters": [ + { + "type": "string", + "description": "username of user to delete", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "purge the user from the system completely", + "name": "purge", + "in": "query" + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Edit an existing user", + "operationId": "adminEditUser", + "parameters": [ + { + "type": "string", + "description": "username of user to edit", + "name": "username", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditUserOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/User" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/admin/users/{username}/keys": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Add a public key on behalf of a user", + "operationId": "adminCreatePublicKey", + "parameters": [ + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + }, + { + "name": "key", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateKeyOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/PublicKey" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/admin/users/{username}/keys/{id}": { + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Delete a user's public key", + "operationId": "adminDeleteUserPublicKey", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the key to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/admin/users/{username}/orgs": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Create an organization", + "operationId": "adminCreateOrg", + "parameters": [ + { + "type": "string", + "description": "username of the user that will own the created organization", + "name": "username", + "in": "path", + "required": true + }, + { + "name": "organization", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateOrgOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Organization" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/admin/users/{username}/rename": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Rename a user", + "operationId": "adminRenameUser", + "parameters": [ + { + "type": "string", + "description": "existing username of user", + "name": "username", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RenameUserOption" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/admin/users/{username}/repos": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Create a repository on behalf of a user", + "operationId": "adminCreateRepo", + "parameters": [ + { + "type": "string", + "description": "username of the user. This user will own the created repository", + "name": "username", + "in": "path", + "required": true + }, + { + "name": "repository", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateRepoOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Repository" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "$ref": "#/responses/error" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/gitignore/templates": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Returns a list of all gitignore templates", + "operationId": "listGitignoresTemplates", + "responses": { + "200": { + "$ref": "#/responses/GitignoreTemplateList" + } + } + } + }, + "/gitignore/templates/{name}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Returns information about a gitignore template", + "operationId": "getGitignoreTemplateInfo", + "parameters": [ + { + "type": "string", + "description": "name of the template", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/GitignoreTemplateInfo" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/label/templates": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Returns a list of all label templates", + "operationId": "listLabelTemplates", + "responses": { + "200": { + "$ref": "#/responses/LabelTemplateList" + } + } + } + }, + "/label/templates/{name}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Returns all labels in a template", + "operationId": "getLabelTemplateInfo", + "parameters": [ + { + "type": "string", + "description": "name of the template", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/LabelTemplateInfo" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/licenses": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Returns a list of all license templates", + "operationId": "listLicenseTemplates", + "responses": { + "200": { + "$ref": "#/responses/LicenseTemplateList" + } + } + } + }, + "/licenses/{name}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Returns information about a license template", + "operationId": "getLicenseTemplateInfo", + "parameters": [ + { + "type": "string", + "description": "name of the license", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/LicenseTemplateInfo" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/markdown": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "text/html" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Render a markdown document as HTML", + "operationId": "renderMarkdown", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/MarkdownOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/MarkdownRender" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/markdown/raw": { + "post": { + "consumes": [ + "text/plain" + ], + "produces": [ + "text/html" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Render raw markdown as HTML", + "operationId": "renderMarkdownRaw", + "parameters": [ + { + "description": "Request body to render", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/MarkdownRender" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/markup": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "text/html" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Render a markup document as HTML", + "operationId": "renderMarkup", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/MarkupOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/MarkupRender" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/nodeinfo": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Returns the nodeinfo of the Gitea application", + "operationId": "getNodeInfo", + "responses": { + "200": { + "$ref": "#/responses/NodeInfo" + } + } + } + }, + "/notifications": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notification" + ], + "summary": "List users's notification threads", + "operationId": "notifyGetList", + "parameters": [ + { + "type": "boolean", + "description": "If true, show notifications marked as read. Default value is false", + "name": "all", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "Show notifications with the provided status types. Options are: unread, read and/or pinned. Defaults to unread \u0026 pinned.", + "name": "status-types", + "in": "query" + }, + { + "type": "array", + "items": { + "enum": [ + "issue", + "pull", + "commit", + "repository" + ], + "type": "string" + }, + "collectionFormat": "multi", + "description": "filter notifications by subject type", + "name": "subject-type", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show notifications updated after the given time. This is a timestamp in RFC 3339 format", + "name": "since", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show notifications updated before the given time. This is a timestamp in RFC 3339 format", + "name": "before", + "in": "query" + }, + { + "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/NotificationThreadList" + } + } + }, + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notification" + ], + "summary": "Mark notification threads as read, pinned or unread", + "operationId": "notifyReadList", + "parameters": [ + { + "type": "string", + "format": "date-time", + "description": "Describes the last point that notifications were checked. Anything updated since this time will not be updated.", + "name": "last_read_at", + "in": "query" + }, + { + "type": "string", + "description": "If true, mark all notifications on this repo. Default value is false", + "name": "all", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "Mark notifications with the provided status types. Options are: unread, read and/or pinned. Defaults to unread.", + "name": "status-types", + "in": "query" + }, + { + "type": "string", + "description": "Status to mark notifications as, Defaults to read.", + "name": "to-status", + "in": "query" + } + ], + "responses": { + "205": { + "$ref": "#/responses/NotificationThreadList" + } + } + } + }, + "/notifications/new": { + "get": { + "tags": [ + "notification" + ], + "summary": "Check if unread notifications exist", + "operationId": "notifyNewAvailable", + "responses": { + "200": { + "$ref": "#/responses/NotificationCount" + } + } + } + }, + "/notifications/threads/{id}": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notification" + ], + "summary": "Get notification thread by ID", + "operationId": "notifyGetThread", + "parameters": [ + { + "type": "string", + "description": "id of notification thread", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/NotificationThread" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notification" + ], + "summary": "Mark notification thread as read by ID", + "operationId": "notifyReadThread", + "parameters": [ + { + "type": "string", + "description": "id of notification thread", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "default": "read", + "description": "Status to mark notifications as", + "name": "to-status", + "in": "query" + } + ], + "responses": { + "205": { + "$ref": "#/responses/NotificationThread" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/org/{org}/repos": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Create a repository in an organization", + "operationId": "createOrgRepoDeprecated", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "name of organization", + "name": "org", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateRepoOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Repository" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/orgs": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Get list of organizations", + "operationId": "orgGetAll", + "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/OrganizationList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Create an organization", + "operationId": "orgCreate", + "parameters": [ + { + "name": "organization", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateOrgOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Organization" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/orgs/{org}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Get an organization", + "operationId": "orgGet", + "parameters": [ + { + "type": "string", + "description": "name of the organization to get", + "name": "org", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Organization" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Delete an organization", + "operationId": "orgDelete", + "parameters": [ + { + "type": "string", + "description": "organization that is to be deleted", + "name": "org", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Edit an organization", + "operationId": "orgEdit", + "parameters": [ + { + "type": "string", + "description": "name of the organization to edit", + "name": "org", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/EditOrgOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Organization" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/actions/secrets": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List an organization's actions secrets", + "operationId": "orgListActionsSecrets", + "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/SecretList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/actions/secrets/{secretname}": { + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Create or Update a secret value in an organization", + "operationId": "updateOrgSecret", + "parameters": [ + { + "type": "string", + "description": "name of organization", + "name": "org", + "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": [ + "organization" + ], + "summary": "Delete a secret in an organization", + "operationId": "deleteOrgSecret", + "parameters": [ + { + "type": "string", + "description": "name of organization", + "name": "org", + "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" + } + } + } + }, + "/orgs/{org}/activities/feeds": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List an organization's activity feeds", + "operationId": "orgListActivityFeeds", + "parameters": [ + { + "type": "string", + "description": "name of the org", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "date", + "description": "the date of the activities to be found", + "name": "date", + "in": "query" + }, + { + "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/ActivityFeedsList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/avatar": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Update Avatar", + "operationId": "orgUpdateAvatar", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/UpdateUserAvatarOption" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Delete Avatar", + "operationId": "orgDeleteAvatar", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/block/{username}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Blocks a user from the organization", + "operationId": "orgBlockUser", + "parameters": [ + { + "type": "string", + "description": "name of the org", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/orgs/{org}/hooks": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List an organization's webhooks", + "operationId": "orgListHooks", + "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/HookList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Create a hook", + "operationId": "orgCreateHook", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateHookOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Hook" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/hooks/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Get a hook", + "operationId": "orgGetHook", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the hook to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Hook" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Delete a hook", + "operationId": "orgDeleteHook", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the hook to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Update a hook", + "operationId": "orgEditHook", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the hook to update", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditHookOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Hook" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/labels": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List an organization's labels", + "operationId": "orgListLabels", + "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/LabelList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Create a label for an organization", + "operationId": "orgCreateLabel", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateLabelOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Label" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/orgs/{org}/labels/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Get a single label", + "operationId": "orgGetLabel", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the label to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Label" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "organization" + ], + "summary": "Delete a label", + "operationId": "orgDeleteLabel", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the label to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Update a label", + "operationId": "orgEditLabel", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the label to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditLabelOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Label" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/orgs/{org}/list_blocked": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List the organization's blocked users", + "operationId": "orgListBlockedUsers", + "parameters": [ + { + "type": "string", + "description": "name of the org", + "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/BlockedUserList" + } + } + } + }, + "/orgs/{org}/members": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List an organization's members", + "operationId": "orgListMembers", + "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/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/members/{username}": { + "get": { + "tags": [ + "organization" + ], + "summary": "Check if a user is a member of an organization", + "operationId": "orgIsMember", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "user is a member" + }, + "303": { + "description": "redirection to /orgs/{org}/public_members/{username}" + }, + "404": { + "description": "user is not a member" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Remove a member from an organization", + "operationId": "orgDeleteMember", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "member removed" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/public_members": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List an organization's public members", + "operationId": "orgListPublicMembers", + "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/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/public_members/{username}": { + "get": { + "tags": [ + "organization" + ], + "summary": "Check if a user is a public member of an organization", + "operationId": "orgIsPublicMember", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "user is a public member" + }, + "404": { + "description": "user is not a public member" + } + } + }, + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Publicize a user's membership", + "operationId": "orgPublicizeMember", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "membership publicized" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Conceal a user's membership", + "operationId": "orgConcealMember", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/repos": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List an organization's repos", + "operationId": "orgListRepos", + "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/RepositoryList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Create a repository in an organization", + "operationId": "createOrgRepo", + "parameters": [ + { + "type": "string", + "description": "name of organization", + "name": "org", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateRepoOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Repository" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/teams": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List an organization's teams", + "operationId": "orgListTeams", + "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/TeamList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Create a team", + "operationId": "orgCreateTeam", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateTeamOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Team" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/orgs/{org}/teams/search": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Search for teams within an organization", + "operationId": "teamSearch", + "parameters": [ + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "keywords to search", + "name": "q", + "in": "query" + }, + { + "type": "boolean", + "description": "include search within team description (defaults to true)", + "name": "include_desc", + "in": "query" + }, + { + "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": { + "description": "SearchResults of a successful search", + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/Team" + } + }, + "ok": { + "type": "boolean" + } + } + } + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/orgs/{org}/unblock/{username}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Unblock a user from the organization", + "operationId": "orgUnblockUser", + "parameters": [ + { + "type": "string", + "description": "name of the org", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/packages/{owner}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "package" + ], + "summary": "Gets all packages of an owner", + "operationId": "listPackages", + "parameters": [ + { + "type": "string", + "description": "owner of the packages", + "name": "owner", + "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" + }, + { + "enum": [ + "alpine", + "cargo", + "chef", + "composer", + "conan", + "conda", + "container", + "cran", + "debian", + "generic", + "go", + "helm", + "maven", + "npm", + "nuget", + "pub", + "pypi", + "rpm", + "rubygems", + "swift", + "vagrant" + ], + "type": "string", + "description": "package type filter", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "name filter", + "name": "q", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/PackageList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/packages/{owner}/{type}/{name}/{version}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "package" + ], + "summary": "Gets a package", + "operationId": "getPackage", + "parameters": [ + { + "type": "string", + "description": "owner of the package", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "type of the package", + "name": "type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the package", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "version of the package", + "name": "version", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Package" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "package" + ], + "summary": "Delete a package", + "operationId": "deletePackage", + "parameters": [ + { + "type": "string", + "description": "owner of the package", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "type of the package", + "name": "type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the package", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "version of the package", + "name": "version", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/packages/{owner}/{type}/{name}/{version}/files": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "package" + ], + "summary": "Gets all files of a package", + "operationId": "listPackageFiles", + "parameters": [ + { + "type": "string", + "description": "owner of the package", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "type of the package", + "name": "type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the package", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "version of the package", + "name": "version", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/PackageFileList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/issues/search": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Search for issues across the repositories that the user has access to", + "operationId": "issueSearchIssues", + "parameters": [ + { + "type": "string", + "description": "whether issue is open or closed", + "name": "state", + "in": "query" + }, + { + "type": "string", + "description": "comma separated list of labels. Fetch only issues that have any of this labels. Non existent labels are discarded", + "name": "labels", + "in": "query" + }, + { + "type": "string", + "description": "comma separated list of milestone names. Fetch only issues that have any of this milestones. Non existent are discarded", + "name": "milestones", + "in": "query" + }, + { + "type": "string", + "description": "search string", + "name": "q", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "repository to prioritize in the results", + "name": "priority_repo_id", + "in": "query" + }, + { + "type": "string", + "description": "filter by type (issues / pulls) if set", + "name": "type", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show notifications updated after the given time. This is a timestamp in RFC 3339 format", + "name": "since", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show notifications updated before the given time. This is a timestamp in RFC 3339 format", + "name": "before", + "in": "query" + }, + { + "type": "boolean", + "description": "filter (issues / pulls) assigned to you, default is false", + "name": "assigned", + "in": "query" + }, + { + "type": "boolean", + "description": "filter (issues / pulls) created by you, default is false", + "name": "created", + "in": "query" + }, + { + "type": "boolean", + "description": "filter (issues / pulls) mentioning you, default is false", + "name": "mentioned", + "in": "query" + }, + { + "type": "boolean", + "description": "filter pulls requesting your review, default is false", + "name": "review_requested", + "in": "query" + }, + { + "type": "boolean", + "description": "filter pulls reviewed by you, default is false", + "name": "reviewed", + "in": "query" + }, + { + "type": "string", + "description": "filter by owner", + "name": "owner", + "in": "query" + }, + { + "type": "string", + "description": "filter by team (requires organization owner parameter to be provided)", + "name": "team", + "in": "query" + }, + { + "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/IssueList" + } + } + } + }, + "/repos/migrate": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Migrate a remote git repository", + "operationId": "repoMigrate", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/MigrateRepoOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Repository" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "409": { + "description": "The repository with the same name already exists." + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/search": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Search for repositories", + "operationId": "repoSearch", + "parameters": [ + { + "type": "string", + "description": "keyword", + "name": "q", + "in": "query" + }, + { + "type": "boolean", + "description": "Limit search to repositories with keyword as topic", + "name": "topic", + "in": "query" + }, + { + "type": "boolean", + "description": "include search of keyword within repository description", + "name": "includeDesc", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "search only for repos that the user with the given id owns or contributes to", + "name": "uid", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "repo owner to prioritize in the results", + "name": "priority_owner_id", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "search only for repos that belong to the given team id", + "name": "team_id", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "search only for repos that the user with the given id has starred", + "name": "starredBy", + "in": "query" + }, + { + "type": "boolean", + "description": "include private repositories this user has access to (defaults to true)", + "name": "private", + "in": "query" + }, + { + "type": "boolean", + "description": "show only pubic, private or all repositories (defaults to all)", + "name": "is_private", + "in": "query" + }, + { + "type": "boolean", + "description": "include template repositories this user has access to (defaults to true)", + "name": "template", + "in": "query" + }, + { + "type": "boolean", + "description": "show only archived, non-archived or all repositories (defaults to all)", + "name": "archived", + "in": "query" + }, + { + "type": "string", + "description": "type of repository to search for. Supported values are \"fork\", \"source\", \"mirror\" and \"collaborative\"", + "name": "mode", + "in": "query" + }, + { + "type": "boolean", + "description": "if `uid` is given, search only for repos that the user owns", + "name": "exclusive", + "in": "query" + }, + { + "type": "string", + "description": "sort repos by attribute. Supported values are \"alpha\", \"created\", \"updated\", \"size\", and \"id\". Default is \"alpha\"", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "sort order, either \"asc\" (ascending) or \"desc\" (descending). Default is \"asc\", ignored if \"sort\" is not specified.", + "name": "order", + "in": "query" + }, + { + "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/SearchResults" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a repository", + "operationId": "repoGet", + "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/Repository" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a repository", + "operationId": "repoDelete", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to delete", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to delete", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Edit a repository's properties. Only fields that are set will be changed.", + "operationId": "repoEdit", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to edit", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to edit", + "name": "repo", + "in": "path", + "required": true + }, + { + "description": "Properties of a repo that you can edit", + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditRepoOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Repository" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/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", + "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}/activities/feeds": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repository's activity feeds", + "operationId": "repoListActivityFeeds", + "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", + "format": "date", + "description": "the date of the activities to be found", + "name": "date", + "in": "query" + }, + { + "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/ActivityFeedsList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/archive/{archive}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get an archive of a repository", + "operationId": "repoGetArchive", + "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": "the git reference for download with attached archive format (e.g. master.zip)", + "name": "archive", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "success" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/assignees": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Return all users that have write access and can be assigned to issues", + "operationId": "repoGetAssignees", + "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/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/avatar": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Update avatar", + "operationId": "repoUpdateAvatar", + "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/UpdateRepoAvatarOption" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete avatar", + "operationId": "repoDeleteAvatar", + "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}/branch_protections": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List branch protections for a repository", + "operationId": "repoListBranchProtection", + "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/BranchProtectionList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a branch protections for a repository", + "operationId": "repoCreateBranchProtection", + "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/CreateBranchProtectionOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/BranchProtection" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/branch_protections/{name}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a specific branch protection for the repository", + "operationId": "repoGetBranchProtection", + "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": "name of protected branch", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/BranchProtection" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a specific branch protection for the repository", + "operationId": "repoDeleteBranchProtection", + "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": "name of protected branch", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Edit a branch protections for a repository. Only fields that are set will be changed", + "operationId": "repoEditBranchProtection", + "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": "name of protected branch", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditBranchProtectionOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/BranchProtection" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/branches": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repository's branches", + "operationId": "repoListBranches", + "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", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/BranchList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a branch", + "operationId": "repoCreateBranch", + "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/CreateBranchRepoOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Branch" + }, + "403": { + "description": "The branch is archived or a mirror." + }, + "404": { + "description": "The old branch does not exist." + }, + "409": { + "description": "The branch with the same name already exists." + } + } + } + }, + "/repos/{owner}/{repo}/branches/{branch}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Retrieve a specific branch from a repository, including its effective branch protection", + "operationId": "repoGetBranch", + "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": "branch to get", + "name": "branch", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Branch" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a specific branch from a repository", + "operationId": "repoDeleteBranch", + "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": "branch to delete", + "name": "branch", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/collaborators": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repository's collaborators", + "operationId": "repoListCollaborators", + "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", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/collaborators/{collaborator}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Check if a user is a collaborator of a repository", + "operationId": "repoCheckCollaborator", + "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": "username of the collaborator", + "name": "collaborator", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + }, + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Add a collaborator to a repository", + "operationId": "repoAddCollaborator", + "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": "username of the collaborator to add", + "name": "collaborator", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/AddCollaboratorOption" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a collaborator from a repository", + "operationId": "repoDeleteCollaborator", + "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": "username of the collaborator to delete", + "name": "collaborator", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/collaborators/{collaborator}/permission": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get repository permissions for a user", + "operationId": "repoGetRepoPermissions", + "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": "username of the collaborator", + "name": "collaborator", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/RepoCollaboratorPermission" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/commits": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a list of all commits from a repository", + "operationId": "repoGetAllCommits", + "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": "SHA or branch to start listing commits from (usually 'master')", + "name": "sha", + "in": "query" + }, + { + "type": "string", + "description": "filepath of a file/dir", + "name": "path", + "in": "query" + }, + { + "type": "boolean", + "description": "include diff stats for every commit (disable for speedup, default 'true')", + "name": "stat", + "in": "query" + }, + { + "type": "boolean", + "description": "include verification for every commit (disable for speedup, default 'true')", + "name": "verification", + "in": "query" + }, + { + "type": "boolean", + "description": "include a list of affected files for every commit (disable for speedup, default 'true')", + "name": "files", + "in": "query" + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results (ignored if used with 'path')", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "description": "commits that match the given specifier will not be listed.", + "name": "not", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CommitList" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "$ref": "#/responses/EmptyRepository" + } + } + } + }, + "/repos/{owner}/{repo}/commits/{ref}/status": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a commit's combined status, by branch/tag/commit reference", + "operationId": "repoGetCombinedStatusByRef", + "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": "name of branch/tag/commit", + "name": "ref", + "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/CombinedStatus" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/commits/{ref}/statuses": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a commit's statuses, by branch/tag/commit reference", + "operationId": "repoListStatusesByRef", + "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": "name of branch/tag/commit", + "name": "ref", + "in": "path", + "required": true + }, + { + "enum": [ + "oldest", + "recentupdate", + "leastupdate", + "leastindex", + "highestindex" + ], + "type": "string", + "description": "type of sort", + "name": "sort", + "in": "query" + }, + { + "enum": [ + "pending", + "success", + "error", + "failure", + "warning" + ], + "type": "string", + "description": "type of state", + "name": "state", + "in": "query" + }, + { + "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/CommitStatusList" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/contents": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Gets the metadata of all the entries of the root dir", + "operationId": "repoGetContentsList", + "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": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)", + "name": "ref", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/ContentsListResponse" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Modify multiple files in a repository", + "operationId": "repoChangeFiles", + "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", + "required": true, + "schema": { + "$ref": "#/definitions/ChangeFilesOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/FilesResponse" + }, + "403": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/contents/{filepath}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Gets the metadata and contents (if a file) of an entry in a repository, or a list of entries if a dir", + "operationId": "repoGetContents", + "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": "path of the dir, file, symlink or submodule in the repo", + "name": "filepath", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)", + "name": "ref", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/ContentsResponse" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Update a file in a repository", + "operationId": "repoUpdateFile", + "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": "path of the file to update", + "name": "filepath", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UpdateFileOptions" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/FileResponse" + }, + "403": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/error" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a file in a repository", + "operationId": "repoCreateFile", + "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": "path of the file to create", + "name": "filepath", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateFileOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/FileResponse" + }, + "403": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/error" + } + } + }, + "delete": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a file in a repository", + "operationId": "repoDeleteFile", + "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": "path of the file to delete", + "name": "filepath", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/DeleteFileOptions" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/FileDeleteResponse" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/diffpatch": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Apply diff patch to repository", + "operationId": "repoApplyDiffPatch", + "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", + "required": true, + "schema": { + "$ref": "#/definitions/UpdateFileOptions" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/FileResponse" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/editorconfig/{filepath}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get the EditorConfig definitions of a file in a repository", + "operationId": "repoGetEditorConfig", + "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": "filepath of file to get", + "name": "filepath", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)", + "name": "ref", + "in": "query" + } + ], + "responses": { + "200": { + "description": "success" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/forks": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repository's forks", + "operationId": "listForks", + "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", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/RepositoryList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Fork a repository", + "operationId": "createFork", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to fork", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to fork", + "name": "repo", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateForkOption" + } + } + ], + "responses": { + "202": { + "$ref": "#/responses/Repository" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "description": "The repository with the same name already exists." + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/git/blobs/{sha}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Gets the blob of a repository.", + "operationId": "GetBlob", + "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": "sha of the commit", + "name": "sha", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/GitBlobResponse" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/git/commits/{sha}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a single commit from a repository", + "operationId": "repoGetSingleCommit", + "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": "a git ref or commit sha", + "name": "sha", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "include diff stats for every commit (disable for speedup, default 'true')", + "name": "stat", + "in": "query" + }, + { + "type": "boolean", + "description": "include verification for every commit (disable for speedup, default 'true')", + "name": "verification", + "in": "query" + }, + { + "type": "boolean", + "description": "include a list of affected files for every commit (disable for speedup, default 'true')", + "name": "files", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/Commit" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/git/commits/{sha}.{diffType}": { + "get": { + "produces": [ + "text/plain" + ], + "tags": [ + "repository" + ], + "summary": "Get a commit's diff or patch", + "operationId": "repoDownloadCommitDiffOrPatch", + "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": "SHA of the commit to get", + "name": "sha", + "in": "path", + "required": true + }, + { + "enum": [ + "diff", + "patch" + ], + "type": "string", + "description": "whether the output is diff or patch", + "name": "diffType", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/string" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/git/notes/{sha}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a note corresponding to a single commit from a repository", + "operationId": "repoGetNote", + "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": "a git ref or commit sha", + "name": "sha", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "include verification for every commit (disable for speedup, default 'true')", + "name": "verification", + "in": "query" + }, + { + "type": "boolean", + "description": "include a list of affected files for every commit (disable for speedup, default 'true')", + "name": "files", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/Note" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/git/refs": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get specified ref or filtered repository's refs", + "operationId": "repoListAllGitRefs", + "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/ReferenceList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/git/refs/{ref}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get specified ref or filtered repository's refs", + "operationId": "repoListGitRefs", + "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": "part or full name of the ref", + "name": "ref", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/ReferenceList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/git/tags/{sha}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Gets the tag object of an annotated tag (not lightweight tags)", + "operationId": "GetAnnotatedTag", + "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": "sha of the tag. The Git tags API only supports annotated tag objects, not lightweight tags.", + "name": "sha", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/AnnotatedTag" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/git/trees/{sha}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Gets the tree of a repository.", + "operationId": "GetTree", + "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": "sha of the commit", + "name": "sha", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "show all directories and files", + "name": "recursive", + "in": "query" + }, + { + "type": "integer", + "description": "page number; the 'truncated' field in the response will be true if there are still more items after this page, false if the last page", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "number of items per page", + "name": "per_page", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/GitTreeResponse" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/hooks": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List the hooks in a repository", + "operationId": "repoListHooks", + "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", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/HookList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a hook", + "operationId": "repoCreateHook", + "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/CreateHookOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Hook" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/hooks/git": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List the Git hooks in a repository", + "operationId": "repoListGitHooks", + "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/GitHookList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/hooks/git/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a Git hook", + "operationId": "repoGetGitHook", + "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": "id of the hook to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/GitHook" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a Git hook in a repository", + "operationId": "repoDeleteGitHook", + "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": "id of the hook to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Edit a Git hook in a repository", + "operationId": "repoEditGitHook", + "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": "id of the hook to get", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditGitHookOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/GitHook" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/hooks/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a hook", + "operationId": "repoGetHook", + "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", + "format": "int64", + "description": "id of the hook to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Hook" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a hook in a repository", + "operationId": "repoDeleteHook", + "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", + "format": "int64", + "description": "id of the hook to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Edit a hook in a repository", + "operationId": "repoEditHook", + "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", + "format": "int64", + "description": "index of the hook", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditHookOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Hook" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/hooks/{id}/tests": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Test a push webhook", + "operationId": "repoTestHook", + "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", + "format": "int64", + "description": "id of the hook to test", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the commit/branch/tag, indicates which commit will be loaded to the webhook payload.", + "name": "ref", + "in": "query" + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issue_config": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Returns the issue config for a repo", + "operationId": "repoGetIssueConfig", + "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/RepoIssueConfig" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issue_config/validate": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Returns the validation information for a issue config", + "operationId": "repoValidateIssueConfig", + "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/RepoIssueConfigValidation" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issue_templates": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get available issue templates for a repository", + "operationId": "repoGetIssueTemplates", + "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/IssueTemplates" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List a repository's issues", + "operationId": "issueListIssues", + "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 + }, + { + "enum": [ + "closed", + "open", + "all" + ], + "type": "string", + "description": "whether issue is open or closed", + "name": "state", + "in": "query" + }, + { + "type": "string", + "description": "comma separated list of labels. Fetch only issues that have any of this labels. Non existent labels are discarded", + "name": "labels", + "in": "query" + }, + { + "type": "string", + "description": "search string", + "name": "q", + "in": "query" + }, + { + "enum": [ + "issues", + "pulls" + ], + "type": "string", + "description": "filter by type (issues / pulls) if set", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "comma separated list of milestone names or ids. It uses names and fall back to ids. Fetch only issues that have any of this milestones. Non existent milestones are discarded", + "name": "milestones", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show items updated after the given time. This is a timestamp in RFC 3339 format", + "name": "since", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show items updated before the given time. This is a timestamp in RFC 3339 format", + "name": "before", + "in": "query" + }, + { + "type": "string", + "description": "Only show items which were created by the the given user", + "name": "created_by", + "in": "query" + }, + { + "type": "string", + "description": "Only show items for which the given user is assigned", + "name": "assigned_by", + "in": "query" + }, + { + "type": "string", + "description": "Only show items in which the given user was mentioned", + "name": "mentioned_by", + "in": "query" + }, + { + "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/IssueList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Create an issue. If using deadline only the date will be taken into account, and time of day ignored.", + "operationId": "issueCreateIssue", + "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/CreateIssueOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Issue" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "412": { + "$ref": "#/responses/error" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/issues/comments": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List all comments in a repository", + "operationId": "issueGetRepoComments", + "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", + "format": "date-time", + "description": "if provided, only comments updated since the provided time are returned.", + "name": "since", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "if provided, only comments updated before the provided time are returned.", + "name": "before", + "in": "query" + }, + { + "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/CommentList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/comments/{id}": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get a comment", + "operationId": "issueGetComment", + "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", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Comment" + }, + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "issue" + ], + "summary": "Delete a comment", + "operationId": "issueDeleteComment", + "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", + "format": "int64", + "description": "id of comment to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Edit a comment", + "operationId": "issueEditComment", + "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", + "format": "int64", + "description": "id of the comment to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditIssueCommentOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Comment" + }, + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/comments/{id}/assets": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List comment's attachments", + "operationId": "issueListIssueCommentAttachments", + "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", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/AttachmentList" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "post": { + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Create a comment attachment", + "operationId": "issueCreateIssueCommentAttachment", + "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", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the attachment", + "name": "name", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "time of the attachment's creation. This is a timestamp in RFC 3339 format", + "name": "updated_at", + "in": "query" + }, + { + "type": "file", + "description": "attachment to upload", + "name": "attachment", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "$ref": "#/responses/Attachment" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/issues/comments/{id}/assets/{attachment_id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get a comment attachment", + "operationId": "issueGetIssueCommentAttachment", + "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", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to get", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Attachment" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Delete a comment attachment", + "operationId": "issueDeleteIssueCommentAttachment", + "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", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to delete", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Edit a comment attachment", + "operationId": "issueEditIssueCommentAttachment", + "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", + "format": "int64", + "description": "id of the comment", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to edit", + "name": "attachment_id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditAttachmentOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Attachment" + }, + "404": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/issues/comments/{id}/reactions": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get a list of reactions from a comment of an issue", + "operationId": "issueGetCommentReactions", + "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", + "format": "int64", + "description": "id of the comment to edit", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/ReactionList" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Add a reaction to a comment of an issue", + "operationId": "issuePostCommentReaction", + "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", + "format": "int64", + "description": "id of the comment to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "content", + "in": "body", + "schema": { + "$ref": "#/definitions/EditReactionOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Reaction" + }, + "201": { + "$ref": "#/responses/Reaction" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Remove a reaction from a comment of an issue", + "operationId": "issueDeleteCommentReaction", + "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", + "format": "int64", + "description": "id of the comment to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "content", + "in": "body", + "schema": { + "$ref": "#/definitions/EditReactionOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/pinned": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repo's pinned issues", + "operationId": "repoListPinnedIssues", + "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/IssueList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get an issue", + "operationId": "issueGetIssue", + "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", + "format": "int64", + "description": "index of the issue to get", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Issue" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "issue" + ], + "summary": "Delete an issue", + "operationId": "issueDelete", + "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", + "format": "int64", + "description": "index of issue to delete", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Edit an issue. If using deadline only the date will be taken into account, and time of day ignored.", + "operationId": "issueEditIssue", + "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", + "format": "int64", + "description": "index of the issue to edit", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditIssueOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Issue" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "412": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/assets": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List issue's attachments", + "operationId": "issueListIssueAttachments", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/AttachmentList" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "post": { + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Create an issue attachment", + "operationId": "issueCreateIssueAttachment", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the attachment", + "name": "name", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "time of the attachment's creation. This is a timestamp in RFC 3339 format", + "name": "updated_at", + "in": "query" + }, + { + "type": "file", + "description": "attachment to upload", + "name": "attachment", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "$ref": "#/responses/Attachment" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/assets/{attachment_id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get an issue attachment", + "operationId": "issueGetIssueAttachment", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to get", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Attachment" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Delete an issue attachment", + "operationId": "issueDeleteIssueAttachment", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to delete", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/error" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Edit an issue attachment", + "operationId": "issueEditIssueAttachment", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to edit", + "name": "attachment_id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditAttachmentOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Attachment" + }, + "404": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/blocks": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List issues that are blocked by this issue", + "operationId": "issueListBlocks", + "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": "index of the issue", + "name": "index", + "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/IssueList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Block the issue given in the body by the issue in path", + "operationId": "issueCreateIssueBlocking", + "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": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/IssueMeta" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Issue" + }, + "404": { + "description": "the issue does not exist" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Unblock the issue given in the body by the issue in path", + "operationId": "issueRemoveIssueBlocking", + "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": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/IssueMeta" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Issue" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/comments": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List all comments on an issue", + "operationId": "issueGetComments", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "date-time", + "description": "if provided, only comments updated since the specified time are returned.", + "name": "since", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "if provided, only comments updated before the provided time are returned.", + "name": "before", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CommentList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Add a comment to an issue", + "operationId": "issueCreateComment", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateIssueCommentOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Comment" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/comments/{id}": { + "delete": { + "tags": [ + "issue" + ], + "summary": "Delete a comment", + "operationId": "issueDeleteCommentDeprecated", + "deprecated": true, + "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": "this parameter is ignored", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of comment to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Edit a comment", + "operationId": "issueEditCommentDeprecated", + "deprecated": true, + "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": "this parameter is ignored", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the comment to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditIssueCommentOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Comment" + }, + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/deadline": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Set an issue deadline. If set to null, the deadline is deleted. If using deadline only the date will be taken into account, and time of day ignored.", + "operationId": "issueEditIssueDeadline", + "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", + "format": "int64", + "description": "index of the issue to create or update a deadline on", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditDeadlineOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/IssueDeadline" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/dependencies": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List an issue's dependencies, i.e all issues that block this issue.", + "operationId": "issueListIssueDependencies", + "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": "index of the issue", + "name": "index", + "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/IssueList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Make the issue in the url depend on the issue in the form.", + "operationId": "issueCreateIssueDependencies", + "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": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/IssueMeta" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Issue" + }, + "404": { + "description": "the issue does not exist" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Remove an issue dependency", + "operationId": "issueRemoveIssueDependencies", + "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": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/IssueMeta" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Issue" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/labels": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get an issue's labels", + "operationId": "issueGetLabels", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/LabelList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Replace an issue's labels", + "operationId": "issueReplaceLabels", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/IssueLabelsOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/LabelList" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Add a label to an issue", + "operationId": "issueAddLabel", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/IssueLabelsOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/LabelList" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Remove all labels from an issue", + "operationId": "issueClearLabels", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/DeleteLabelsOption" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/labels/{id}": { + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Remove a label from an issue", + "operationId": "issueRemoveLabel", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the label to remove", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/DeleteLabelsOption" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/pin": { + "post": { + "tags": [ + "issue" + ], + "summary": "Pin an Issue", + "operationId": "pinIssue", + "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", + "format": "int64", + "description": "index of issue to pin", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "issue" + ], + "summary": "Unpin an Issue", + "operationId": "unpinIssue", + "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", + "format": "int64", + "description": "index of issue to unpin", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/pin/{position}": { + "patch": { + "tags": [ + "issue" + ], + "summary": "Moves the Pin to the given Position", + "operationId": "moveIssuePin", + "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", + "format": "int64", + "description": "index of issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "the new position", + "name": "position", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/reactions": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get a list reactions of an issue", + "operationId": "issueGetIssueReactions", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "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/ReactionList" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Add a reaction to an issue", + "operationId": "issuePostIssueReaction", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "content", + "in": "body", + "schema": { + "$ref": "#/definitions/EditReactionOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Reaction" + }, + "201": { + "$ref": "#/responses/Reaction" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Remove a reaction from an issue", + "operationId": "issueDeleteIssueReaction", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "content", + "in": "body", + "schema": { + "$ref": "#/definitions/EditReactionOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/stopwatch/delete": { + "delete": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Delete an issue's existing stopwatch.", + "operationId": "issueDeleteStopWatch", + "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", + "format": "int64", + "description": "index of the issue to stop the stopwatch on", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "description": "Not repo writer, user does not have rights to toggle stopwatch" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "description": "Cannot cancel a non existent stopwatch" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/stopwatch/start": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Start stopwatch on an issue.", + "operationId": "issueStartStopWatch", + "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", + "format": "int64", + "description": "index of the issue to create the stopwatch on", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "$ref": "#/responses/empty" + }, + "403": { + "description": "Not repo writer, user does not have rights to toggle stopwatch" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "description": "Cannot start a stopwatch again if it already exists" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/stopwatch/stop": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Stop an issue's existing stopwatch.", + "operationId": "issueStopStopWatch", + "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", + "format": "int64", + "description": "index of the issue to stop the stopwatch on", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "$ref": "#/responses/empty" + }, + "403": { + "description": "Not repo writer, user does not have rights to toggle stopwatch" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "description": "Cannot stop a non existent stopwatch" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/subscriptions": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get users who subscribed on an issue.", + "operationId": "issueSubscriptions", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "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/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/subscriptions/check": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Check if user is subscribed to an issue", + "operationId": "issueCheckSubscription", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/WatchInfo" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/subscriptions/{user}": { + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Subscribe user to issue", + "operationId": "issueAddSubscription", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "user to subscribe", + "name": "user", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Already subscribed" + }, + "201": { + "description": "Successfully Subscribed" + }, + "304": { + "description": "User can only subscribe itself if he is no admin" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Unsubscribe user from issue", + "operationId": "issueDeleteSubscription", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "user witch unsubscribe", + "name": "user", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Already unsubscribed" + }, + "201": { + "description": "Successfully Unsubscribed" + }, + "304": { + "description": "User can only subscribe itself if he is no admin" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/timeline": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List all comments and events on an issue", + "operationId": "issueGetCommentsAndTimeline", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "date-time", + "description": "if provided, only comments updated since the specified time are returned.", + "name": "since", + "in": "query" + }, + { + "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" + }, + { + "type": "string", + "format": "date-time", + "description": "if provided, only comments updated before the provided time are returned.", + "name": "before", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/TimelineList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/times": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "List an issue's tracked times", + "operationId": "issueTrackedTimes", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "optional filter by user (available for issue managers)", + "name": "user", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show times updated after the given time. This is a timestamp in RFC 3339 format", + "name": "since", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show times updated before the given time. This is a timestamp in RFC 3339 format", + "name": "before", + "in": "query" + }, + { + "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/TrackedTimeList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Add tracked time to a issue", + "operationId": "issueAddTime", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/AddTimeOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/TrackedTime" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Reset a tracked time of an issue", + "operationId": "issueResetTime", + "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", + "format": "int64", + "description": "index of the issue to add tracked time to", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/issues/{index}/times/{id}": { + "delete": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Delete specific tracked time", + "operationId": "issueDeleteTime", + "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", + "format": "int64", + "description": "index of the issue", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of time to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/keys": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repository's keys", + "operationId": "repoListKeys", + "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": "the key_id to search for", + "name": "key_id", + "in": "query" + }, + { + "type": "string", + "description": "fingerprint of the key", + "name": "fingerprint", + "in": "query" + }, + { + "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/DeployKeyList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Add a key to a repository", + "operationId": "repoCreateKey", + "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/CreateKeyOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/DeployKey" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/keys/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a repository's key by id", + "operationId": "repoGetKey", + "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", + "format": "int64", + "description": "id of the key to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/DeployKey" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "repository" + ], + "summary": "Delete a key from a repository", + "operationId": "repoDeleteKey", + "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", + "format": "int64", + "description": "id of the key to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/labels": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get all of a repository's labels", + "operationId": "issueListLabels", + "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", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/LabelList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Create a label", + "operationId": "issueCreateLabel", + "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/CreateLabelOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Label" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/labels/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get a single label", + "operationId": "issueGetLabel", + "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", + "format": "int64", + "description": "id of the label to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Label" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "issue" + ], + "summary": "Delete a label", + "operationId": "issueDeleteLabel", + "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", + "format": "int64", + "description": "id of the label to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Update a label", + "operationId": "issueEditLabel", + "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", + "format": "int64", + "description": "id of the label to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditLabelOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Label" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/languages": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get languages and number of bytes of code written", + "operationId": "repoGetLanguages", + "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/LanguageStatistics" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/media/{filepath}": { + "get": { + "tags": [ + "repository" + ], + "summary": "Get a file or it's LFS object from a repository", + "operationId": "repoGetRawFileOrLFS", + "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": "filepath of the file to get", + "name": "filepath", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)", + "name": "ref", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Returns raw file content." + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/milestones": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get all of a repository's opened milestones", + "operationId": "issueGetMilestonesList", + "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": "Milestone state, Recognized values are open, closed and all. Defaults to \"open\"", + "name": "state", + "in": "query" + }, + { + "type": "string", + "description": "filter by milestone name", + "name": "name", + "in": "query" + }, + { + "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/MilestoneList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Create a milestone", + "operationId": "issueCreateMilestone", + "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/CreateMilestoneOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Milestone" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/milestones/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Get a milestone", + "operationId": "issueGetMilestone", + "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": "the milestone to get, identified by ID and if not available by name", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Milestone" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "issue" + ], + "summary": "Delete a milestone", + "operationId": "issueDeleteMilestone", + "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": "the milestone to delete, identified by ID and if not available by name", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issue" + ], + "summary": "Update a milestone", + "operationId": "issueEditMilestone", + "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": "the milestone to edit, identified by ID and if not available by name", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditMilestoneOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Milestone" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/mirror-sync": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Sync a mirrored repository", + "operationId": "repoMirrorSync", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to sync", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to sync", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/new_pin_allowed": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Returns if new Issue Pins are allowed", + "operationId": "repoNewPinAllowed", + "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/RepoNewIssuePinsAllowed" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/notifications": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notification" + ], + "summary": "List users's notification threads on a specific repo", + "operationId": "notifyGetRepoList", + "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": "boolean", + "description": "If true, show notifications marked as read. Default value is false", + "name": "all", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "Show notifications with the provided status types. Options are: unread, read and/or pinned. Defaults to unread \u0026 pinned", + "name": "status-types", + "in": "query" + }, + { + "type": "array", + "items": { + "enum": [ + "issue", + "pull", + "commit", + "repository" + ], + "type": "string" + }, + "collectionFormat": "multi", + "description": "filter notifications by subject type", + "name": "subject-type", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show notifications updated after the given time. This is a timestamp in RFC 3339 format", + "name": "since", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show notifications updated before the given time. This is a timestamp in RFC 3339 format", + "name": "before", + "in": "query" + }, + { + "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/NotificationThreadList" + } + } + }, + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notification" + ], + "summary": "Mark notification threads as read, pinned or unread on a specific repo", + "operationId": "notifyReadRepoList", + "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": "If true, mark all notifications on this repo. Default value is false", + "name": "all", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "Mark notifications with the provided status types. Options are: unread, read and/or pinned. Defaults to unread.", + "name": "status-types", + "in": "query" + }, + { + "type": "string", + "description": "Status to mark notifications as. Defaults to read.", + "name": "to-status", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Describes the last point that notifications were checked. Anything updated since this time will not be updated.", + "name": "last_read_at", + "in": "query" + } + ], + "responses": { + "205": { + "$ref": "#/responses/NotificationThreadList" + } + } + } + }, + "/repos/{owner}/{repo}/pulls": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repo's pull requests", + "operationId": "repoListPullRequests", + "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 + }, + { + "enum": [ + "closed", + "open", + "all" + ], + "type": "string", + "description": "State of pull request: open or closed (optional)", + "name": "state", + "in": "query" + }, + { + "enum": [ + "oldest", + "recentupdate", + "leastupdate", + "mostcomment", + "leastcomment", + "priority" + ], + "type": "string", + "description": "Type of sort", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "ID of the milestone", + "name": "milestone", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "collectionFormat": "multi", + "description": "Label IDs", + "name": "labels", + "in": "query" + }, + { + "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/PullRequestList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a pull request", + "operationId": "repoCreatePullRequest", + "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/CreatePullRequestOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/PullRequest" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "$ref": "#/responses/error" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/pinned": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repo's pinned pull requests", + "operationId": "repoListPinnedPullRequests", + "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/PullRequestList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a pull request", + "operationId": "repoGetPullRequest", + "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", + "format": "int64", + "description": "index of the pull request to get", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/PullRequest" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Update a pull request. If using deadline only the date will be taken into account, and time of day ignored.", + "operationId": "repoEditPullRequest", + "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", + "format": "int64", + "description": "index of the pull request to edit", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditPullRequestOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/PullRequest" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "$ref": "#/responses/error" + }, + "412": { + "$ref": "#/responses/error" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}.{diffType}": { + "get": { + "produces": [ + "text/plain" + ], + "tags": [ + "repository" + ], + "summary": "Get a pull request diff or patch", + "operationId": "repoDownloadPullDiffOrPatch", + "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", + "format": "int64", + "description": "index of the pull request to get", + "name": "index", + "in": "path", + "required": true + }, + { + "enum": [ + "diff", + "patch" + ], + "type": "string", + "description": "whether the output is diff or patch", + "name": "diffType", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "whether to include binary file changes. if true, the diff is applicable with `git apply`", + "name": "binary", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/string" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/commits": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get commits for a pull request", + "operationId": "repoGetPullRequestCommits", + "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", + "format": "int64", + "description": "index of the pull request to get", + "name": "index", + "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" + }, + { + "type": "boolean", + "description": "include verification for every commit (disable for speedup, default 'true')", + "name": "verification", + "in": "query" + }, + { + "type": "boolean", + "description": "include a list of affected files for every commit (disable for speedup, default 'true')", + "name": "files", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CommitList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/files": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get changed files for a pull request", + "operationId": "repoGetPullRequestFiles", + "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", + "format": "int64", + "description": "index of the pull request to get", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "skip to given file", + "name": "skip-to", + "in": "query" + }, + { + "enum": [ + "ignore-all", + "ignore-change", + "ignore-eol", + "show-all" + ], + "type": "string", + "description": "whitespace behavior", + "name": "whitespace", + "in": "query" + }, + { + "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/ChangedFileList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/merge": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Check if a pull request has been merged", + "operationId": "repoPullRequestIsMerged", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "pull request has been merged" + }, + "404": { + "description": "pull request has not been merged" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Merge a pull request", + "operationId": "repoMergePullRequest", + "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", + "format": "int64", + "description": "index of the pull request to merge", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/MergePullRequestOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "405": { + "$ref": "#/responses/empty" + }, + "409": { + "$ref": "#/responses/error" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Cancel the scheduled auto merge for the given pull request", + "operationId": "repoCancelScheduledAutoMerge", + "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", + "format": "int64", + "description": "index of the pull request to merge", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/requested_reviewers": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "create review requests for a pull request", + "operationId": "repoCreatePullReviewRequests", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PullReviewRequestOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/PullReviewList" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "cancel review requests for a pull request", + "operationId": "repoDeletePullReviewRequests", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PullReviewRequestOptions" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/reviews": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List all reviews for a pull request", + "operationId": "repoListPullReviews", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "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/PullReviewList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a review to an pull request", + "operationId": "repoCreatePullReview", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreatePullReviewOptions" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/PullReview" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/reviews/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a specific review for a pull request", + "operationId": "repoGetPullReview", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the review", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/PullReview" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Submit a pending review to an pull request", + "operationId": "repoSubmitPullReview", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the review", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/SubmitPullReviewOptions" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/PullReview" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a specific review from a pull request", + "operationId": "repoDeletePullReview", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the review", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a specific review for a pull request", + "operationId": "repoGetPullReviewComments", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the review", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/PullReviewCommentList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/reviews/{id}/dismissals": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Dismiss a review for a pull request", + "operationId": "repoDismissPullReview", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the review", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/DismissPullReviewOptions" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/PullReview" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/reviews/{id}/undismissals": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Cancel to dismiss a review for a pull request", + "operationId": "repoUnDismissPullReview", + "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", + "format": "int64", + "description": "index of the pull request", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the review", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/PullReview" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/pulls/{index}/update": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Merge PR's baseBranch into headBranch", + "operationId": "repoUpdatePullRequest", + "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", + "format": "int64", + "description": "index of the pull request to get", + "name": "index", + "in": "path", + "required": true + }, + { + "enum": [ + "merge", + "rebase" + ], + "type": "string", + "description": "how to update pull request", + "name": "style", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "$ref": "#/responses/error" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/push_mirrors": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get all push mirrors of the repository", + "operationId": "repoListPushMirrors", + "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", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/PushMirrorList" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "add a push mirror to the repository", + "operationId": "repoAddPushMirror", + "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/CreatePushMirrorOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/PushMirror" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/push_mirrors-sync": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Sync all push mirrored repository", + "operationId": "repoPushMirrorSync", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to sync", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to sync", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/empty" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/push_mirrors/{name}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get push mirror of the repository by remoteName", + "operationId": "repoGetPushMirrorByRemoteName", + "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": "remote name of push mirror", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/PushMirror" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "deletes a push mirror from a repository by remoteName", + "operationId": "repoDeletePushMirror", + "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": "remote name of the pushMirror", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/raw/{filepath}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a file from a repository", + "operationId": "repoGetRawFile", + "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": "filepath of the file to get", + "name": "filepath", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)", + "name": "ref", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Returns raw file content." + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/releases": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repo's releases", + "operationId": "repoListReleases", + "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": "boolean", + "description": "filter (exclude / include) drafts, if you dont have repo write access none will show", + "name": "draft", + "in": "query" + }, + { + "type": "boolean", + "description": "filter (exclude / include) pre-releases", + "name": "pre-release", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results, deprecated - use limit", + "name": "per_page", + "in": "query" + }, + { + "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/ReleaseList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a release", + "operationId": "repoCreateRelease", + "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/CreateReleaseOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Release" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/releases/latest": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Gets the most recent non-prerelease, non-draft release of a repository, sorted by created_at", + "operationId": "repoGetLatestRelease", + "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/Release" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/releases/tags/{tag}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a release by tag name", + "operationId": "repoGetReleaseByTag", + "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": "tag name of the release to get", + "name": "tag", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Release" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "repository" + ], + "summary": "Delete a release by tag name", + "operationId": "repoDeleteReleaseByTag", + "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": "tag name of the release to delete", + "name": "tag", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "405": { + "$ref": "#/responses/empty" + } + } + } + }, + "/repos/{owner}/{repo}/releases/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a release", + "operationId": "repoGetRelease", + "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", + "format": "int64", + "description": "id of the release to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Release" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "repository" + ], + "summary": "Delete a release", + "operationId": "repoDeleteRelease", + "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", + "format": "int64", + "description": "id of the release to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "405": { + "$ref": "#/responses/empty" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Update a release", + "operationId": "repoEditRelease", + "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", + "format": "int64", + "description": "id of the release to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditReleaseOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Release" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/releases/{id}/assets": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List release's attachments", + "operationId": "repoListReleaseAttachments", + "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", + "format": "int64", + "description": "id of the release", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/AttachmentList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a release attachment", + "operationId": "repoCreateReleaseAttachment", + "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", + "format": "int64", + "description": "id of the release", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the attachment", + "name": "name", + "in": "query" + }, + { + "type": "file", + "description": "attachment to upload", + "name": "attachment", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "$ref": "#/responses/Attachment" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/releases/{id}/assets/{attachment_id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a release attachment", + "operationId": "repoGetReleaseAttachment", + "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", + "format": "int64", + "description": "id of the release", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to get", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Attachment" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a release attachment", + "operationId": "repoDeleteReleaseAttachment", + "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", + "format": "int64", + "description": "id of the release", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to delete", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Edit a release attachment", + "operationId": "repoEditReleaseAttachment", + "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", + "format": "int64", + "description": "id of the release", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "id of the attachment to edit", + "name": "attachment_id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditAttachmentOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Attachment" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/reviewers": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Return all users that can be requested to review in this repo", + "operationId": "repoGetReviewers", + "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/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/signing-key.gpg": { + "get": { + "produces": [ + "text/plain" + ], + "tags": [ + "repository" + ], + "summary": "Get signing-key.gpg for given repository", + "operationId": "repoSigningKey", + "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": { + "description": "GPG armored public key", + "schema": { + "type": "string" + } + } + } + } + }, + "/repos/{owner}/{repo}/stargazers": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repo's stargazers", + "operationId": "repoListStargazers", + "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", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/statuses/{sha}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a commit's statuses", + "operationId": "repoListStatuses", + "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": "sha of the commit", + "name": "sha", + "in": "path", + "required": true + }, + { + "enum": [ + "oldest", + "recentupdate", + "leastupdate", + "leastindex", + "highestindex" + ], + "type": "string", + "description": "type of sort", + "name": "sort", + "in": "query" + }, + { + "enum": [ + "pending", + "success", + "error", + "failure", + "warning" + ], + "type": "string", + "description": "type of state", + "name": "state", + "in": "query" + }, + { + "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/CommitStatusList" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a commit status", + "operationId": "repoCreateStatus", + "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": "sha of the commit", + "name": "sha", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateStatusOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/CommitStatus" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/subscribers": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repo's watchers", + "operationId": "repoListSubscribers", + "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", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/subscription": { + "get": { + "tags": [ + "repository" + ], + "summary": "Check if the current user is watching a repo", + "operationId": "userCurrentCheckSubscription", + "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": { + "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}/tags": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repository's tags", + "operationId": "repoListTags", + "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/TagList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a new git tag in a repository", + "operationId": "repoCreateTag", + "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/CreateTagOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Tag" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "405": { + "$ref": "#/responses/empty" + }, + "409": { + "$ref": "#/responses/conflict" + } + } + } + }, + "/repos/{owner}/{repo}/tags/{tag}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get the tag of a repository by tag name", + "operationId": "repoGetTag", + "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": "name of tag", + "name": "tag", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Tag" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a repository's tag by name", + "operationId": "repoDeleteTag", + "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": "name of tag to delete", + "name": "tag", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "405": { + "$ref": "#/responses/empty" + }, + "409": { + "$ref": "#/responses/conflict" + } + } + } + }, + "/repos/{owner}/{repo}/teams": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repository's teams", + "operationId": "repoListTeams", + "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/TeamList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/teams/{team}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Check if a team is assigned to a repository", + "operationId": "repoCheckTeam", + "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": "team name", + "name": "team", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Team" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "405": { + "$ref": "#/responses/error" + } + } + }, + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Add a team to a repository", + "operationId": "repoAddTeam", + "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": "team name", + "name": "team", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "405": { + "$ref": "#/responses/error" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a team from a repository", + "operationId": "repoDeleteTeam", + "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": "team name", + "name": "team", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "405": { + "$ref": "#/responses/error" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/times": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a repo's tracked times", + "operationId": "repoTrackedTimes", + "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": "optional filter by user (available for issue managers)", + "name": "user", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show times updated after the given time. This is a timestamp in RFC 3339 format", + "name": "since", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show times updated before the given time. This is a timestamp in RFC 3339 format", + "name": "before", + "in": "query" + }, + { + "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/TrackedTimeList" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/times/{user}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "List a user's tracked times in a repo", + "operationId": "userTrackedTimes", + "deprecated": true, + "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": "username of user", + "name": "user", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/TrackedTimeList" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/topics": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get list of topics that a repository has", + "operationId": "repoListTopics", + "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", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/TopicNames" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Replace list of topics for a repository", + "operationId": "repoUpdateTopics", + "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/RepoTopicOptions" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/invalidTopicsError" + } + } + } + }, + "/repos/{owner}/{repo}/topics/{topic}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Add a topic to a repository", + "operationId": "repoAddTopic", + "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": "name of the topic to add", + "name": "topic", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/invalidTopicsError" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Delete a topic from a repository", + "operationId": "repoDeleteTopic", + "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": "name of the topic to delete", + "name": "topic", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/invalidTopicsError" + } + } + } + }, + "/repos/{owner}/{repo}/transfer": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Transfer a repo ownership", + "operationId": "repoTransfer", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to transfer", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to transfer", + "name": "repo", + "in": "path", + "required": true + }, + { + "description": "Transfer Options", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/TransferRepoOption" + } + } + ], + "responses": { + "202": { + "$ref": "#/responses/Repository" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repos/{owner}/{repo}/transfer/accept": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Accept a repo transfer", + "operationId": "acceptRepoTransfer", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to transfer", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to transfer", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "$ref": "#/responses/Repository" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/transfer/reject": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Reject a repo transfer", + "operationId": "rejectRepoTransfer", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to transfer", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to transfer", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Repository" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/wiki/new": { + "post": { + "consumes": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a wiki page", + "operationId": "repoCreateWikiPage", + "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/CreateWikiPageOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/WikiPage" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/wiki/page/{pageName}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a wiki page", + "operationId": "repoGetWikiPage", + "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": "name of the page", + "name": "pageName", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/WikiPage" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "repository" + ], + "summary": "Delete a wiki page", + "operationId": "repoDeleteWikiPage", + "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": "name of the page", + "name": "pageName", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Edit a wiki page", + "operationId": "repoEditWikiPage", + "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": "name of the page", + "name": "pageName", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateWikiPageOptions" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/WikiPage" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/wiki/pages": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get all wiki pages", + "operationId": "repoGetWikiPages", + "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", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/WikiPageList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/wiki/revisions/{pageName}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get revisions of a wiki page", + "operationId": "repoGetWikiPageRevisions", + "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": "name of the page", + "name": "pageName", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/WikiCommitList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{template_owner}/{template_repo}/generate": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Create a repository using a template", + "operationId": "generateRepo", + "parameters": [ + { + "type": "string", + "description": "name of the template repository owner", + "name": "template_owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the template repository", + "name": "template_repo", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/GenerateRepoOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Repository" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "409": { + "description": "The repository with the same name already exists." + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/repositories/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a repository by id", + "operationId": "repoGetByID", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the repo to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Repository" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/settings/api": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "settings" + ], + "summary": "Get instance's global settings for api", + "operationId": "getGeneralAPISettings", + "responses": { + "200": { + "$ref": "#/responses/GeneralAPISettings" + } + } + } + }, + "/settings/attachment": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "settings" + ], + "summary": "Get instance's global settings for Attachment", + "operationId": "getGeneralAttachmentSettings", + "responses": { + "200": { + "$ref": "#/responses/GeneralAttachmentSettings" + } + } + } + }, + "/settings/repository": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "settings" + ], + "summary": "Get instance's global settings for repositories", + "operationId": "getGeneralRepositorySettings", + "responses": { + "200": { + "$ref": "#/responses/GeneralRepoSettings" + } + } + } + }, + "/settings/ui": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "settings" + ], + "summary": "Get instance's global settings for ui", + "operationId": "getGeneralUISettings", + "responses": { + "200": { + "$ref": "#/responses/GeneralUISettings" + } + } + } + }, + "/signing-key.gpg": { + "get": { + "produces": [ + "text/plain" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Get default signing-key.gpg", + "operationId": "getSigningKey", + "responses": { + "200": { + "description": "GPG armored public key", + "schema": { + "type": "string" + } + } + } + } + }, + "/teams/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Get a team", + "operationId": "orgGetTeam", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Team" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "organization" + ], + "summary": "Delete a team", + "operationId": "orgDeleteTeam", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "team deleted" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Edit a team", + "operationId": "orgEditTeam", + "parameters": [ + { + "type": "integer", + "description": "id of the team to edit", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditTeamOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Team" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/teams/{id}/activities/feeds": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List a team's activity feeds", + "operationId": "orgListTeamActivityFeeds", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "date", + "description": "the date of the activities to be found", + "name": "date", + "in": "query" + }, + { + "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/ActivityFeedsList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/teams/{id}/members": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List a team's members", + "operationId": "orgListTeamMembers", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team", + "name": "id", + "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/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/teams/{id}/members/{username}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List a particular member of team", + "operationId": "orgListTeamMember", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the member to list", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/User" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Add a team member", + "operationId": "orgAddTeamMember", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user to add", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Remove a team member", + "operationId": "orgRemoveTeamMember", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of the user to remove", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/teams/{id}/repos": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List a team's repos", + "operationId": "orgListTeamRepos", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team", + "name": "id", + "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/RepositoryList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/teams/{id}/repos/{org}/{repo}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List a particular repo of team", + "operationId": "orgListTeamRepo", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "organization that owns the repo to list", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to list", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Repository" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Add a repository to a team", + "operationId": "orgAddTeamRepository", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "organization that owns the repo to add", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to add", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "description": "This does not delete the repository, it only removes the repository from the team.", + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Remove a repository from a team", + "operationId": "orgRemoveTeamRepository", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the team", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "organization that owns the repo to remove", + "name": "org", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to remove", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/topics/search": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "search topics via keyword", + "operationId": "topicSearch", + "parameters": [ + { + "type": "string", + "description": "keywords to search", + "name": "q", + "in": "query", + "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/TopicListResponse" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get the authenticated user", + "operationId": "userGetCurrent", + "responses": { + "200": { + "$ref": "#/responses/User" + } + } + } + }, + "/user/actions/secrets/{secretname}": { + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Create or Update a secret value in a user scope", + "operationId": "updateUserSecret", + "parameters": [ + { + "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": [ + "user" + ], + "summary": "Delete a secret in a user scope", + "operationId": "deleteUserSecret", + "parameters": [ + { + "type": "string", + "description": "name of the secret", + "name": "secretname", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "delete one secret of the user" + }, + "400": { + "$ref": "#/responses/error" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user/applications/oauth2": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the authenticated user's oauth2 applications", + "operationId": "userGetOauth2Application", + "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/OAuth2ApplicationList" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "creates a new OAuth2 application", + "operationId": "userCreateOAuth2Application", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateOAuth2ApplicationOptions" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/OAuth2Application" + }, + "400": { + "$ref": "#/responses/error" + } + } + } + }, + "/user/applications/oauth2/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "get an OAuth2 Application", + "operationId": "userGetOAuth2Application", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "Application ID to be found", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/OAuth2Application" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "delete an OAuth2 Application", + "operationId": "userDeleteOAuth2Application", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "token to be deleted", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "patch": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "update an OAuth2 Application, this includes regenerating the client secret", + "operationId": "userUpdateOAuth2Application", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "application to be updated", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateOAuth2ApplicationOptions" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/OAuth2Application" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user/avatar": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Update Avatar", + "operationId": "userUpdateAvatar", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/UpdateUserAvatarOption" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Delete Avatar", + "operationId": "userDeleteAvatar", + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + } + }, + "/user/block/{username}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Blocks a user from the doer.", + "operationId": "userBlockUser", + "parameters": [ + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/user/emails": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the authenticated user's email addresses", + "operationId": "userListEmails", + "responses": { + "200": { + "$ref": "#/responses/EmailList" + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Add email addresses", + "operationId": "userAddEmail", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateEmailOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/EmailList" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Delete email addresses", + "operationId": "userDeleteEmail", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/DeleteEmailOption" + } + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user/followers": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the authenticated user's followers", + "operationId": "userCurrentListFollowers", + "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/UserList" + } + } + } + }, + "/user/following": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the users that the authenticated user is following", + "operationId": "userCurrentListFollowing", + "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/UserList" + } + } + } + }, + "/user/following/{username}": { + "get": { + "tags": [ + "user" + ], + "summary": "Check whether a user is followed by the authenticated user", + "operationId": "userCurrentCheckFollowing", + "parameters": [ + { + "type": "string", + "description": "username of followed user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "put": { + "tags": [ + "user" + ], + "summary": "Follow a user", + "operationId": "userCurrentPutFollow", + "parameters": [ + { + "type": "string", + "description": "username of user to follow", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "user" + ], + "summary": "Unfollow a user", + "operationId": "userCurrentDeleteFollow", + "parameters": [ + { + "type": "string", + "description": "username of user to unfollow", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user/gpg_key_token": { + "get": { + "produces": [ + "text/plain" + ], + "tags": [ + "user" + ], + "summary": "Get a Token to verify", + "operationId": "getVerificationToken", + "responses": { + "200": { + "$ref": "#/responses/string" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user/gpg_key_verify": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Verify a GPG key", + "operationId": "userVerifyGPGKey", + "responses": { + "201": { + "$ref": "#/responses/GPGKey" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/user/gpg_keys": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the authenticated user's GPG keys", + "operationId": "userCurrentListGPGKeys", + "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/GPGKeyList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Create a GPG key", + "operationId": "userCurrentPostGPGKey", + "parameters": [ + { + "name": "Form", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateGPGKeyOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/GPGKey" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/user/gpg_keys/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get a GPG key", + "operationId": "userCurrentGetGPGKey", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of key to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/GPGKey" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Remove a GPG key", + "operationId": "userCurrentDeleteGPGKey", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of key to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user/hooks": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the authenticated user's webhooks", + "operationId": "userListHooks", + "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/HookList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Create a hook", + "operationId": "userCreateHook", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateHookOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Hook" + } + } + } + }, + "/user/hooks/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get a hook", + "operationId": "userGetHook", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the hook to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/Hook" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Delete a hook", + "operationId": "userDeleteHook", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the hook to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Update a hook", + "operationId": "userEditHook", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of the hook to update", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/EditHookOption" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/Hook" + } + } + } + }, + "/user/keys": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the authenticated user's public keys", + "operationId": "userCurrentListKeys", + "parameters": [ + { + "type": "string", + "description": "fingerprint of the key", + "name": "fingerprint", + "in": "query" + }, + { + "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/PublicKeyList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Create a public key", + "operationId": "userCurrentPostKey", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateKeyOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/PublicKey" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/user/keys/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get a public key", + "operationId": "userCurrentGetKey", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of key to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/PublicKey" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Delete a public key", + "operationId": "userCurrentDeleteKey", + "parameters": [ + { + "type": "integer", + "format": "int64", + "description": "id of key to delete", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user/list_blocked": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the authenticated user's blocked users", + "operationId": "userListBlockedUsers", + "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/BlockedUserList" + } + } + } + }, + "/user/orgs": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List the current user's organizations", + "operationId": "orgListCurrentUserOrgs", + "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/OrganizationList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user/repos": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the repos that the authenticated user owns", + "operationId": "userCurrentListRepos", + "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/RepositoryList" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository", + "user" + ], + "summary": "Create a repository", + "operationId": "createCurrentUserRepo", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateRepoOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/Repository" + }, + "400": { + "$ref": "#/responses/error" + }, + "409": { + "description": "The repository with the same name already exists." + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/user/settings": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get user settings", + "operationId": "getUserSettings", + "responses": { + "200": { + "$ref": "#/responses/UserSettings" + } + } + }, + "patch": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Update user settings", + "operationId": "updateUserSettings", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/UserSettingsOptions" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserSettings" + } + } + } + }, + "/user/starred": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "The repos that the authenticated user has starred", + "operationId": "userCurrentListStarred", + "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/RepositoryList" + } + } + } + }, + "/user/starred/{owner}/{repo}": { + "get": { + "tags": [ + "user" + ], + "summary": "Whether the authenticated is starring the repo", + "operationId": "userCurrentCheckStarring", + "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" + } + } + }, + "put": { + "tags": [ + "user" + ], + "summary": "Star the given repo", + "operationId": "userCurrentPutStar", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to star", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to star", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + }, + "delete": { + "tags": [ + "user" + ], + "summary": "Unstar the given repo", + "operationId": "userCurrentDeleteStar", + "parameters": [ + { + "type": "string", + "description": "owner of the repo to unstar", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo to unstar", + "name": "repo", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/user/stopwatches": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get list of all existing stopwatches", + "operationId": "userGetStopWatches", + "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/StopWatchList" + } + } + } + }, + "/user/subscriptions": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List repositories watched by the authenticated user", + "operationId": "userCurrentListSubscriptions", + "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/RepositoryList" + } + } + } + }, + "/user/teams": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List all the teams a user belongs to", + "operationId": "userListTeams", + "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/TeamList" + } + } + } + }, + "/user/times": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the current user's tracked times", + "operationId": "userCurrentTrackedTimes", + "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" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show times updated after the given time. This is a timestamp in RFC 3339 format", + "name": "since", + "in": "query" + }, + { + "type": "string", + "format": "date-time", + "description": "Only show times updated before the given time. This is a timestamp in RFC 3339 format", + "name": "before", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/TrackedTimeList" + } + } + } + }, + "/user/unblock/{username}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Unblocks a user from the doer.", + "operationId": "userUnblockUser", + "parameters": [ + { + "type": "string", + "description": "username of the user", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/users/search": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Search for users", + "operationId": "userSearch", + "parameters": [ + { + "type": "string", + "description": "keyword", + "name": "q", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "ID of the user to search for", + "name": "uid", + "in": "query" + }, + { + "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": { + "description": "SearchResults of a successful search", + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + }, + "ok": { + "type": "boolean" + } + } + } + } + } + } + }, + "/users/{username}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get a user", + "operationId": "userGet", + "parameters": [ + { + "type": "string", + "description": "username of user to get", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/User" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/activities/feeds": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List a user's activity feeds", + "operationId": "userListActivityFeeds", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "if true, only show actions performed by the requested user", + "name": "only-performed-by", + "in": "query" + }, + { + "type": "string", + "format": "date", + "description": "the date of the activities to be found", + "name": "date", + "in": "query" + }, + { + "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/ActivityFeedsList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/followers": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the given user's followers", + "operationId": "userListFollowers", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "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/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/following": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the users that the given user is following", + "operationId": "userListFollowing", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "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/UserList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/following/{target}": { + "get": { + "tags": [ + "user" + ], + "summary": "Check if one user is following another user", + "operationId": "userCheckFollowing", + "parameters": [ + { + "type": "string", + "description": "username of following user", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "username of followed user", + "name": "target", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/gpg_keys": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the given user's GPG keys", + "operationId": "userListGPGKeys", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "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/GPGKeyList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/heatmap": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get a user's heatmap", + "operationId": "userGetHeatmapData", + "parameters": [ + { + "type": "string", + "description": "username of user to get", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserHeatmapData" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/keys": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the given user's public keys", + "operationId": "userListKeys", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "fingerprint of the key", + "name": "fingerprint", + "in": "query" + }, + { + "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/PublicKeyList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/orgs": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "List a user's organizations", + "operationId": "orgListUserOrgs", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "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/OrganizationList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/orgs/{org}/permissions": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "organization" + ], + "summary": "Get user permissions in organization", + "operationId": "orgGetUserPermissions", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the organization", + "name": "org", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/OrganizationPermissions" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/repos": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the repos owned by the given user", + "operationId": "userListRepos", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "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/RepositoryList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/starred": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "The repos that the given user has starred", + "operationId": "userListStarred", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "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/RepositoryList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/subscriptions": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the repositories watched by a user", + "operationId": "userListSubscriptions", + "parameters": [ + { + "type": "string", + "description": "username of the user", + "name": "username", + "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/RepositoryList" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/users/{username}/tokens": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "List the authenticated user's access tokens", + "operationId": "userGetTokens", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "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/AccessTokenList" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Create an access token", + "operationId": "userCreateToken", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/CreateAccessTokenOption" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/AccessToken" + }, + "400": { + "$ref": "#/responses/error" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, + "/users/{username}/tokens/{token}": { + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "delete an access token", + "operationId": "userDeleteAccessToken", + "parameters": [ + { + "type": "string", + "description": "username of user", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "token to be deleted, identified by ID and if not available by name", + "name": "token", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "$ref": "#/responses/empty" + }, + "403": { + "$ref": "#/responses/forbidden" + }, + "404": { + "$ref": "#/responses/notFound" + }, + "422": { + "$ref": "#/responses/error" + } + } + } + }, + "/version": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "miscellaneous" + ], + "summary": "Returns the version of the Gitea application", + "operationId": "getVersion", + "responses": { + "200": { + "$ref": "#/responses/ServerVersion" + } + } + } + } + }, + "definitions": { + "APIError": { + "description": "APIError is an api error with a message", + "type": "object", + "properties": { + "message": { + "type": "string", + "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" + }, + "Activity": { + "type": "object", + "properties": { + "act_user": { + "$ref": "#/definitions/User" + }, + "act_user_id": { + "type": "integer", + "format": "int64", + "x-go-name": "ActUserID" + }, + "comment": { + "$ref": "#/definitions/Comment" + }, + "comment_id": { + "type": "integer", + "format": "int64", + "x-go-name": "CommentID" + }, + "content": { + "type": "string", + "x-go-name": "Content" + }, + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "is_private": { + "type": "boolean", + "x-go-name": "IsPrivate" + }, + "op_type": { + "type": "string", + "x-go-name": "OpType" + }, + "ref_name": { + "type": "string", + "x-go-name": "RefName" + }, + "repo": { + "$ref": "#/definitions/Repository" + }, + "repo_id": { + "type": "integer", + "format": "int64", + "x-go-name": "RepoID" + }, + "user_id": { + "type": "integer", + "format": "int64", + "x-go-name": "UserID" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ActivityPub": { + "description": "ActivityPub type", + "type": "object", + "properties": { + "@context": { + "type": "string", + "x-go-name": "Context" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "AddCollaboratorOption": { + "description": "AddCollaboratorOption options when adding a user as a collaborator of a repository", + "type": "object", + "properties": { + "permission": { + "type": "string", + "x-go-name": "Permission" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "AddTimeOption": { + "description": "AddTimeOption options for adding time to an issue", + "type": "object", + "required": [ + "time" + ], + "properties": { + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "time": { + "description": "time in seconds", + "type": "integer", + "format": "int64", + "x-go-name": "Time" + }, + "user_name": { + "description": "User who spent the time (optional)", + "type": "string", + "x-go-name": "User" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "AnnotatedTag": { + "description": "AnnotatedTag represents an annotated tag", + "type": "object", + "properties": { + "message": { + "type": "string", + "x-go-name": "Message" + }, + "object": { + "$ref": "#/definitions/AnnotatedTagObject" + }, + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "tag": { + "type": "string", + "x-go-name": "Tag" + }, + "tagger": { + "$ref": "#/definitions/CommitUser" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "verification": { + "$ref": "#/definitions/PayloadCommitVerification" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "AnnotatedTagObject": { + "description": "AnnotatedTagObject contains meta information of the tag object", + "type": "object", + "properties": { + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Attachment": { + "description": "Attachment a generic attachment", + "type": "object", + "properties": { + "browser_download_url": { + "type": "string", + "x-go-name": "DownloadURL" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "download_count": { + "type": "integer", + "format": "int64", + "x-go-name": "DownloadCount" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "size": { + "type": "integer", + "format": "int64", + "x-go-name": "Size" + }, + "uuid": { + "type": "string", + "x-go-name": "UUID" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "BlockedUser": { + "type": "object", + "title": "BlockedUser represents a blocked user.", + "properties": { + "block_id": { + "type": "integer", + "format": "int64", + "x-go-name": "BlockID" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Branch": { + "description": "Branch represents a repository branch", + "type": "object", + "properties": { + "commit": { + "$ref": "#/definitions/PayloadCommit" + }, + "effective_branch_protection_name": { + "type": "string", + "x-go-name": "EffectiveBranchProtectionName" + }, + "enable_status_check": { + "type": "boolean", + "x-go-name": "EnableStatusCheck" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "protected": { + "type": "boolean", + "x-go-name": "Protected" + }, + "required_approvals": { + "type": "integer", + "format": "int64", + "x-go-name": "RequiredApprovals" + }, + "status_check_contexts": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "StatusCheckContexts" + }, + "user_can_merge": { + "type": "boolean", + "x-go-name": "UserCanMerge" + }, + "user_can_push": { + "type": "boolean", + "x-go-name": "UserCanPush" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "BranchProtection": { + "description": "BranchProtection represents a branch protection for a repository", + "type": "object", + "properties": { + "approvals_whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "ApprovalsWhitelistTeams" + }, + "approvals_whitelist_username": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "ApprovalsWhitelistUsernames" + }, + "block_on_official_review_requests": { + "type": "boolean", + "x-go-name": "BlockOnOfficialReviewRequests" + }, + "block_on_outdated_branch": { + "type": "boolean", + "x-go-name": "BlockOnOutdatedBranch" + }, + "block_on_rejected_reviews": { + "type": "boolean", + "x-go-name": "BlockOnRejectedReviews" + }, + "branch_name": { + "description": "Deprecated: true", + "type": "string", + "x-go-name": "BranchName" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "dismiss_stale_approvals": { + "type": "boolean", + "x-go-name": "DismissStaleApprovals" + }, + "enable_approvals_whitelist": { + "type": "boolean", + "x-go-name": "EnableApprovalsWhitelist" + }, + "enable_merge_whitelist": { + "type": "boolean", + "x-go-name": "EnableMergeWhitelist" + }, + "enable_push": { + "type": "boolean", + "x-go-name": "EnablePush" + }, + "enable_push_whitelist": { + "type": "boolean", + "x-go-name": "EnablePushWhitelist" + }, + "enable_status_check": { + "type": "boolean", + "x-go-name": "EnableStatusCheck" + }, + "merge_whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "MergeWhitelistTeams" + }, + "merge_whitelist_usernames": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "MergeWhitelistUsernames" + }, + "protected_file_patterns": { + "type": "string", + "x-go-name": "ProtectedFilePatterns" + }, + "push_whitelist_deploy_keys": { + "type": "boolean", + "x-go-name": "PushWhitelistDeployKeys" + }, + "push_whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "PushWhitelistTeams" + }, + "push_whitelist_usernames": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "PushWhitelistUsernames" + }, + "require_signed_commits": { + "type": "boolean", + "x-go-name": "RequireSignedCommits" + }, + "required_approvals": { + "type": "integer", + "format": "int64", + "x-go-name": "RequiredApprovals" + }, + "rule_name": { + "type": "string", + "x-go-name": "RuleName" + }, + "status_check_contexts": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "StatusCheckContexts" + }, + "unprotected_file_patterns": { + "type": "string", + "x-go-name": "UnprotectedFilePatterns" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ChangeFileOperation": { + "description": "ChangeFileOperation for creating, updating or deleting a file", + "type": "object", + "required": [ + "operation", + "path" + ], + "properties": { + "content": { + "description": "new or updated file content, must be base64 encoded", + "type": "string", + "x-go-name": "ContentBase64" + }, + "from_path": { + "description": "old path of the file to move", + "type": "string", + "x-go-name": "FromPath" + }, + "operation": { + "description": "indicates what to do with the file", + "type": "string", + "enum": [ + "create", + "update", + "delete" + ], + "x-go-name": "Operation" + }, + "path": { + "description": "path to the existing or new file", + "type": "string", + "x-go-name": "Path" + }, + "sha": { + "description": "sha is the SHA for the file that already exists, required for update or delete", + "type": "string", + "x-go-name": "SHA" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ChangeFilesOptions": { + "description": "ChangeFilesOptions options for creating, updating or deleting multiple files\nNote: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", + "type": "object", + "required": [ + "files" + ], + "properties": { + "author": { + "$ref": "#/definitions/Identity" + }, + "branch": { + "description": "branch (optional) to base this file from. if not given, the default branch is used", + "type": "string", + "x-go-name": "BranchName" + }, + "committer": { + "$ref": "#/definitions/Identity" + }, + "dates": { + "$ref": "#/definitions/CommitDateOptions" + }, + "files": { + "description": "list of file operations", + "type": "array", + "items": { + "$ref": "#/definitions/ChangeFileOperation" + }, + "x-go-name": "Files" + }, + "message": { + "description": "message (optional) for the commit of this file. if not supplied, a default message will be used", + "type": "string", + "x-go-name": "Message" + }, + "new_branch": { + "description": "new_branch (optional) will make a new branch from `branch` before creating the file", + "type": "string", + "x-go-name": "NewBranchName" + }, + "signoff": { + "description": "Add a Signed-off-by trailer by the committer at the end of the commit log message.", + "type": "boolean", + "x-go-name": "Signoff" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ChangedFile": { + "description": "ChangedFile store information about files affected by the pull request", + "type": "object", + "properties": { + "additions": { + "type": "integer", + "format": "int64", + "x-go-name": "Additions" + }, + "changes": { + "type": "integer", + "format": "int64", + "x-go-name": "Changes" + }, + "contents_url": { + "type": "string", + "x-go-name": "ContentsURL" + }, + "deletions": { + "type": "integer", + "format": "int64", + "x-go-name": "Deletions" + }, + "filename": { + "type": "string", + "x-go-name": "Filename" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "previous_filename": { + "type": "string", + "x-go-name": "PreviousFilename" + }, + "raw_url": { + "type": "string", + "x-go-name": "RawURL" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CombinedStatus": { + "description": "CombinedStatus holds the combined state of several statuses for a single commit", + "type": "object", + "properties": { + "commit_url": { + "type": "string", + "x-go-name": "CommitURL" + }, + "repository": { + "$ref": "#/definitions/Repository" + }, + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "state": { + "$ref": "#/definitions/CommitStatusState" + }, + "statuses": { + "type": "array", + "items": { + "$ref": "#/definitions/CommitStatus" + }, + "x-go-name": "Statuses" + }, + "total_count": { + "type": "integer", + "format": "int64", + "x-go-name": "TotalCount" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Comment": { + "description": "Comment represents a comment on a commit or issue", + "type": "object", + "properties": { + "assets": { + "type": "array", + "items": { + "$ref": "#/definitions/Attachment" + }, + "x-go-name": "Attachments" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "issue_url": { + "type": "string", + "x-go-name": "IssueURL" + }, + "original_author": { + "type": "string", + "x-go-name": "OriginalAuthor" + }, + "original_author_id": { + "type": "integer", + "format": "int64", + "x-go-name": "OriginalAuthorID" + }, + "pull_request_url": { + "type": "string", + "x-go-name": "PRURL" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Commit": { + "type": "object", + "title": "Commit contains information generated from a Git commit.", + "properties": { + "author": { + "$ref": "#/definitions/User" + }, + "commit": { + "$ref": "#/definitions/RepoCommit" + }, + "committer": { + "$ref": "#/definitions/User" + }, + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "files": { + "type": "array", + "items": { + "$ref": "#/definitions/CommitAffectedFiles" + }, + "x-go-name": "Files" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "parents": { + "type": "array", + "items": { + "$ref": "#/definitions/CommitMeta" + }, + "x-go-name": "Parents" + }, + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "stats": { + "$ref": "#/definitions/CommitStats" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CommitAffectedFiles": { + "description": "CommitAffectedFiles store information about files affected by the commit", + "type": "object", + "properties": { + "filename": { + "type": "string", + "x-go-name": "Filename" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CommitDateOptions": { + "description": "CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE", + "type": "object", + "properties": { + "author": { + "type": "string", + "format": "date-time", + "x-go-name": "Author" + }, + "committer": { + "type": "string", + "format": "date-time", + "x-go-name": "Committer" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CommitMeta": { + "type": "object", + "title": "CommitMeta contains meta information of a commit in terms of API.", + "properties": { + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CommitStats": { + "description": "CommitStats is statistics for a RepoCommit", + "type": "object", + "properties": { + "additions": { + "type": "integer", + "format": "int64", + "x-go-name": "Additions" + }, + "deletions": { + "type": "integer", + "format": "int64", + "x-go-name": "Deletions" + }, + "total": { + "type": "integer", + "format": "int64", + "x-go-name": "Total" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CommitStatus": { + "description": "CommitStatus holds a single status of a single Commit", + "type": "object", + "properties": { + "context": { + "type": "string", + "x-go-name": "Context" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "creator": { + "$ref": "#/definitions/User" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "status": { + "$ref": "#/definitions/CommitStatusState" + }, + "target_url": { + "type": "string", + "x-go-name": "TargetURL" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CommitStatusState": { + "description": "CommitStatusState holds the state of a CommitStatus\nIt can be \"pending\", \"success\", \"error\" and \"failure\"", + "type": "string", + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CommitUser": { + "type": "object", + "title": "CommitUser contains information of a user in the context of a commit.", + "properties": { + "date": { + "type": "string", + "x-go-name": "Date" + }, + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "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", + "properties": { + "_links": { + "$ref": "#/definitions/FileLinksResponse" + }, + "content": { + "description": "`content` is populated when `type` is `file`, otherwise null", + "type": "string", + "x-go-name": "Content" + }, + "download_url": { + "type": "string", + "x-go-name": "DownloadURL" + }, + "encoding": { + "description": "`encoding` is populated when `type` is `file`, otherwise null", + "type": "string", + "x-go-name": "Encoding" + }, + "git_url": { + "type": "string", + "x-go-name": "GitURL" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "last_commit_sha": { + "type": "string", + "x-go-name": "LastCommitSHA" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "path": { + "type": "string", + "x-go-name": "Path" + }, + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "size": { + "type": "integer", + "format": "int64", + "x-go-name": "Size" + }, + "submodule_git_url": { + "description": "`submodule_git_url` is populated when `type` is `submodule`, otherwise null", + "type": "string", + "x-go-name": "SubmoduleGitURL" + }, + "target": { + "description": "`target` is populated when `type` is `symlink`, otherwise null", + "type": "string", + "x-go-name": "Target" + }, + "type": { + "description": "`type` will be `file`, `dir`, `symlink`, or `submodule`", + "type": "string", + "x-go-name": "Type" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateAccessTokenOption": { + "description": "CreateAccessTokenOption options when create access token", + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string", + "x-go-name": "Name" + }, + "scopes": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Scopes" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateBranchProtectionOption": { + "description": "CreateBranchProtectionOption options for creating a branch protection", + "type": "object", + "properties": { + "approvals_whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "ApprovalsWhitelistTeams" + }, + "approvals_whitelist_username": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "ApprovalsWhitelistUsernames" + }, + "block_on_official_review_requests": { + "type": "boolean", + "x-go-name": "BlockOnOfficialReviewRequests" + }, + "block_on_outdated_branch": { + "type": "boolean", + "x-go-name": "BlockOnOutdatedBranch" + }, + "block_on_rejected_reviews": { + "type": "boolean", + "x-go-name": "BlockOnRejectedReviews" + }, + "branch_name": { + "description": "Deprecated: true", + "type": "string", + "x-go-name": "BranchName" + }, + "dismiss_stale_approvals": { + "type": "boolean", + "x-go-name": "DismissStaleApprovals" + }, + "enable_approvals_whitelist": { + "type": "boolean", + "x-go-name": "EnableApprovalsWhitelist" + }, + "enable_merge_whitelist": { + "type": "boolean", + "x-go-name": "EnableMergeWhitelist" + }, + "enable_push": { + "type": "boolean", + "x-go-name": "EnablePush" + }, + "enable_push_whitelist": { + "type": "boolean", + "x-go-name": "EnablePushWhitelist" + }, + "enable_status_check": { + "type": "boolean", + "x-go-name": "EnableStatusCheck" + }, + "merge_whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "MergeWhitelistTeams" + }, + "merge_whitelist_usernames": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "MergeWhitelistUsernames" + }, + "protected_file_patterns": { + "type": "string", + "x-go-name": "ProtectedFilePatterns" + }, + "push_whitelist_deploy_keys": { + "type": "boolean", + "x-go-name": "PushWhitelistDeployKeys" + }, + "push_whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "PushWhitelistTeams" + }, + "push_whitelist_usernames": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "PushWhitelistUsernames" + }, + "require_signed_commits": { + "type": "boolean", + "x-go-name": "RequireSignedCommits" + }, + "required_approvals": { + "type": "integer", + "format": "int64", + "x-go-name": "RequiredApprovals" + }, + "rule_name": { + "type": "string", + "x-go-name": "RuleName" + }, + "status_check_contexts": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "StatusCheckContexts" + }, + "unprotected_file_patterns": { + "type": "string", + "x-go-name": "UnprotectedFilePatterns" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateBranchRepoOption": { + "description": "CreateBranchRepoOption options when creating a branch in a repository", + "type": "object", + "required": [ + "new_branch_name" + ], + "properties": { + "new_branch_name": { + "description": "Name of the branch to create", + "type": "string", + "uniqueItems": true, + "x-go-name": "BranchName" + }, + "old_branch_name": { + "description": "Deprecated: true\nName of the old branch to create from", + "type": "string", + "uniqueItems": true, + "x-go-name": "OldBranchName" + }, + "old_ref_name": { + "description": "Name of the old branch/tag/commit to create from", + "type": "string", + "uniqueItems": true, + "x-go-name": "OldRefName" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateEmailOption": { + "description": "CreateEmailOption options when creating email addresses", + "type": "object", + "properties": { + "emails": { + "description": "email addresses to add", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Emails" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateFileOptions": { + "description": "CreateFileOptions options for creating files\nNote: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", + "type": "object", + "required": [ + "content" + ], + "properties": { + "author": { + "$ref": "#/definitions/Identity" + }, + "branch": { + "description": "branch (optional) to base this file from. if not given, the default branch is used", + "type": "string", + "x-go-name": "BranchName" + }, + "committer": { + "$ref": "#/definitions/Identity" + }, + "content": { + "description": "content must be base64 encoded", + "type": "string", + "x-go-name": "ContentBase64" + }, + "dates": { + "$ref": "#/definitions/CommitDateOptions" + }, + "message": { + "description": "message (optional) for the commit of this file. if not supplied, a default message will be used", + "type": "string", + "x-go-name": "Message" + }, + "new_branch": { + "description": "new_branch (optional) will make a new branch from `branch` before creating the file", + "type": "string", + "x-go-name": "NewBranchName" + }, + "signoff": { + "description": "Add a Signed-off-by trailer by the committer at the end of the commit log message.", + "type": "boolean", + "x-go-name": "Signoff" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateForkOption": { + "description": "CreateForkOption options for creating a fork", + "type": "object", + "properties": { + "name": { + "description": "name of the forked repository", + "type": "string", + "x-go-name": "Name" + }, + "organization": { + "description": "organization name, if forking into an organization", + "type": "string", + "x-go-name": "Organization" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateGPGKeyOption": { + "description": "CreateGPGKeyOption options create user GPG key", + "type": "object", + "required": [ + "armored_public_key" + ], + "properties": { + "armored_public_key": { + "description": "An armored GPG key to add", + "type": "string", + "uniqueItems": true, + "x-go-name": "ArmoredKey" + }, + "armored_signature": { + "type": "string", + "x-go-name": "Signature" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateHookOption": { + "description": "CreateHookOption options when create a hook", + "type": "object", + "required": [ + "type", + "config" + ], + "properties": { + "active": { + "type": "boolean", + "default": false, + "x-go-name": "Active" + }, + "authorization_header": { + "type": "string", + "x-go-name": "AuthorizationHeader" + }, + "branch_filter": { + "type": "string", + "x-go-name": "BranchFilter" + }, + "config": { + "$ref": "#/definitions/CreateHookOptionConfig" + }, + "events": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Events" + }, + "type": { + "type": "string", + "enum": [ + "forgejo", + "dingtalk", + "discord", + "gitea", + "gogs", + "msteams", + "slack", + "telegram", + "feishu", + "wechatwork", + "packagist" + ], + "x-go-name": "Type" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateHookOptionConfig": { + "description": "CreateHookOptionConfig has all config options in it\nrequired are \"content_type\" and \"url\" Required", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateIssueCommentOption": { + "description": "CreateIssueCommentOption options for creating a comment on an issue", + "type": "object", + "required": [ + "body" + ], + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateIssueOption": { + "description": "CreateIssueOption options to create one issue", + "type": "object", + "required": [ + "title" + ], + "properties": { + "assignee": { + "description": "deprecated", + "type": "string", + "x-go-name": "Assignee" + }, + "assignees": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Assignees" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "closed": { + "type": "boolean", + "x-go-name": "Closed" + }, + "due_date": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "labels": { + "description": "list of label ids", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "x-go-name": "Labels" + }, + "milestone": { + "description": "milestone id", + "type": "integer", + "format": "int64", + "x-go-name": "Milestone" + }, + "ref": { + "type": "string", + "x-go-name": "Ref" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateKeyOption": { + "description": "CreateKeyOption options when creating a key", + "type": "object", + "required": [ + "title", + "key" + ], + "properties": { + "key": { + "description": "An armored SSH key to add", + "type": "string", + "uniqueItems": true, + "x-go-name": "Key" + }, + "read_only": { + "description": "Describe if the key has only read access or read/write", + "type": "boolean", + "x-go-name": "ReadOnly" + }, + "title": { + "description": "Title of the key to add", + "type": "string", + "uniqueItems": true, + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateLabelOption": { + "description": "CreateLabelOption options for creating a label", + "type": "object", + "required": [ + "name", + "color" + ], + "properties": { + "color": { + "type": "string", + "x-go-name": "Color", + "example": "#00aabb" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "exclusive": { + "type": "boolean", + "x-go-name": "Exclusive", + "example": false + }, + "is_archived": { + "type": "boolean", + "x-go-name": "IsArchived", + "example": false + }, + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateMilestoneOption": { + "description": "CreateMilestoneOption options for creating a milestone", + "type": "object", + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "due_on": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "state": { + "type": "string", + "enum": [ + "open", + "closed" + ], + "x-go-name": "State" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateOAuth2ApplicationOptions": { + "description": "CreateOAuth2ApplicationOptions holds options to create an oauth2 application", + "type": "object", + "properties": { + "confidential_client": { + "type": "boolean", + "x-go-name": "ConfidentialClient" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "redirect_uris": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "RedirectURIs" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateOrUpdateSecretOption": { + "description": "CreateOrUpdateSecretOption options when creating or updating secret", + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "description": "Data of the secret to update", + "type": "string", + "x-go-name": "Data" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateOrgOption": { + "description": "CreateOrgOption options for creating an organization", + "type": "object", + "required": [ + "username" + ], + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "email": { + "type": "string", + "x-go-name": "Email" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "location": { + "type": "string", + "x-go-name": "Location" + }, + "repo_admin_change_team_access": { + "type": "boolean", + "x-go-name": "RepoAdminChangeTeamAccess" + }, + "username": { + "type": "string", + "x-go-name": "UserName" + }, + "visibility": { + "description": "possible values are `public` (default), `limited` or `private`", + "type": "string", + "enum": [ + "public", + "limited", + "private" + ], + "x-go-name": "Visibility" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreatePullRequestOption": { + "description": "CreatePullRequestOption options when creating a pull request", + "type": "object", + "properties": { + "assignee": { + "type": "string", + "x-go-name": "Assignee" + }, + "assignees": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Assignees" + }, + "base": { + "type": "string", + "x-go-name": "Base" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "due_date": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "head": { + "type": "string", + "x-go-name": "Head" + }, + "labels": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "x-go-name": "Labels" + }, + "milestone": { + "type": "integer", + "format": "int64", + "x-go-name": "Milestone" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreatePullReviewComment": { + "description": "CreatePullReviewComment represent a review comment for creation api", + "type": "object", + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + }, + "new_position": { + "description": "if comment to new file line or 0", + "type": "integer", + "format": "int64", + "x-go-name": "NewLineNum" + }, + "old_position": { + "description": "if comment to old file line or 0", + "type": "integer", + "format": "int64", + "x-go-name": "OldLineNum" + }, + "path": { + "description": "the tree path", + "type": "string", + "x-go-name": "Path" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreatePullReviewOptions": { + "description": "CreatePullReviewOptions are options to create a pull review", + "type": "object", + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + }, + "comments": { + "type": "array", + "items": { + "$ref": "#/definitions/CreatePullReviewComment" + }, + "x-go-name": "Comments" + }, + "commit_id": { + "type": "string", + "x-go-name": "CommitID" + }, + "event": { + "$ref": "#/definitions/ReviewStateType" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreatePushMirrorOption": { + "type": "object", + "title": "CreatePushMirrorOption represents need information to create a push mirror of a repository.", + "properties": { + "interval": { + "type": "string", + "x-go-name": "Interval" + }, + "remote_address": { + "type": "string", + "x-go-name": "RemoteAddress" + }, + "remote_password": { + "type": "string", + "x-go-name": "RemotePassword" + }, + "remote_username": { + "type": "string", + "x-go-name": "RemoteUsername" + }, + "sync_on_commit": { + "type": "boolean", + "x-go-name": "SyncOnCommit" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateReleaseOption": { + "description": "CreateReleaseOption options when creating a release", + "type": "object", + "required": [ + "tag_name" + ], + "properties": { + "body": { + "type": "string", + "x-go-name": "Note" + }, + "draft": { + "type": "boolean", + "x-go-name": "IsDraft" + }, + "name": { + "type": "string", + "x-go-name": "Title" + }, + "prerelease": { + "type": "boolean", + "x-go-name": "IsPrerelease" + }, + "tag_name": { + "type": "string", + "x-go-name": "TagName" + }, + "target_commitish": { + "type": "string", + "x-go-name": "Target" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateRepoOption": { + "description": "CreateRepoOption options when creating repository", + "type": "object", + "required": [ + "name" + ], + "properties": { + "auto_init": { + "description": "Whether the repository should be auto-initialized?", + "type": "boolean", + "x-go-name": "AutoInit" + }, + "default_branch": { + "description": "DefaultBranch of the repository (used when initializes and in template)", + "type": "string", + "x-go-name": "DefaultBranch" + }, + "description": { + "description": "Description of the repository to create", + "type": "string", + "x-go-name": "Description" + }, + "gitignores": { + "description": "Gitignores to use", + "type": "string", + "x-go-name": "Gitignores" + }, + "issue_labels": { + "description": "Label-Set to use", + "type": "string", + "x-go-name": "IssueLabels" + }, + "license": { + "description": "License to use", + "type": "string", + "x-go-name": "License" + }, + "name": { + "description": "Name of the repository to create", + "type": "string", + "uniqueItems": true, + "x-go-name": "Name" + }, + "private": { + "description": "Whether the repository is private", + "type": "boolean", + "x-go-name": "Private" + }, + "readme": { + "description": "Readme of the repository to create", + "type": "string", + "x-go-name": "Readme" + }, + "template": { + "description": "Whether the repository is template", + "type": "boolean", + "x-go-name": "Template" + }, + "trust_model": { + "description": "TrustModel of the repository", + "type": "string", + "enum": [ + "default", + "collaborator", + "committer", + "collaboratorcommitter" + ], + "x-go-name": "TrustModel" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateStatusOption": { + "description": "CreateStatusOption holds the information needed to create a new CommitStatus for a Commit", + "type": "object", + "properties": { + "context": { + "type": "string", + "x-go-name": "Context" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "state": { + "$ref": "#/definitions/CommitStatusState" + }, + "target_url": { + "type": "string", + "x-go-name": "TargetURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateTagOption": { + "description": "CreateTagOption options when creating a tag", + "type": "object", + "required": [ + "tag_name" + ], + "properties": { + "message": { + "type": "string", + "x-go-name": "Message" + }, + "tag_name": { + "type": "string", + "x-go-name": "TagName" + }, + "target": { + "type": "string", + "x-go-name": "Target" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateTeamOption": { + "description": "CreateTeamOption options for creating a team", + "type": "object", + "required": [ + "name" + ], + "properties": { + "can_create_org_repo": { + "type": "boolean", + "x-go-name": "CanCreateOrgRepo" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "includes_all_repositories": { + "type": "boolean", + "x-go-name": "IncludesAllRepositories" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "permission": { + "type": "string", + "enum": [ + "read", + "write", + "admin" + ], + "x-go-name": "Permission" + }, + "units": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Units", + "example": [ + "repo.actions", + "repo.code", + "repo.issues", + "repo.ext_issues", + "repo.wiki", + "repo.ext_wiki", + "repo.pulls", + "repo.releases", + "repo.projects", + "repo.ext_wiki" + ] + }, + "units_map": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "UnitsMap", + "example": "{\"repo.actions\",\"repo.packages\",\"repo.code\":\"read\",\"repo.issues\":\"write\",\"repo.ext_issues\":\"none\",\"repo.wiki\":\"admin\",\"repo.pulls\":\"owner\",\"repo.releases\":\"none\",\"repo.projects\":\"none\",\"repo.ext_wiki\":\"none\"}" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateUserOption": { + "description": "CreateUserOption create user options", + "type": "object", + "required": [ + "username", + "email" + ], + "properties": { + "created_at": { + "description": "For explicitly setting the user creation timestamp. Useful when users are\nmigrated from other systems. When omitted, the user's creation timestamp\nwill be set to \"now\".", + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "login_name": { + "type": "string", + "x-go-name": "LoginName" + }, + "must_change_password": { + "type": "boolean", + "x-go-name": "MustChangePassword" + }, + "password": { + "type": "string", + "x-go-name": "Password" + }, + "restricted": { + "type": "boolean", + "x-go-name": "Restricted" + }, + "send_notify": { + "type": "boolean", + "x-go-name": "SendNotify" + }, + "source_id": { + "type": "integer", + "format": "int64", + "x-go-name": "SourceID" + }, + "username": { + "type": "string", + "x-go-name": "Username" + }, + "visibility": { + "type": "string", + "x-go-name": "Visibility" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CreateWikiPageOptions": { + "description": "CreateWikiPageOptions form for creating wiki", + "type": "object", + "properties": { + "content_base64": { + "description": "content must be base64 encoded", + "type": "string", + "x-go-name": "ContentBase64" + }, + "message": { + "description": "optional commit message summarizing the change", + "type": "string", + "x-go-name": "Message" + }, + "title": { + "description": "page title. leave empty to keep unchanged", + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Cron": { + "description": "Cron represents a Cron task", + "type": "object", + "properties": { + "exec_times": { + "type": "integer", + "format": "int64", + "x-go-name": "ExecTimes" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "next": { + "type": "string", + "format": "date-time", + "x-go-name": "Next" + }, + "prev": { + "type": "string", + "format": "date-time", + "x-go-name": "Prev" + }, + "schedule": { + "type": "string", + "x-go-name": "Schedule" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "DeleteEmailOption": { + "description": "DeleteEmailOption options when deleting email addresses", + "type": "object", + "properties": { + "emails": { + "description": "email addresses to delete", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Emails" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "DeleteFileOptions": { + "description": "DeleteFileOptions options for deleting files (used for other File structs below)\nNote: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", + "type": "object", + "required": [ + "sha" + ], + "properties": { + "author": { + "$ref": "#/definitions/Identity" + }, + "branch": { + "description": "branch (optional) to base this file from. if not given, the default branch is used", + "type": "string", + "x-go-name": "BranchName" + }, + "committer": { + "$ref": "#/definitions/Identity" + }, + "dates": { + "$ref": "#/definitions/CommitDateOptions" + }, + "message": { + "description": "message (optional) for the commit of this file. if not supplied, a default message will be used", + "type": "string", + "x-go-name": "Message" + }, + "new_branch": { + "description": "new_branch (optional) will make a new branch from `branch` before creating the file", + "type": "string", + "x-go-name": "NewBranchName" + }, + "sha": { + "description": "sha is the SHA for the file that already exists", + "type": "string", + "x-go-name": "SHA" + }, + "signoff": { + "description": "Add a Signed-off-by trailer by the committer at the end of the commit log message.", + "type": "boolean", + "x-go-name": "Signoff" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "DeleteLabelsOption": { + "description": "DeleteLabelOption options for deleting a label", + "type": "object", + "properties": { + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "DeployKey": { + "description": "DeployKey a deploy key", + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "fingerprint": { + "type": "string", + "x-go-name": "Fingerprint" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "key": { + "type": "string", + "x-go-name": "Key" + }, + "key_id": { + "type": "integer", + "format": "int64", + "x-go-name": "KeyID" + }, + "read_only": { + "type": "boolean", + "x-go-name": "ReadOnly" + }, + "repository": { + "$ref": "#/definitions/Repository" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "DismissPullReviewOptions": { + "description": "DismissPullReviewOptions are options to dismiss a pull review", + "type": "object", + "properties": { + "message": { + "type": "string", + "x-go-name": "Message" + }, + "priors": { + "type": "boolean", + "x-go-name": "Priors" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditAttachmentOptions": { + "description": "EditAttachmentOptions options for editing attachments", + "type": "object", + "properties": { + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditBranchProtectionOption": { + "description": "EditBranchProtectionOption options for editing a branch protection", + "type": "object", + "properties": { + "approvals_whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "ApprovalsWhitelistTeams" + }, + "approvals_whitelist_username": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "ApprovalsWhitelistUsernames" + }, + "block_on_official_review_requests": { + "type": "boolean", + "x-go-name": "BlockOnOfficialReviewRequests" + }, + "block_on_outdated_branch": { + "type": "boolean", + "x-go-name": "BlockOnOutdatedBranch" + }, + "block_on_rejected_reviews": { + "type": "boolean", + "x-go-name": "BlockOnRejectedReviews" + }, + "dismiss_stale_approvals": { + "type": "boolean", + "x-go-name": "DismissStaleApprovals" + }, + "enable_approvals_whitelist": { + "type": "boolean", + "x-go-name": "EnableApprovalsWhitelist" + }, + "enable_merge_whitelist": { + "type": "boolean", + "x-go-name": "EnableMergeWhitelist" + }, + "enable_push": { + "type": "boolean", + "x-go-name": "EnablePush" + }, + "enable_push_whitelist": { + "type": "boolean", + "x-go-name": "EnablePushWhitelist" + }, + "enable_status_check": { + "type": "boolean", + "x-go-name": "EnableStatusCheck" + }, + "merge_whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "MergeWhitelistTeams" + }, + "merge_whitelist_usernames": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "MergeWhitelistUsernames" + }, + "protected_file_patterns": { + "type": "string", + "x-go-name": "ProtectedFilePatterns" + }, + "push_whitelist_deploy_keys": { + "type": "boolean", + "x-go-name": "PushWhitelistDeployKeys" + }, + "push_whitelist_teams": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "PushWhitelistTeams" + }, + "push_whitelist_usernames": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "PushWhitelistUsernames" + }, + "require_signed_commits": { + "type": "boolean", + "x-go-name": "RequireSignedCommits" + }, + "required_approvals": { + "type": "integer", + "format": "int64", + "x-go-name": "RequiredApprovals" + }, + "status_check_contexts": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "StatusCheckContexts" + }, + "unprotected_file_patterns": { + "type": "string", + "x-go-name": "UnprotectedFilePatterns" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditDeadlineOption": { + "description": "EditDeadlineOption options for creating a deadline", + "type": "object", + "required": [ + "due_date" + ], + "properties": { + "due_date": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditGitHookOption": { + "description": "EditGitHookOption options when modifying one Git hook", + "type": "object", + "properties": { + "content": { + "type": "string", + "x-go-name": "Content" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditHookOption": { + "description": "EditHookOption options when modify one hook", + "type": "object", + "properties": { + "active": { + "type": "boolean", + "x-go-name": "Active" + }, + "authorization_header": { + "type": "string", + "x-go-name": "AuthorizationHeader" + }, + "branch_filter": { + "type": "string", + "x-go-name": "BranchFilter" + }, + "config": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Config" + }, + "events": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Events" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditIssueCommentOption": { + "description": "EditIssueCommentOption options for editing a comment", + "type": "object", + "required": [ + "body" + ], + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditIssueOption": { + "description": "EditIssueOption options for editing an issue", + "type": "object", + "properties": { + "assignee": { + "description": "deprecated", + "type": "string", + "x-go-name": "Assignee" + }, + "assignees": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Assignees" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "due_date": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "milestone": { + "type": "integer", + "format": "int64", + "x-go-name": "Milestone" + }, + "ref": { + "type": "string", + "x-go-name": "Ref" + }, + "state": { + "type": "string", + "x-go-name": "State" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "unset_due_date": { + "type": "boolean", + "x-go-name": "RemoveDeadline" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditLabelOption": { + "description": "EditLabelOption options for editing a label", + "type": "object", + "properties": { + "color": { + "type": "string", + "x-go-name": "Color", + "example": "#00aabb" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "exclusive": { + "type": "boolean", + "x-go-name": "Exclusive", + "example": false + }, + "is_archived": { + "type": "boolean", + "x-go-name": "IsArchived", + "example": false + }, + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditMilestoneOption": { + "description": "EditMilestoneOption options for editing a milestone", + "type": "object", + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "due_on": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "state": { + "type": "string", + "x-go-name": "State" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditOrgOption": { + "description": "EditOrgOption options for editing an organization", + "type": "object", + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "email": { + "type": "string", + "x-go-name": "Email" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "location": { + "type": "string", + "x-go-name": "Location" + }, + "repo_admin_change_team_access": { + "type": "boolean", + "x-go-name": "RepoAdminChangeTeamAccess" + }, + "visibility": { + "description": "possible values are `public`, `limited` or `private`", + "type": "string", + "enum": [ + "public", + "limited", + "private" + ], + "x-go-name": "Visibility" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditPullRequestOption": { + "description": "EditPullRequestOption options when modify pull request", + "type": "object", + "properties": { + "allow_maintainer_edit": { + "type": "boolean", + "x-go-name": "AllowMaintainerEdit" + }, + "assignee": { + "type": "string", + "x-go-name": "Assignee" + }, + "assignees": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Assignees" + }, + "base": { + "type": "string", + "x-go-name": "Base" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "due_date": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "labels": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "x-go-name": "Labels" + }, + "milestone": { + "type": "integer", + "format": "int64", + "x-go-name": "Milestone" + }, + "state": { + "type": "string", + "x-go-name": "State" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "unset_due_date": { + "type": "boolean", + "x-go-name": "RemoveDeadline" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditReactionOption": { + "description": "EditReactionOption contain the reaction type", + "type": "object", + "properties": { + "content": { + "type": "string", + "x-go-name": "Reaction" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditReleaseOption": { + "description": "EditReleaseOption options when editing a release", + "type": "object", + "properties": { + "body": { + "type": "string", + "x-go-name": "Note" + }, + "draft": { + "type": "boolean", + "x-go-name": "IsDraft" + }, + "name": { + "type": "string", + "x-go-name": "Title" + }, + "prerelease": { + "type": "boolean", + "x-go-name": "IsPrerelease" + }, + "tag_name": { + "type": "string", + "x-go-name": "TagName" + }, + "target_commitish": { + "type": "string", + "x-go-name": "Target" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditRepoOption": { + "description": "EditRepoOption options when editing a repository's properties", + "type": "object", + "properties": { + "allow_manual_merge": { + "description": "either `true` to allow mark pr as merged manually, or `false` to prevent it.", + "type": "boolean", + "x-go-name": "AllowManualMerge" + }, + "allow_merge_commits": { + "description": "either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits.", + "type": "boolean", + "x-go-name": "AllowMerge" + }, + "allow_rebase": { + "description": "either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging.", + "type": "boolean", + "x-go-name": "AllowRebase" + }, + "allow_rebase_explicit": { + "description": "either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits.", + "type": "boolean", + "x-go-name": "AllowRebaseMerge" + }, + "allow_rebase_update": { + "description": "either `true` to allow updating pull request branch by rebase, or `false` to prevent it.", + "type": "boolean", + "x-go-name": "AllowRebaseUpdate" + }, + "allow_squash_merge": { + "description": "either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging.", + "type": "boolean", + "x-go-name": "AllowSquash" + }, + "archived": { + "description": "set to `true` to archive this repository.", + "type": "boolean", + "x-go-name": "Archived" + }, + "autodetect_manual_merge": { + "description": "either `true` to enable AutodetectManualMerge, or `false` to prevent it. Note: In some special cases, misjudgments can occur.", + "type": "boolean", + "x-go-name": "AutodetectManualMerge" + }, + "default_allow_maintainer_edit": { + "description": "set to `true` to allow edits from maintainers by default", + "type": "boolean", + "x-go-name": "DefaultAllowMaintainerEdit" + }, + "default_branch": { + "description": "sets the default branch for this repository.", + "type": "string", + "x-go-name": "DefaultBranch" + }, + "default_delete_branch_after_merge": { + "description": "set to `true` to delete pr branch after merge by default", + "type": "boolean", + "x-go-name": "DefaultDeleteBranchAfterMerge" + }, + "default_merge_style": { + "description": "set to a merge style to be used by this repository: \"merge\", \"rebase\", \"rebase-merge\", or \"squash\".", + "type": "string", + "x-go-name": "DefaultMergeStyle" + }, + "description": { + "description": "a short description of the repository.", + "type": "string", + "x-go-name": "Description" + }, + "enable_prune": { + "description": "enable prune - remove obsolete remote-tracking references", + "type": "boolean", + "x-go-name": "EnablePrune" + }, + "external_tracker": { + "$ref": "#/definitions/ExternalTracker" + }, + "external_wiki": { + "$ref": "#/definitions/ExternalWiki" + }, + "has_actions": { + "description": "either `true` to enable actions unit, or `false` to disable them.", + "type": "boolean", + "x-go-name": "HasActions" + }, + "has_issues": { + "description": "either `true` to enable issues for this repository or `false` to disable them.", + "type": "boolean", + "x-go-name": "HasIssues" + }, + "has_packages": { + "description": "either `true` to enable packages unit, or `false` to disable them.", + "type": "boolean", + "x-go-name": "HasPackages" + }, + "has_projects": { + "description": "either `true` to enable project unit, or `false` to disable them.", + "type": "boolean", + "x-go-name": "HasProjects" + }, + "has_pull_requests": { + "description": "either `true` to allow pull requests, or `false` to prevent pull request.", + "type": "boolean", + "x-go-name": "HasPullRequests" + }, + "has_releases": { + "description": "either `true` to enable releases unit, or `false` to disable them.", + "type": "boolean", + "x-go-name": "HasReleases" + }, + "has_wiki": { + "description": "either `true` to enable the wiki for this repository or `false` to disable it.", + "type": "boolean", + "x-go-name": "HasWiki" + }, + "ignore_whitespace_conflicts": { + "description": "either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace.", + "type": "boolean", + "x-go-name": "IgnoreWhitespaceConflicts" + }, + "internal_tracker": { + "$ref": "#/definitions/InternalTracker" + }, + "mirror_interval": { + "description": "set to a string like `8h30m0s` to set the mirror interval time", + "type": "string", + "x-go-name": "MirrorInterval" + }, + "name": { + "description": "name of the repository", + "type": "string", + "uniqueItems": true, + "x-go-name": "Name" + }, + "private": { + "description": "either `true` to make the repository private or `false` to make it public.\nNote: you will get a 422 error if the organization restricts changing repository visibility to organization\nowners and a non-owner tries to change the value of private.", + "type": "boolean", + "x-go-name": "Private" + }, + "template": { + "description": "either `true` to make this repository a template or `false` to make it a normal repository", + "type": "boolean", + "x-go-name": "Template" + }, + "website": { + "description": "a URL with more information about the repository.", + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditTeamOption": { + "description": "EditTeamOption options for editing a team", + "type": "object", + "required": [ + "name" + ], + "properties": { + "can_create_org_repo": { + "type": "boolean", + "x-go-name": "CanCreateOrgRepo" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "includes_all_repositories": { + "type": "boolean", + "x-go-name": "IncludesAllRepositories" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "permission": { + "type": "string", + "enum": [ + "read", + "write", + "admin" + ], + "x-go-name": "Permission" + }, + "units": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Units", + "example": [ + "repo.code", + "repo.issues", + "repo.ext_issues", + "repo.wiki", + "repo.pulls", + "repo.releases", + "repo.projects", + "repo.ext_wiki" + ] + }, + "units_map": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "UnitsMap", + "example": { + "repo.code": "read", + "repo.ext_issues": "none", + "repo.ext_wiki": "none", + "repo.issues": "write", + "repo.projects": "none", + "repo.pulls": "owner", + "repo.releases": "none", + "repo.wiki": "admin" + } + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "EditUserOption": { + "description": "EditUserOption edit user options", + "type": "object", + "required": [ + "source_id", + "login_name" + ], + "properties": { + "active": { + "type": "boolean", + "x-go-name": "Active" + }, + "admin": { + "type": "boolean", + "x-go-name": "Admin" + }, + "allow_create_organization": { + "type": "boolean", + "x-go-name": "AllowCreateOrganization" + }, + "allow_git_hook": { + "type": "boolean", + "x-go-name": "AllowGitHook" + }, + "allow_import_local": { + "type": "boolean", + "x-go-name": "AllowImportLocal" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "location": { + "type": "string", + "x-go-name": "Location" + }, + "login_name": { + "type": "string", + "x-go-name": "LoginName" + }, + "max_repo_creation": { + "type": "integer", + "format": "int64", + "x-go-name": "MaxRepoCreation" + }, + "must_change_password": { + "type": "boolean", + "x-go-name": "MustChangePassword" + }, + "password": { + "type": "string", + "x-go-name": "Password" + }, + "prohibit_login": { + "type": "boolean", + "x-go-name": "ProhibitLogin" + }, + "restricted": { + "type": "boolean", + "x-go-name": "Restricted" + }, + "source_id": { + "type": "integer", + "format": "int64", + "x-go-name": "SourceID" + }, + "visibility": { + "type": "string", + "x-go-name": "Visibility" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Email": { + "description": "Email an email address belonging to a user", + "type": "object", + "properties": { + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "primary": { + "type": "boolean", + "x-go-name": "Primary" + }, + "user_id": { + "type": "integer", + "format": "int64", + "x-go-name": "UserID" + }, + "username": { + "type": "string", + "x-go-name": "UserName" + }, + "verified": { + "type": "boolean", + "x-go-name": "Verified" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ExternalTracker": { + "description": "ExternalTracker represents settings for external tracker", + "type": "object", + "properties": { + "external_tracker_format": { + "description": "External Issue Tracker URL Format. Use the placeholders {user}, {repo} and {index} for the username, repository name and issue index.", + "type": "string", + "x-go-name": "ExternalTrackerFormat" + }, + "external_tracker_regexp_pattern": { + "description": "External Issue Tracker issue regular expression", + "type": "string", + "x-go-name": "ExternalTrackerRegexpPattern" + }, + "external_tracker_style": { + "description": "External Issue Tracker Number Format, either `numeric`, `alphanumeric`, or `regexp`", + "type": "string", + "x-go-name": "ExternalTrackerStyle" + }, + "external_tracker_url": { + "description": "URL of external issue tracker.", + "type": "string", + "x-go-name": "ExternalTrackerURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ExternalWiki": { + "description": "ExternalWiki represents setting for external wiki", + "type": "object", + "properties": { + "external_wiki_url": { + "description": "URL of external wiki.", + "type": "string", + "x-go-name": "ExternalWikiURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "FileCommitResponse": { + "type": "object", + "title": "FileCommitResponse contains information generated from a Git commit for a repo's file.", + "properties": { + "author": { + "$ref": "#/definitions/CommitUser" + }, + "committer": { + "$ref": "#/definitions/CommitUser" + }, + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "parents": { + "type": "array", + "items": { + "$ref": "#/definitions/CommitMeta" + }, + "x-go-name": "Parents" + }, + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "tree": { + "$ref": "#/definitions/CommitMeta" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "FileDeleteResponse": { + "description": "FileDeleteResponse contains information about a repo's file that was deleted", + "type": "object", + "properties": { + "commit": { + "$ref": "#/definitions/FileCommitResponse" + }, + "content": { + "x-go-name": "Content" + }, + "verification": { + "$ref": "#/definitions/PayloadCommitVerification" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "FileLinksResponse": { + "description": "FileLinksResponse contains the links for a repo's file", + "type": "object", + "properties": { + "git": { + "type": "string", + "x-go-name": "GitURL" + }, + "html": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "self": { + "type": "string", + "x-go-name": "Self" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "FileResponse": { + "description": "FileResponse contains information about a repo's file", + "type": "object", + "properties": { + "commit": { + "$ref": "#/definitions/FileCommitResponse" + }, + "content": { + "$ref": "#/definitions/ContentsResponse" + }, + "verification": { + "$ref": "#/definitions/PayloadCommitVerification" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "FilesResponse": { + "description": "FilesResponse contains information about multiple files from a repo", + "type": "object", + "properties": { + "commit": { + "$ref": "#/definitions/FileCommitResponse" + }, + "files": { + "type": "array", + "items": { + "$ref": "#/definitions/ContentsResponse" + }, + "x-go-name": "Files" + }, + "verification": { + "$ref": "#/definitions/PayloadCommitVerification" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GPGKey": { + "description": "GPGKey a user GPG key to sign commit and tag in repository", + "type": "object", + "properties": { + "can_certify": { + "type": "boolean", + "x-go-name": "CanCertify" + }, + "can_encrypt_comms": { + "type": "boolean", + "x-go-name": "CanEncryptComms" + }, + "can_encrypt_storage": { + "type": "boolean", + "x-go-name": "CanEncryptStorage" + }, + "can_sign": { + "type": "boolean", + "x-go-name": "CanSign" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "emails": { + "type": "array", + "items": { + "$ref": "#/definitions/GPGKeyEmail" + }, + "x-go-name": "Emails" + }, + "expires_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Expires" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "key_id": { + "type": "string", + "x-go-name": "KeyID" + }, + "primary_key_id": { + "type": "string", + "x-go-name": "PrimaryKeyID" + }, + "public_key": { + "type": "string", + "x-go-name": "PublicKey" + }, + "subkeys": { + "type": "array", + "items": { + "$ref": "#/definitions/GPGKey" + }, + "x-go-name": "SubsKey" + }, + "verified": { + "type": "boolean", + "x-go-name": "Verified" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GPGKeyEmail": { + "description": "GPGKeyEmail an email attached to a GPGKey", + "type": "object", + "properties": { + "email": { + "type": "string", + "x-go-name": "Email" + }, + "verified": { + "type": "boolean", + "x-go-name": "Verified" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GeneralAPISettings": { + "description": "GeneralAPISettings contains global api settings exposed by it", + "type": "object", + "properties": { + "default_git_trees_per_page": { + "type": "integer", + "format": "int64", + "x-go-name": "DefaultGitTreesPerPage" + }, + "default_max_blob_size": { + "type": "integer", + "format": "int64", + "x-go-name": "DefaultMaxBlobSize" + }, + "default_paging_num": { + "type": "integer", + "format": "int64", + "x-go-name": "DefaultPagingNum" + }, + "max_response_items": { + "type": "integer", + "format": "int64", + "x-go-name": "MaxResponseItems" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GeneralAttachmentSettings": { + "description": "GeneralAttachmentSettings contains global Attachment settings exposed by API", + "type": "object", + "properties": { + "allowed_types": { + "type": "string", + "x-go-name": "AllowedTypes" + }, + "enabled": { + "type": "boolean", + "x-go-name": "Enabled" + }, + "max_files": { + "type": "integer", + "format": "int64", + "x-go-name": "MaxFiles" + }, + "max_size": { + "type": "integer", + "format": "int64", + "x-go-name": "MaxSize" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GeneralRepoSettings": { + "description": "GeneralRepoSettings contains global repository settings exposed by API", + "type": "object", + "properties": { + "http_git_disabled": { + "type": "boolean", + "x-go-name": "HTTPGitDisabled" + }, + "lfs_disabled": { + "type": "boolean", + "x-go-name": "LFSDisabled" + }, + "migrations_disabled": { + "type": "boolean", + "x-go-name": "MigrationsDisabled" + }, + "mirrors_disabled": { + "type": "boolean", + "x-go-name": "MirrorsDisabled" + }, + "stars_disabled": { + "type": "boolean", + "x-go-name": "StarsDisabled" + }, + "time_tracking_disabled": { + "type": "boolean", + "x-go-name": "TimeTrackingDisabled" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GeneralUISettings": { + "description": "GeneralUISettings contains global ui settings exposed by API", + "type": "object", + "properties": { + "allowed_reactions": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "AllowedReactions" + }, + "custom_emojis": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "CustomEmojis" + }, + "default_theme": { + "type": "string", + "x-go-name": "DefaultTheme" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GenerateRepoOption": { + "description": "GenerateRepoOption options when creating repository using a template", + "type": "object", + "required": [ + "owner", + "name" + ], + "properties": { + "avatar": { + "description": "include avatar of the template repo", + "type": "boolean", + "x-go-name": "Avatar" + }, + "default_branch": { + "description": "Default branch of the new repository", + "type": "string", + "x-go-name": "DefaultBranch" + }, + "description": { + "description": "Description of the repository to create", + "type": "string", + "x-go-name": "Description" + }, + "git_content": { + "description": "include git content of default branch in template repo", + "type": "boolean", + "x-go-name": "GitContent" + }, + "git_hooks": { + "description": "include git hooks in template repo", + "type": "boolean", + "x-go-name": "GitHooks" + }, + "labels": { + "description": "include labels in template repo", + "type": "boolean", + "x-go-name": "Labels" + }, + "name": { + "description": "Name of the repository to create", + "type": "string", + "uniqueItems": true, + "x-go-name": "Name" + }, + "owner": { + "description": "The organization or person who will own the new repository", + "type": "string", + "x-go-name": "Owner" + }, + "private": { + "description": "Whether the repository is private", + "type": "boolean", + "x-go-name": "Private" + }, + "protected_branch": { + "description": "include protected branches in template repo", + "type": "boolean", + "x-go-name": "ProtectedBranch" + }, + "topics": { + "description": "include topics in template repo", + "type": "boolean", + "x-go-name": "Topics" + }, + "webhooks": { + "description": "include webhooks in template repo", + "type": "boolean", + "x-go-name": "Webhooks" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GitBlobResponse": { + "description": "GitBlobResponse represents a git blob", + "type": "object", + "properties": { + "content": { + "type": "string", + "x-go-name": "Content" + }, + "encoding": { + "type": "string", + "x-go-name": "Encoding" + }, + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "size": { + "type": "integer", + "format": "int64", + "x-go-name": "Size" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GitEntry": { + "description": "GitEntry represents a git tree", + "type": "object", + "properties": { + "mode": { + "type": "string", + "x-go-name": "Mode" + }, + "path": { + "type": "string", + "x-go-name": "Path" + }, + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "size": { + "type": "integer", + "format": "int64", + "x-go-name": "Size" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GitHook": { + "description": "GitHook represents a Git repository hook", + "type": "object", + "properties": { + "content": { + "type": "string", + "x-go-name": "Content" + }, + "is_active": { + "type": "boolean", + "x-go-name": "IsActive" + }, + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GitObject": { + "type": "object", + "title": "GitObject represents a Git object.", + "properties": { + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GitTreeResponse": { + "description": "GitTreeResponse returns a git tree", + "type": "object", + "properties": { + "page": { + "type": "integer", + "format": "int64", + "x-go-name": "Page" + }, + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "total_count": { + "type": "integer", + "format": "int64", + "x-go-name": "TotalCount" + }, + "tree": { + "type": "array", + "items": { + "$ref": "#/definitions/GitEntry" + }, + "x-go-name": "Entries" + }, + "truncated": { + "type": "boolean", + "x-go-name": "Truncated" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "GitignoreTemplateInfo": { + "description": "GitignoreTemplateInfo name and text of a gitignore template", + "type": "object", + "properties": { + "name": { + "type": "string", + "x-go-name": "Name" + }, + "source": { + "type": "string", + "x-go-name": "Source" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Hook": { + "description": "Hook a hook is a web hook when one repository changed", + "type": "object", + "properties": { + "active": { + "type": "boolean", + "x-go-name": "Active" + }, + "authorization_header": { + "type": "string", + "x-go-name": "AuthorizationHeader" + }, + "branch_filter": { + "type": "string", + "x-go-name": "BranchFilter" + }, + "config": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Config" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "events": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Events" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Identity": { + "description": "Identity for a person's identity like an author or committer", + "type": "object", + "properties": { + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "InternalTracker": { + "description": "InternalTracker represents settings for internal tracker", + "type": "object", + "properties": { + "allow_only_contributors_to_track_time": { + "description": "Let only contributors track time (Built-in issue tracker)", + "type": "boolean", + "x-go-name": "AllowOnlyContributorsToTrackTime" + }, + "enable_issue_dependencies": { + "description": "Enable dependencies for issues and pull requests (Built-in issue tracker)", + "type": "boolean", + "x-go-name": "EnableIssueDependencies" + }, + "enable_time_tracker": { + "description": "Enable time tracking (Built-in issue tracker)", + "type": "boolean", + "x-go-name": "EnableTimeTracker" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Issue": { + "description": "Issue represents an issue in a repository", + "type": "object", + "properties": { + "assets": { + "type": "array", + "items": { + "$ref": "#/definitions/Attachment" + }, + "x-go-name": "Attachments" + }, + "assignee": { + "$ref": "#/definitions/User" + }, + "assignees": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + }, + "x-go-name": "Assignees" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "closed_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Closed" + }, + "comments": { + "type": "integer", + "format": "int64", + "x-go-name": "Comments" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "due_date": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "is_locked": { + "type": "boolean", + "x-go-name": "IsLocked" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + }, + "x-go-name": "Labels" + }, + "milestone": { + "$ref": "#/definitions/Milestone" + }, + "number": { + "type": "integer", + "format": "int64", + "x-go-name": "Index" + }, + "original_author": { + "type": "string", + "x-go-name": "OriginalAuthor" + }, + "original_author_id": { + "type": "integer", + "format": "int64", + "x-go-name": "OriginalAuthorID" + }, + "pin_order": { + "type": "integer", + "format": "int64", + "x-go-name": "PinOrder" + }, + "pull_request": { + "$ref": "#/definitions/PullRequestMeta" + }, + "ref": { + "type": "string", + "x-go-name": "Ref" + }, + "repository": { + "$ref": "#/definitions/RepositoryMeta" + }, + "state": { + "$ref": "#/definitions/StateType" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueConfig": { + "type": "object", + "properties": { + "blank_issues_enabled": { + "type": "boolean", + "x-go-name": "BlankIssuesEnabled" + }, + "contact_links": { + "type": "array", + "items": { + "$ref": "#/definitions/IssueConfigContactLink" + }, + "x-go-name": "ContactLinks" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueConfigContactLink": { + "type": "object", + "properties": { + "about": { + "type": "string", + "x-go-name": "About" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueConfigValidation": { + "type": "object", + "properties": { + "message": { + "type": "string", + "x-go-name": "Message" + }, + "valid": { + "type": "boolean", + "x-go-name": "Valid" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueDeadline": { + "description": "IssueDeadline represents an issue deadline", + "type": "object", + "properties": { + "due_date": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueFormField": { + "description": "IssueFormField represents a form field", + "type": "object", + "properties": { + "attributes": { + "type": "object", + "additionalProperties": {}, + "x-go-name": "Attributes" + }, + "id": { + "type": "string", + "x-go-name": "ID" + }, + "type": { + "$ref": "#/definitions/IssueFormFieldType" + }, + "validations": { + "type": "object", + "additionalProperties": {}, + "x-go-name": "Validations" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueFormFieldType": { + "type": "string", + "title": "IssueFormFieldType defines issue form field type, can be \"markdown\", \"textarea\", \"input\", \"dropdown\" or \"checkboxes\"", + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueLabelsOption": { + "description": "IssueLabelsOption a collection of labels", + "type": "object", + "properties": { + "labels": { + "description": "list of label IDs", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "x-go-name": "Labels" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueMeta": { + "description": "IssueMeta basic issue information", + "type": "object", + "properties": { + "index": { + "type": "integer", + "format": "int64", + "x-go-name": "Index" + }, + "owner": { + "type": "string", + "x-go-name": "Owner" + }, + "repo": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueTemplate": { + "description": "IssueTemplate represents an issue template for a repository", + "type": "object", + "properties": { + "about": { + "type": "string", + "x-go-name": "About" + }, + "body": { + "type": "array", + "items": { + "$ref": "#/definitions/IssueFormField" + }, + "x-go-name": "Fields" + }, + "content": { + "type": "string", + "x-go-name": "Content" + }, + "file_name": { + "type": "string", + "x-go-name": "FileName" + }, + "labels": { + "$ref": "#/definitions/IssueTemplateLabels" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "ref": { + "type": "string", + "x-go-name": "Ref" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "IssueTemplateLabels": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Label": { + "description": "Label a label to an issue or a pr", + "type": "object", + "properties": { + "color": { + "type": "string", + "x-go-name": "Color", + "example": "00aabb" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "exclusive": { + "type": "boolean", + "x-go-name": "Exclusive", + "example": false + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "is_archived": { + "type": "boolean", + "x-go-name": "IsArchived", + "example": false + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "LabelTemplate": { + "description": "LabelTemplate info of a Label template", + "type": "object", + "properties": { + "color": { + "type": "string", + "x-go-name": "Color", + "example": "00aabb" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "exclusive": { + "type": "boolean", + "x-go-name": "Exclusive", + "example": false + }, + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "LicenseTemplateInfo": { + "description": "LicensesInfo contains information about a License", + "type": "object", + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + }, + "implementation": { + "type": "string", + "x-go-name": "Implementation" + }, + "key": { + "type": "string", + "x-go-name": "Key" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "LicensesTemplateListEntry": { + "description": "LicensesListEntry is used for the API", + "type": "object", + "properties": { + "key": { + "type": "string", + "x-go-name": "Key" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "MarkdownOption": { + "description": "MarkdownOption markdown options", + "type": "object", + "properties": { + "Context": { + "description": "Context to render\n\nin: body", + "type": "string" + }, + "Mode": { + "description": "Mode to render (comment, gfm, markdown)\n\nin: body", + "type": "string" + }, + "Text": { + "description": "Text markdown to render\n\nin: body", + "type": "string" + }, + "Wiki": { + "description": "Is it a wiki page ?\n\nin: body", + "type": "boolean" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "MarkupOption": { + "description": "MarkupOption markup options", + "type": "object", + "properties": { + "Context": { + "description": "Context to render\n\nin: body", + "type": "string" + }, + "FilePath": { + "description": "File path for detecting extension in file mode\n\nin: body", + "type": "string" + }, + "Mode": { + "description": "Mode to render (comment, gfm, markdown, file)\n\nin: body", + "type": "string" + }, + "Text": { + "description": "Text markup to render\n\nin: body", + "type": "string" + }, + "Wiki": { + "description": "Is it a wiki page ?\n\nin: body", + "type": "boolean" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "MergePullRequestOption": { + "description": "MergePullRequestForm form for merging Pull Request", + "type": "object", + "required": [ + "Do" + ], + "properties": { + "Do": { + "type": "string", + "enum": [ + "merge", + "rebase", + "rebase-merge", + "squash", + "manually-merged" + ] + }, + "MergeCommitID": { + "type": "string" + }, + "MergeMessageField": { + "type": "string" + }, + "MergeTitleField": { + "type": "string" + }, + "delete_branch_after_merge": { + "type": "boolean", + "x-go-name": "DeleteBranchAfterMerge" + }, + "force_merge": { + "type": "boolean", + "x-go-name": "ForceMerge" + }, + "head_commit_id": { + "type": "string", + "x-go-name": "HeadCommitID" + }, + "merge_when_checks_succeed": { + "type": "boolean", + "x-go-name": "MergeWhenChecksSucceed" + } + }, + "x-go-name": "MergePullRequestForm", + "x-go-package": "code.gitea.io/gitea/services/forms" + }, + "MigrateRepoOptions": { + "description": "MigrateRepoOptions options for migrating repository's\nthis is used to interact with api v1", + "type": "object", + "required": [ + "clone_addr", + "repo_name" + ], + "properties": { + "auth_password": { + "type": "string", + "x-go-name": "AuthPassword" + }, + "auth_token": { + "type": "string", + "x-go-name": "AuthToken" + }, + "auth_username": { + "type": "string", + "x-go-name": "AuthUsername" + }, + "clone_addr": { + "type": "string", + "x-go-name": "CloneAddr" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "issues": { + "type": "boolean", + "x-go-name": "Issues" + }, + "labels": { + "type": "boolean", + "x-go-name": "Labels" + }, + "lfs": { + "type": "boolean", + "x-go-name": "LFS" + }, + "lfs_endpoint": { + "type": "string", + "x-go-name": "LFSEndpoint" + }, + "milestones": { + "type": "boolean", + "x-go-name": "Milestones" + }, + "mirror": { + "type": "boolean", + "x-go-name": "Mirror" + }, + "mirror_interval": { + "type": "string", + "x-go-name": "MirrorInterval" + }, + "private": { + "type": "boolean", + "x-go-name": "Private" + }, + "pull_requests": { + "type": "boolean", + "x-go-name": "PullRequests" + }, + "releases": { + "type": "boolean", + "x-go-name": "Releases" + }, + "repo_name": { + "type": "string", + "x-go-name": "RepoName" + }, + "repo_owner": { + "description": "Name of User or Organisation who will own Repo after migration", + "type": "string", + "x-go-name": "RepoOwner" + }, + "service": { + "type": "string", + "enum": [ + "git", + "github", + "gitea", + "gitlab", + "gogs", + "onedev", + "gitbucket", + "codebase" + ], + "x-go-name": "Service" + }, + "uid": { + "description": "deprecated (only for backwards compatibility)", + "type": "integer", + "format": "int64", + "x-go-name": "RepoOwnerID" + }, + "wiki": { + "type": "boolean", + "x-go-name": "Wiki" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Milestone": { + "description": "Milestone milestone is a collection of issues on one repository", + "type": "object", + "properties": { + "closed_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Closed" + }, + "closed_issues": { + "type": "integer", + "format": "int64", + "x-go-name": "ClosedIssues" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "due_on": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "open_issues": { + "type": "integer", + "format": "int64", + "x-go-name": "OpenIssues" + }, + "state": { + "$ref": "#/definitions/StateType" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "NewIssuePinsAllowed": { + "description": "NewIssuePinsAllowed represents an API response that says if new Issue Pins are allowed", + "type": "object", + "properties": { + "issues": { + "type": "boolean", + "x-go-name": "Issues" + }, + "pull_requests": { + "type": "boolean", + "x-go-name": "PullRequests" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "NodeInfo": { + "description": "NodeInfo contains standardized way of exposing metadata about a server running one of the distributed social networks", + "type": "object", + "properties": { + "metadata": { + "type": "object", + "x-go-name": "Metadata" + }, + "openRegistrations": { + "type": "boolean", + "x-go-name": "OpenRegistrations" + }, + "protocols": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Protocols" + }, + "services": { + "$ref": "#/definitions/NodeInfoServices" + }, + "software": { + "$ref": "#/definitions/NodeInfoSoftware" + }, + "usage": { + "$ref": "#/definitions/NodeInfoUsage" + }, + "version": { + "type": "string", + "x-go-name": "Version" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "NodeInfoServices": { + "description": "NodeInfoServices contains the third party sites this server can connect to via their application API", + "type": "object", + "properties": { + "inbound": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Inbound" + }, + "outbound": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Outbound" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "NodeInfoSoftware": { + "description": "NodeInfoSoftware contains Metadata about server software in use", + "type": "object", + "properties": { + "homepage": { + "type": "string", + "x-go-name": "Homepage" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "repository": { + "type": "string", + "x-go-name": "Repository" + }, + "version": { + "type": "string", + "x-go-name": "Version" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "NodeInfoUsage": { + "description": "NodeInfoUsage contains usage statistics for this server", + "type": "object", + "properties": { + "localComments": { + "type": "integer", + "format": "int64", + "x-go-name": "LocalComments" + }, + "localPosts": { + "type": "integer", + "format": "int64", + "x-go-name": "LocalPosts" + }, + "users": { + "$ref": "#/definitions/NodeInfoUsageUsers" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "NodeInfoUsageUsers": { + "description": "NodeInfoUsageUsers contains statistics about the users of this server", + "type": "object", + "properties": { + "activeHalfyear": { + "type": "integer", + "format": "int64", + "x-go-name": "ActiveHalfyear" + }, + "activeMonth": { + "type": "integer", + "format": "int64", + "x-go-name": "ActiveMonth" + }, + "total": { + "type": "integer", + "format": "int64", + "x-go-name": "Total" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Note": { + "description": "Note contains information related to a git note", + "type": "object", + "properties": { + "commit": { + "$ref": "#/definitions/Commit" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "NotificationCount": { + "description": "NotificationCount number of unread notifications", + "type": "object", + "properties": { + "new": { + "type": "integer", + "format": "int64", + "x-go-name": "New" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "NotificationSubject": { + "description": "NotificationSubject contains the notification subject (Issue/Pull/Commit)", + "type": "object", + "properties": { + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "latest_comment_html_url": { + "type": "string", + "x-go-name": "LatestCommentHTMLURL" + }, + "latest_comment_url": { + "type": "string", + "x-go-name": "LatestCommentURL" + }, + "state": { + "$ref": "#/definitions/StateType" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "type": { + "$ref": "#/definitions/NotifySubjectType" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "NotificationThread": { + "description": "NotificationThread expose Notification on API", + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "pinned": { + "type": "boolean", + "x-go-name": "Pinned" + }, + "repository": { + "$ref": "#/definitions/Repository" + }, + "subject": { + "$ref": "#/definitions/NotificationSubject" + }, + "unread": { + "type": "boolean", + "x-go-name": "Unread" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "UpdatedAt" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "NotifySubjectType": { + "description": "NotifySubjectType represent type of notification subject", + "type": "string", + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "OAuth2Application": { + "type": "object", + "title": "OAuth2Application represents an OAuth2 application.", + "properties": { + "client_id": { + "type": "string", + "x-go-name": "ClientID" + }, + "client_secret": { + "type": "string", + "x-go-name": "ClientSecret" + }, + "confidential_client": { + "type": "boolean", + "x-go-name": "ConfidentialClient" + }, + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "redirect_uris": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "RedirectURIs" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Organization": { + "description": "Organization represents an organization", + "type": "object", + "properties": { + "avatar_url": { + "type": "string", + "x-go-name": "AvatarURL" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "email": { + "type": "string", + "x-go-name": "Email" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "location": { + "type": "string", + "x-go-name": "Location" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "repo_admin_change_team_access": { + "type": "boolean", + "x-go-name": "RepoAdminChangeTeamAccess" + }, + "username": { + "description": "deprecated", + "type": "string", + "x-go-name": "UserName" + }, + "visibility": { + "type": "string", + "x-go-name": "Visibility" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "OrganizationPermissions": { + "description": "OrganizationPermissions list different users permissions on an organization", + "type": "object", + "properties": { + "can_create_repository": { + "type": "boolean", + "x-go-name": "CanCreateRepository" + }, + "can_read": { + "type": "boolean", + "x-go-name": "CanRead" + }, + "can_write": { + "type": "boolean", + "x-go-name": "CanWrite" + }, + "is_admin": { + "type": "boolean", + "x-go-name": "IsAdmin" + }, + "is_owner": { + "type": "boolean", + "x-go-name": "IsOwner" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PRBranchInfo": { + "description": "PRBranchInfo information about a branch", + "type": "object", + "properties": { + "label": { + "type": "string", + "x-go-name": "Name" + }, + "ref": { + "type": "string", + "x-go-name": "Ref" + }, + "repo": { + "$ref": "#/definitions/Repository" + }, + "repo_id": { + "type": "integer", + "format": "int64", + "x-go-name": "RepoID" + }, + "sha": { + "type": "string", + "x-go-name": "Sha" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Package": { + "description": "Package represents a package", + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "CreatedAt" + }, + "creator": { + "$ref": "#/definitions/User" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "owner": { + "$ref": "#/definitions/User" + }, + "repository": { + "$ref": "#/definitions/Repository" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "version": { + "type": "string", + "x-go-name": "Version" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PackageFile": { + "description": "PackageFile represents a package file", + "type": "object", + "properties": { + "Size": { + "type": "integer", + "format": "int64" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "md5": { + "type": "string", + "x-go-name": "HashMD5" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "sha1": { + "type": "string", + "x-go-name": "HashSHA1" + }, + "sha256": { + "type": "string", + "x-go-name": "HashSHA256" + }, + "sha512": { + "type": "string", + "x-go-name": "HashSHA512" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PayloadCommit": { + "description": "PayloadCommit represents a commit", + "type": "object", + "properties": { + "added": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Added" + }, + "author": { + "$ref": "#/definitions/PayloadUser" + }, + "committer": { + "$ref": "#/definitions/PayloadUser" + }, + "id": { + "description": "sha1 hash of the commit", + "type": "string", + "x-go-name": "ID" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "modified": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Modified" + }, + "removed": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Removed" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "x-go-name": "Timestamp" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "verification": { + "$ref": "#/definitions/PayloadCommitVerification" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PayloadCommitVerification": { + "description": "PayloadCommitVerification represents the GPG verification of a commit", + "type": "object", + "properties": { + "payload": { + "type": "string", + "x-go-name": "Payload" + }, + "reason": { + "type": "string", + "x-go-name": "Reason" + }, + "signature": { + "type": "string", + "x-go-name": "Signature" + }, + "signer": { + "$ref": "#/definitions/PayloadUser" + }, + "verified": { + "type": "boolean", + "x-go-name": "Verified" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PayloadUser": { + "description": "PayloadUser represents the author or committer of a commit", + "type": "object", + "properties": { + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "name": { + "description": "Full name of the commit author", + "type": "string", + "x-go-name": "Name" + }, + "username": { + "type": "string", + "x-go-name": "UserName" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Permission": { + "description": "Permission represents a set of permissions", + "type": "object", + "properties": { + "admin": { + "type": "boolean", + "x-go-name": "Admin" + }, + "pull": { + "type": "boolean", + "x-go-name": "Pull" + }, + "push": { + "type": "boolean", + "x-go-name": "Push" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PublicKey": { + "description": "PublicKey publickey is a user key to push code to repository", + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "fingerprint": { + "type": "string", + "x-go-name": "Fingerprint" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "key": { + "type": "string", + "x-go-name": "Key" + }, + "key_type": { + "type": "string", + "x-go-name": "KeyType" + }, + "read_only": { + "type": "boolean", + "x-go-name": "ReadOnly" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PullRequest": { + "description": "PullRequest represents a pull request", + "type": "object", + "properties": { + "allow_maintainer_edit": { + "type": "boolean", + "x-go-name": "AllowMaintainerEdit" + }, + "assignee": { + "$ref": "#/definitions/User" + }, + "assignees": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + }, + "x-go-name": "Assignees" + }, + "base": { + "$ref": "#/definitions/PRBranchInfo" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "closed_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Closed" + }, + "comments": { + "type": "integer", + "format": "int64", + "x-go-name": "Comments" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "diff_url": { + "type": "string", + "x-go-name": "DiffURL" + }, + "due_date": { + "type": "string", + "format": "date-time", + "x-go-name": "Deadline" + }, + "head": { + "$ref": "#/definitions/PRBranchInfo" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "is_locked": { + "type": "boolean", + "x-go-name": "IsLocked" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + }, + "x-go-name": "Labels" + }, + "merge_base": { + "type": "string", + "x-go-name": "MergeBase" + }, + "merge_commit_sha": { + "type": "string", + "x-go-name": "MergedCommitID" + }, + "mergeable": { + "type": "boolean", + "x-go-name": "Mergeable" + }, + "merged": { + "type": "boolean", + "x-go-name": "HasMerged" + }, + "merged_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Merged" + }, + "merged_by": { + "$ref": "#/definitions/User" + }, + "milestone": { + "$ref": "#/definitions/Milestone" + }, + "number": { + "type": "integer", + "format": "int64", + "x-go-name": "Index" + }, + "patch_url": { + "type": "string", + "x-go-name": "PatchURL" + }, + "pin_order": { + "type": "integer", + "format": "int64", + "x-go-name": "PinOrder" + }, + "requested_reviewers": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + }, + "x-go-name": "RequestedReviewers" + }, + "state": { + "$ref": "#/definitions/StateType" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PullRequestMeta": { + "description": "PullRequestMeta PR info if an issue is a PR", + "type": "object", + "properties": { + "merged": { + "type": "boolean", + "x-go-name": "HasMerged" + }, + "merged_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Merged" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PullReview": { + "description": "PullReview represents a pull request review", + "type": "object", + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + }, + "comments_count": { + "type": "integer", + "format": "int64", + "x-go-name": "CodeCommentsCount" + }, + "commit_id": { + "type": "string", + "x-go-name": "CommitID" + }, + "dismissed": { + "type": "boolean", + "x-go-name": "Dismissed" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "official": { + "type": "boolean", + "x-go-name": "Official" + }, + "pull_request_url": { + "type": "string", + "x-go-name": "HTMLPullURL" + }, + "stale": { + "type": "boolean", + "x-go-name": "Stale" + }, + "state": { + "$ref": "#/definitions/ReviewStateType" + }, + "submitted_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Submitted" + }, + "team": { + "$ref": "#/definitions/Team" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PullReviewComment": { + "description": "PullReviewComment represents a comment on a pull request review", + "type": "object", + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + }, + "commit_id": { + "type": "string", + "x-go-name": "CommitID" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "diff_hunk": { + "type": "string", + "x-go-name": "DiffHunk" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "original_commit_id": { + "type": "string", + "x-go-name": "OrigCommitID" + }, + "original_position": { + "type": "integer", + "format": "uint64", + "x-go-name": "OldLineNum" + }, + "path": { + "type": "string", + "x-go-name": "Path" + }, + "position": { + "type": "integer", + "format": "uint64", + "x-go-name": "LineNum" + }, + "pull_request_review_id": { + "type": "integer", + "format": "int64", + "x-go-name": "ReviewID" + }, + "pull_request_url": { + "type": "string", + "x-go-name": "HTMLPullURL" + }, + "resolver": { + "$ref": "#/definitions/User" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PullReviewRequestOptions": { + "description": "PullReviewRequestOptions are options to add or remove pull review requests", + "type": "object", + "properties": { + "reviewers": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Reviewers" + }, + "team_reviewers": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "TeamReviewers" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "PushMirror": { + "description": "PushMirror represents information of a push mirror", + "type": "object", + "properties": { + "created": { + "type": "string", + "x-go-name": "CreatedUnix" + }, + "interval": { + "type": "string", + "x-go-name": "Interval" + }, + "last_error": { + "type": "string", + "x-go-name": "LastError" + }, + "last_update": { + "type": "string", + "x-go-name": "LastUpdateUnix" + }, + "remote_address": { + "type": "string", + "x-go-name": "RemoteAddress" + }, + "remote_name": { + "type": "string", + "x-go-name": "RemoteName" + }, + "repo_name": { + "type": "string", + "x-go-name": "RepoName" + }, + "sync_on_commit": { + "type": "boolean", + "x-go-name": "SyncOnCommit" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Reaction": { + "description": "Reaction contain one reaction", + "type": "object", + "properties": { + "content": { + "type": "string", + "x-go-name": "Reaction" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Reference": { + "type": "object", + "title": "Reference represents a Git reference.", + "properties": { + "object": { + "$ref": "#/definitions/GitObject" + }, + "ref": { + "type": "string", + "x-go-name": "Ref" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Release": { + "description": "Release represents a repository release", + "type": "object", + "properties": { + "assets": { + "type": "array", + "items": { + "$ref": "#/definitions/Attachment" + }, + "x-go-name": "Attachments" + }, + "author": { + "$ref": "#/definitions/User" + }, + "body": { + "type": "string", + "x-go-name": "Note" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "CreatedAt" + }, + "draft": { + "type": "boolean", + "x-go-name": "IsDraft" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Title" + }, + "prerelease": { + "type": "boolean", + "x-go-name": "IsPrerelease" + }, + "published_at": { + "type": "string", + "format": "date-time", + "x-go-name": "PublishedAt" + }, + "tag_name": { + "type": "string", + "x-go-name": "TagName" + }, + "tarball_url": { + "type": "string", + "x-go-name": "TarURL" + }, + "target_commitish": { + "type": "string", + "x-go-name": "Target" + }, + "upload_url": { + "type": "string", + "x-go-name": "UploadURL" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "zipball_url": { + "type": "string", + "x-go-name": "ZipURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "RenameUserOption": { + "description": "RenameUserOption options when renaming a user", + "type": "object", + "required": [ + "new_username" + ], + "properties": { + "new_username": { + "description": "New username for this user. This name cannot be in use yet by any other user.", + "type": "string", + "uniqueItems": true, + "x-go-name": "NewName" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "RepoCollaboratorPermission": { + "description": "RepoCollaboratorPermission to get repository permission for a collaborator", + "type": "object", + "properties": { + "permission": { + "type": "string", + "x-go-name": "Permission" + }, + "role_name": { + "type": "string", + "x-go-name": "RoleName" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "RepoCommit": { + "type": "object", + "title": "RepoCommit contains information of a commit in the context of a repository.", + "properties": { + "author": { + "$ref": "#/definitions/CommitUser" + }, + "committer": { + "$ref": "#/definitions/CommitUser" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "tree": { + "$ref": "#/definitions/CommitMeta" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "verification": { + "$ref": "#/definitions/PayloadCommitVerification" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "RepoTopicOptions": { + "description": "RepoTopicOptions a collection of repo topic names", + "type": "object", + "properties": { + "topics": { + "description": "list of topic names", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Topics" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "RepoTransfer": { + "description": "RepoTransfer represents a pending repo transfer", + "type": "object", + "properties": { + "doer": { + "$ref": "#/definitions/User" + }, + "recipient": { + "$ref": "#/definitions/User" + }, + "teams": { + "type": "array", + "items": { + "$ref": "#/definitions/Team" + }, + "x-go-name": "Teams" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Repository": { + "description": "Repository represents a repository", + "type": "object", + "properties": { + "allow_merge_commits": { + "type": "boolean", + "x-go-name": "AllowMerge" + }, + "allow_rebase": { + "type": "boolean", + "x-go-name": "AllowRebase" + }, + "allow_rebase_explicit": { + "type": "boolean", + "x-go-name": "AllowRebaseMerge" + }, + "allow_rebase_update": { + "type": "boolean", + "x-go-name": "AllowRebaseUpdate" + }, + "allow_squash_merge": { + "type": "boolean", + "x-go-name": "AllowSquash" + }, + "archived": { + "type": "boolean", + "x-go-name": "Archived" + }, + "archived_at": { + "type": "string", + "format": "date-time", + "x-go-name": "ArchivedAt" + }, + "avatar_url": { + "type": "string", + "x-go-name": "AvatarURL" + }, + "clone_url": { + "type": "string", + "x-go-name": "CloneURL" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "default_allow_maintainer_edit": { + "type": "boolean", + "x-go-name": "DefaultAllowMaintainerEdit" + }, + "default_branch": { + "type": "string", + "x-go-name": "DefaultBranch" + }, + "default_delete_branch_after_merge": { + "type": "boolean", + "x-go-name": "DefaultDeleteBranchAfterMerge" + }, + "default_merge_style": { + "type": "string", + "x-go-name": "DefaultMergeStyle" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "empty": { + "type": "boolean", + "x-go-name": "Empty" + }, + "external_tracker": { + "$ref": "#/definitions/ExternalTracker" + }, + "external_wiki": { + "$ref": "#/definitions/ExternalWiki" + }, + "fork": { + "type": "boolean", + "x-go-name": "Fork" + }, + "forks_count": { + "type": "integer", + "format": "int64", + "x-go-name": "Forks" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "has_actions": { + "type": "boolean", + "x-go-name": "HasActions" + }, + "has_issues": { + "type": "boolean", + "x-go-name": "HasIssues" + }, + "has_packages": { + "type": "boolean", + "x-go-name": "HasPackages" + }, + "has_projects": { + "type": "boolean", + "x-go-name": "HasProjects" + }, + "has_pull_requests": { + "type": "boolean", + "x-go-name": "HasPullRequests" + }, + "has_releases": { + "type": "boolean", + "x-go-name": "HasReleases" + }, + "has_wiki": { + "type": "boolean", + "x-go-name": "HasWiki" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "ignore_whitespace_conflicts": { + "type": "boolean", + "x-go-name": "IgnoreWhitespaceConflicts" + }, + "internal": { + "type": "boolean", + "x-go-name": "Internal" + }, + "internal_tracker": { + "$ref": "#/definitions/InternalTracker" + }, + "language": { + "type": "string", + "x-go-name": "Language" + }, + "languages_url": { + "type": "string", + "x-go-name": "LanguagesURL" + }, + "link": { + "type": "string", + "x-go-name": "Link" + }, + "mirror": { + "type": "boolean", + "x-go-name": "Mirror" + }, + "mirror_interval": { + "type": "string", + "x-go-name": "MirrorInterval" + }, + "mirror_updated": { + "type": "string", + "format": "date-time", + "x-go-name": "MirrorUpdated" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "open_issues_count": { + "type": "integer", + "format": "int64", + "x-go-name": "OpenIssues" + }, + "open_pr_counter": { + "type": "integer", + "format": "int64", + "x-go-name": "OpenPulls" + }, + "original_url": { + "type": "string", + "x-go-name": "OriginalURL" + }, + "owner": { + "$ref": "#/definitions/User" + }, + "parent": { + "$ref": "#/definitions/Repository" + }, + "permissions": { + "$ref": "#/definitions/Permission" + }, + "private": { + "type": "boolean", + "x-go-name": "Private" + }, + "release_counter": { + "type": "integer", + "format": "int64", + "x-go-name": "Releases" + }, + "repo_transfer": { + "$ref": "#/definitions/RepoTransfer" + }, + "size": { + "type": "integer", + "format": "int64", + "x-go-name": "Size" + }, + "ssh_url": { + "type": "string", + "x-go-name": "SSHURL" + }, + "stars_count": { + "type": "integer", + "format": "int64", + "x-go-name": "Stars" + }, + "template": { + "type": "boolean", + "x-go-name": "Template" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "watchers_count": { + "type": "integer", + "format": "int64", + "x-go-name": "Watchers" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "RepositoryMeta": { + "description": "RepositoryMeta basic repository information", + "type": "object", + "properties": { + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "owner": { + "type": "string", + "x-go-name": "Owner" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ReviewStateType": { + "description": "ReviewStateType review state type", + "type": "string", + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "SearchResults": { + "description": "SearchResults results of a successful search", + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/Repository" + }, + "x-go-name": "Data" + }, + "ok": { + "type": "boolean", + "x-go-name": "OK" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Secret": { + "description": "Secret represents a secret", + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "name": { + "description": "the secret's name", + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ServerVersion": { + "description": "ServerVersion wraps the version of the server", + "type": "object", + "properties": { + "version": { + "type": "string", + "x-go-name": "Version" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "StateType": { + "description": "StateType issue state type", + "type": "string", + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "StopWatch": { + "description": "StopWatch represent a running stopwatch", + "type": "object", + "properties": { + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "duration": { + "type": "string", + "x-go-name": "Duration" + }, + "issue_index": { + "type": "integer", + "format": "int64", + "x-go-name": "IssueIndex" + }, + "issue_title": { + "type": "string", + "x-go-name": "IssueTitle" + }, + "repo_name": { + "type": "string", + "x-go-name": "RepoName" + }, + "repo_owner_name": { + "type": "string", + "x-go-name": "RepoOwnerName" + }, + "seconds": { + "type": "integer", + "format": "int64", + "x-go-name": "Seconds" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "SubmitPullReviewOptions": { + "description": "SubmitPullReviewOptions are options to submit a pending pull review", + "type": "object", + "properties": { + "body": { + "type": "string", + "x-go-name": "Body" + }, + "event": { + "$ref": "#/definitions/ReviewStateType" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Tag": { + "description": "Tag represents a repository tag", + "type": "object", + "properties": { + "commit": { + "$ref": "#/definitions/CommitMeta" + }, + "id": { + "type": "string", + "x-go-name": "ID" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "tarball_url": { + "type": "string", + "x-go-name": "TarballURL" + }, + "zipball_url": { + "type": "string", + "x-go-name": "ZipballURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Team": { + "description": "Team represents a team in an organization", + "type": "object", + "properties": { + "can_create_org_repo": { + "type": "boolean", + "x-go-name": "CanCreateOrgRepo" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "includes_all_repositories": { + "type": "boolean", + "x-go-name": "IncludesAllRepositories" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "organization": { + "$ref": "#/definitions/Organization" + }, + "permission": { + "type": "string", + "enum": [ + "none", + "read", + "write", + "admin", + "owner" + ], + "x-go-name": "Permission" + }, + "units": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Units", + "example": [ + "repo.code", + "repo.issues", + "repo.ext_issues", + "repo.wiki", + "repo.pulls", + "repo.releases", + "repo.projects", + "repo.ext_wiki" + ] + }, + "units_map": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "UnitsMap", + "example": { + "repo.code": "read", + "repo.ext_issues": "none", + "repo.ext_wiki": "none", + "repo.issues": "write", + "repo.projects": "none", + "repo.pulls": "owner", + "repo.releases": "none", + "repo.wiki": "admin" + } + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "TimeStamp": { + "description": "TimeStamp defines a timestamp", + "type": "integer", + "format": "int64", + "x-go-package": "code.gitea.io/gitea/modules/timeutil" + }, + "TimelineComment": { + "description": "TimelineComment represents a timeline comment (comment of any type) on a commit or issue", + "type": "object", + "properties": { + "assignee": { + "$ref": "#/definitions/User" + }, + "assignee_team": { + "$ref": "#/definitions/Team" + }, + "body": { + "type": "string", + "x-go-name": "Body" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "dependent_issue": { + "$ref": "#/definitions/Issue" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "issue_url": { + "type": "string", + "x-go-name": "IssueURL" + }, + "label": { + "$ref": "#/definitions/Label" + }, + "milestone": { + "$ref": "#/definitions/Milestone" + }, + "new_ref": { + "type": "string", + "x-go-name": "NewRef" + }, + "new_title": { + "type": "string", + "x-go-name": "NewTitle" + }, + "old_milestone": { + "$ref": "#/definitions/Milestone" + }, + "old_project_id": { + "type": "integer", + "format": "int64", + "x-go-name": "OldProjectID" + }, + "old_ref": { + "type": "string", + "x-go-name": "OldRef" + }, + "old_title": { + "type": "string", + "x-go-name": "OldTitle" + }, + "project_id": { + "type": "integer", + "format": "int64", + "x-go-name": "ProjectID" + }, + "pull_request_url": { + "type": "string", + "x-go-name": "PRURL" + }, + "ref_action": { + "type": "string", + "x-go-name": "RefAction" + }, + "ref_comment": { + "$ref": "#/definitions/Comment" + }, + "ref_commit_sha": { + "description": "commit SHA where issue/PR was referenced", + "type": "string", + "x-go-name": "RefCommitSHA" + }, + "ref_issue": { + "$ref": "#/definitions/Issue" + }, + "removed_assignee": { + "description": "whether the assignees were removed or added", + "type": "boolean", + "x-go-name": "RemovedAssignee" + }, + "resolve_doer": { + "$ref": "#/definitions/User" + }, + "review_id": { + "type": "integer", + "format": "int64", + "x-go-name": "ReviewID" + }, + "tracked_time": { + "$ref": "#/definitions/TrackedTime" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "user": { + "$ref": "#/definitions/User" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "TopicName": { + "description": "TopicName a list of repo topic names", + "type": "object", + "properties": { + "topics": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "TopicNames" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "TopicResponse": { + "description": "TopicResponse for returning topics", + "type": "object", + "properties": { + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "repo_count": { + "type": "integer", + "format": "int64", + "x-go-name": "RepoCount" + }, + "topic_name": { + "type": "string", + "x-go-name": "Name" + }, + "updated": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "TrackedTime": { + "description": "TrackedTime worked time for an issue / pr", + "type": "object", + "properties": { + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "issue": { + "$ref": "#/definitions/Issue" + }, + "issue_id": { + "description": "deprecated (only for backwards compatibility)", + "type": "integer", + "format": "int64", + "x-go-name": "IssueID" + }, + "time": { + "description": "Time in seconds", + "type": "integer", + "format": "int64", + "x-go-name": "Time" + }, + "user_id": { + "description": "deprecated (only for backwards compatibility)", + "type": "integer", + "format": "int64", + "x-go-name": "UserID" + }, + "user_name": { + "type": "string", + "x-go-name": "UserName" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "TransferRepoOption": { + "description": "TransferRepoOption options when transfer a repository's ownership", + "type": "object", + "required": [ + "new_owner" + ], + "properties": { + "new_owner": { + "type": "string", + "x-go-name": "NewOwner" + }, + "team_ids": { + "description": "ID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories.", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "x-go-name": "TeamIDs" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "UpdateFileOptions": { + "description": "UpdateFileOptions options for updating files\nNote: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)", + "type": "object", + "required": [ + "sha", + "content" + ], + "properties": { + "author": { + "$ref": "#/definitions/Identity" + }, + "branch": { + "description": "branch (optional) to base this file from. if not given, the default branch is used", + "type": "string", + "x-go-name": "BranchName" + }, + "committer": { + "$ref": "#/definitions/Identity" + }, + "content": { + "description": "content must be base64 encoded", + "type": "string", + "x-go-name": "ContentBase64" + }, + "dates": { + "$ref": "#/definitions/CommitDateOptions" + }, + "from_path": { + "description": "from_path (optional) is the path of the original file which will be moved/renamed to the path in the URL", + "type": "string", + "x-go-name": "FromPath" + }, + "message": { + "description": "message (optional) for the commit of this file. if not supplied, a default message will be used", + "type": "string", + "x-go-name": "Message" + }, + "new_branch": { + "description": "new_branch (optional) will make a new branch from `branch` before creating the file", + "type": "string", + "x-go-name": "NewBranchName" + }, + "sha": { + "description": "sha is the SHA for the file that already exists", + "type": "string", + "x-go-name": "SHA" + }, + "signoff": { + "description": "Add a Signed-off-by trailer by the committer at the end of the commit log message.", + "type": "boolean", + "x-go-name": "Signoff" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "UpdateRepoAvatarOption": { + "description": "UpdateRepoAvatarUserOption options when updating the repo avatar", + "type": "object", + "properties": { + "image": { + "description": "image must be base64 encoded", + "type": "string", + "x-go-name": "Image" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "UpdateUserAvatarOption": { + "description": "UpdateUserAvatarUserOption options when updating the user avatar", + "type": "object", + "properties": { + "image": { + "description": "image must be base64 encoded", + "type": "string", + "x-go-name": "Image" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "User": { + "description": "User represents a user", + "type": "object", + "properties": { + "active": { + "description": "Is user active", + "type": "boolean", + "x-go-name": "IsActive" + }, + "avatar_url": { + "description": "URL to the user's avatar", + "type": "string", + "x-go-name": "AvatarURL" + }, + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "description": { + "description": "the user's description", + "type": "string", + "x-go-name": "Description" + }, + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "followers_count": { + "description": "user counts", + "type": "integer", + "format": "int64", + "x-go-name": "Followers" + }, + "following_count": { + "type": "integer", + "format": "int64", + "x-go-name": "Following" + }, + "full_name": { + "description": "the user's full name", + "type": "string", + "x-go-name": "FullName" + }, + "id": { + "description": "the user's id", + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "is_admin": { + "description": "Is the user an administrator", + "type": "boolean", + "x-go-name": "IsAdmin" + }, + "language": { + "description": "User locale", + "type": "string", + "x-go-name": "Language" + }, + "last_login": { + "type": "string", + "format": "date-time", + "x-go-name": "LastLogin" + }, + "location": { + "description": "the user's location", + "type": "string", + "x-go-name": "Location" + }, + "login": { + "description": "the user's username", + "type": "string", + "x-go-name": "UserName" + }, + "login_name": { + "description": "the user's authentication sign-in name.", + "type": "string", + "default": "empty", + "x-go-name": "LoginName" + }, + "prohibit_login": { + "description": "Is user login prohibited", + "type": "boolean", + "x-go-name": "ProhibitLogin" + }, + "restricted": { + "description": "Is user restricted", + "type": "boolean", + "x-go-name": "Restricted" + }, + "starred_repos_count": { + "type": "integer", + "format": "int64", + "x-go-name": "StarredRepos" + }, + "visibility": { + "description": "User visibility level option: public, limited, private", + "type": "string", + "x-go-name": "Visibility" + }, + "website": { + "description": "the user's website", + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "UserHeatmapData": { + "description": "UserHeatmapData represents the data needed to create a heatmap", + "type": "object", + "properties": { + "contributions": { + "type": "integer", + "format": "int64", + "x-go-name": "Contributions" + }, + "timestamp": { + "$ref": "#/definitions/TimeStamp" + } + }, + "x-go-package": "code.gitea.io/gitea/models/activities" + }, + "UserSettings": { + "description": "UserSettings represents user settings", + "type": "object", + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "diff_view_style": { + "type": "string", + "x-go-name": "DiffViewStyle" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "hide_activity": { + "type": "boolean", + "x-go-name": "HideActivity" + }, + "hide_email": { + "description": "Privacy", + "type": "boolean", + "x-go-name": "HideEmail" + }, + "language": { + "type": "string", + "x-go-name": "Language" + }, + "location": { + "type": "string", + "x-go-name": "Location" + }, + "theme": { + "type": "string", + "x-go-name": "Theme" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "UserSettingsOptions": { + "description": "UserSettingsOptions represents options to change user settings", + "type": "object", + "properties": { + "description": { + "type": "string", + "x-go-name": "Description" + }, + "diff_view_style": { + "type": "string", + "x-go-name": "DiffViewStyle" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "hide_activity": { + "type": "boolean", + "x-go-name": "HideActivity" + }, + "hide_email": { + "description": "Privacy", + "type": "boolean", + "x-go-name": "HideEmail" + }, + "language": { + "type": "string", + "x-go-name": "Language" + }, + "location": { + "type": "string", + "x-go-name": "Location" + }, + "theme": { + "type": "string", + "x-go-name": "Theme" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "WatchInfo": { + "description": "WatchInfo represents an API watch status of one repository", + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "CreatedAt" + }, + "ignored": { + "type": "boolean", + "x-go-name": "Ignored" + }, + "reason": { + "x-go-name": "Reason" + }, + "repository_url": { + "type": "string", + "x-go-name": "RepositoryURL" + }, + "subscribed": { + "type": "boolean", + "x-go-name": "Subscribed" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "WikiCommit": { + "description": "WikiCommit page commit/revision", + "type": "object", + "properties": { + "author": { + "$ref": "#/definitions/CommitUser" + }, + "commiter": { + "$ref": "#/definitions/CommitUser" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "sha": { + "type": "string", + "x-go-name": "ID" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "WikiCommitList": { + "description": "WikiCommitList commit/revision list", + "type": "object", + "properties": { + "commits": { + "type": "array", + "items": { + "$ref": "#/definitions/WikiCommit" + }, + "x-go-name": "WikiCommits" + }, + "count": { + "type": "integer", + "format": "int64", + "x-go-name": "Count" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "WikiPage": { + "description": "WikiPage a wiki page", + "type": "object", + "properties": { + "commit_count": { + "type": "integer", + "format": "int64", + "x-go-name": "CommitCount" + }, + "content_base64": { + "description": "Page content, base64 encoded", + "type": "string", + "x-go-name": "ContentBase64" + }, + "footer": { + "type": "string", + "x-go-name": "Footer" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "last_commit": { + "$ref": "#/definitions/WikiCommit" + }, + "sidebar": { + "type": "string", + "x-go-name": "Sidebar" + }, + "sub_url": { + "type": "string", + "x-go-name": "SubURL" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "WikiPageMetaData": { + "description": "WikiPageMetaData wiki page meta information", + "type": "object", + "properties": { + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "last_commit": { + "$ref": "#/definitions/WikiCommit" + }, + "sub_url": { + "type": "string", + "x-go-name": "SubURL" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + } + }, + "responses": { + "AccessToken": { + "description": "AccessToken represents an API access token.", + "schema": { + "$ref": "#/definitions/AccessToken" + } + }, + "AccessTokenList": { + "description": "AccessTokenList represents a list of API access token.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/AccessToken" + } + } + }, + "ActivityFeedsList": { + "description": "ActivityFeedsList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Activity" + } + } + }, + "ActivityPub": { + "description": "ActivityPub", + "schema": { + "$ref": "#/definitions/ActivityPub" + } + }, + "AnnotatedTag": { + "description": "AnnotatedTag", + "schema": { + "$ref": "#/definitions/AnnotatedTag" + } + }, + "Attachment": { + "description": "Attachment", + "schema": { + "$ref": "#/definitions/Attachment" + } + }, + "AttachmentList": { + "description": "AttachmentList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Attachment" + } + } + }, + "BlockedUserList": { + "description": "BlockedUserList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/BlockedUser" + } + } + }, + "Branch": { + "description": "Branch", + "schema": { + "$ref": "#/definitions/Branch" + } + }, + "BranchList": { + "description": "BranchList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Branch" + } + } + }, + "BranchProtection": { + "description": "BranchProtection", + "schema": { + "$ref": "#/definitions/BranchProtection" + } + }, + "BranchProtectionList": { + "description": "BranchProtectionList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/BranchProtection" + } + } + }, + "ChangedFileList": { + "description": "ChangedFileList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ChangedFile" + } + }, + "headers": { + "X-HasMore": { + "type": "boolean", + "description": "True if there is another page" + }, + "X-Page": { + "type": "integer", + "format": "int64", + "description": "The current page" + }, + "X-PageCount": { + "type": "integer", + "format": "int64", + "description": "Total number of pages" + }, + "X-PerPage": { + "type": "integer", + "format": "int64", + "description": "Commits per page" + }, + "X-Total": { + "type": "integer", + "format": "int64", + "description": "Total commit count" + } + } + }, + "CombinedStatus": { + "description": "CombinedStatus", + "schema": { + "$ref": "#/definitions/CombinedStatus" + } + }, + "Comment": { + "description": "Comment", + "schema": { + "$ref": "#/definitions/Comment" + } + }, + "CommentList": { + "description": "CommentList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Comment" + } + } + }, + "Commit": { + "description": "Commit", + "schema": { + "$ref": "#/definitions/Commit" + } + }, + "CommitList": { + "description": "CommitList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Commit" + } + }, + "headers": { + "X-HasMore": { + "type": "boolean", + "description": "True if there is another page" + }, + "X-Page": { + "type": "integer", + "format": "int64", + "description": "The current page" + }, + "X-PageCount": { + "type": "integer", + "format": "int64", + "description": "Total number of pages" + }, + "X-PerPage": { + "type": "integer", + "format": "int64", + "description": "Commits per page" + }, + "X-Total": { + "type": "integer", + "format": "int64", + "description": "Total commit count" + } + } + }, + "CommitStatus": { + "description": "CommitStatus", + "schema": { + "$ref": "#/definitions/CommitStatus" + } + }, + "CommitStatusList": { + "description": "CommitStatusList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/CommitStatus" + } + } + }, + "ContentsListResponse": { + "description": "ContentsListResponse", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ContentsResponse" + } + } + }, + "ContentsResponse": { + "description": "ContentsResponse", + "schema": { + "$ref": "#/definitions/ContentsResponse" + } + }, + "CronList": { + "description": "CronList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Cron" + } + } + }, + "DeployKey": { + "description": "DeployKey", + "schema": { + "$ref": "#/definitions/DeployKey" + } + }, + "DeployKeyList": { + "description": "DeployKeyList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/DeployKey" + } + } + }, + "EmailList": { + "description": "EmailList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Email" + } + } + }, + "EmptyRepository": { + "description": "EmptyRepository", + "schema": { + "$ref": "#/definitions/APIError" + } + }, + "FileDeleteResponse": { + "description": "FileDeleteResponse", + "schema": { + "$ref": "#/definitions/FileDeleteResponse" + } + }, + "FileResponse": { + "description": "FileResponse", + "schema": { + "$ref": "#/definitions/FileResponse" + } + }, + "FilesResponse": { + "description": "FilesResponse", + "schema": { + "$ref": "#/definitions/FilesResponse" + } + }, + "GPGKey": { + "description": "GPGKey", + "schema": { + "$ref": "#/definitions/GPGKey" + } + }, + "GPGKeyList": { + "description": "GPGKeyList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/GPGKey" + } + } + }, + "GeneralAPISettings": { + "description": "GeneralAPISettings", + "schema": { + "$ref": "#/definitions/GeneralAPISettings" + } + }, + "GeneralAttachmentSettings": { + "description": "GeneralAttachmentSettings", + "schema": { + "$ref": "#/definitions/GeneralAttachmentSettings" + } + }, + "GeneralRepoSettings": { + "description": "GeneralRepoSettings", + "schema": { + "$ref": "#/definitions/GeneralRepoSettings" + } + }, + "GeneralUISettings": { + "description": "GeneralUISettings", + "schema": { + "$ref": "#/definitions/GeneralUISettings" + } + }, + "GitBlobResponse": { + "description": "GitBlobResponse", + "schema": { + "$ref": "#/definitions/GitBlobResponse" + } + }, + "GitHook": { + "description": "GitHook", + "schema": { + "$ref": "#/definitions/GitHook" + } + }, + "GitHookList": { + "description": "GitHookList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/GitHook" + } + } + }, + "GitTreeResponse": { + "description": "GitTreeResponse", + "schema": { + "$ref": "#/definitions/GitTreeResponse" + } + }, + "GitignoreTemplateInfo": { + "description": "GitignoreTemplateInfo", + "schema": { + "$ref": "#/definitions/GitignoreTemplateInfo" + } + }, + "GitignoreTemplateList": { + "description": "GitignoreTemplateList", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "Hook": { + "description": "Hook", + "schema": { + "$ref": "#/definitions/Hook" + } + }, + "HookList": { + "description": "HookList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Hook" + } + } + }, + "Issue": { + "description": "Issue", + "schema": { + "$ref": "#/definitions/Issue" + } + }, + "IssueDeadline": { + "description": "IssueDeadline", + "schema": { + "$ref": "#/definitions/IssueDeadline" + } + }, + "IssueList": { + "description": "IssueList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Issue" + } + } + }, + "IssueTemplates": { + "description": "IssueTemplates", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/IssueTemplate" + } + } + }, + "Label": { + "description": "Label", + "schema": { + "$ref": "#/definitions/Label" + } + }, + "LabelList": { + "description": "LabelList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + } + } + }, + "LabelTemplateInfo": { + "description": "LabelTemplateInfo", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/LabelTemplate" + } + } + }, + "LabelTemplateList": { + "description": "LabelTemplateList", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "LanguageStatistics": { + "description": "LanguageStatistics", + "schema": { + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int64" + } + } + }, + "LicenseTemplateInfo": { + "description": "LicenseTemplateInfo", + "schema": { + "$ref": "#/definitions/LicenseTemplateInfo" + } + }, + "LicenseTemplateList": { + "description": "LicenseTemplateList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/LicensesTemplateListEntry" + } + } + }, + "MarkdownRender": { + "description": "MarkdownRender is a rendered markdown document", + "schema": { + "type": "string" + } + }, + "MarkupRender": { + "description": "MarkupRender is a rendered markup document", + "schema": { + "type": "string" + } + }, + "Milestone": { + "description": "Milestone", + "schema": { + "$ref": "#/definitions/Milestone" + } + }, + "MilestoneList": { + "description": "MilestoneList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Milestone" + } + } + }, + "NodeInfo": { + "description": "NodeInfo", + "schema": { + "$ref": "#/definitions/NodeInfo" + } + }, + "Note": { + "description": "Note", + "schema": { + "$ref": "#/definitions/Note" + } + }, + "NotificationCount": { + "description": "Number of unread notifications", + "schema": { + "$ref": "#/definitions/NotificationCount" + } + }, + "NotificationThread": { + "description": "NotificationThread", + "schema": { + "$ref": "#/definitions/NotificationThread" + } + }, + "NotificationThreadList": { + "description": "NotificationThreadList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/NotificationThread" + } + } + }, + "OAuth2Application": { + "description": "OAuth2Application", + "schema": { + "$ref": "#/definitions/OAuth2Application" + } + }, + "OAuth2ApplicationList": { + "description": "OAuth2ApplicationList represents a list of OAuth2 applications.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/OAuth2Application" + } + } + }, + "Organization": { + "description": "Organization", + "schema": { + "$ref": "#/definitions/Organization" + } + }, + "OrganizationList": { + "description": "OrganizationList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Organization" + } + } + }, + "OrganizationPermissions": { + "description": "OrganizationPermissions", + "schema": { + "$ref": "#/definitions/OrganizationPermissions" + } + }, + "Package": { + "description": "Package", + "schema": { + "$ref": "#/definitions/Package" + } + }, + "PackageFileList": { + "description": "PackageFileList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PackageFile" + } + } + }, + "PackageList": { + "description": "PackageList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Package" + } + } + }, + "PublicKey": { + "description": "PublicKey", + "schema": { + "$ref": "#/definitions/PublicKey" + } + }, + "PublicKeyList": { + "description": "PublicKeyList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PublicKey" + } + } + }, + "PullRequest": { + "description": "PullRequest", + "schema": { + "$ref": "#/definitions/PullRequest" + } + }, + "PullRequestList": { + "description": "PullRequestList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PullRequest" + } + } + }, + "PullReview": { + "description": "PullReview", + "schema": { + "$ref": "#/definitions/PullReview" + } + }, + "PullReviewComment": { + "description": "PullComment", + "schema": { + "$ref": "#/definitions/PullReviewComment" + } + }, + "PullReviewCommentList": { + "description": "PullCommentList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PullReviewComment" + } + } + }, + "PullReviewList": { + "description": "PullReviewList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PullReview" + } + } + }, + "PushMirror": { + "description": "PushMirror", + "schema": { + "$ref": "#/definitions/PushMirror" + } + }, + "PushMirrorList": { + "description": "PushMirrorList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PushMirror" + } + } + }, + "Reaction": { + "description": "Reaction", + "schema": { + "$ref": "#/definitions/Reaction" + } + }, + "ReactionList": { + "description": "ReactionList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Reaction" + } + } + }, + "Reference": { + "description": "Reference", + "schema": { + "$ref": "#/definitions/Reference" + } + }, + "ReferenceList": { + "description": "ReferenceList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + } + }, + "Release": { + "description": "Release", + "schema": { + "$ref": "#/definitions/Release" + } + }, + "ReleaseList": { + "description": "ReleaseList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Release" + } + } + }, + "RepoCollaboratorPermission": { + "description": "RepoCollaboratorPermission", + "schema": { + "$ref": "#/definitions/RepoCollaboratorPermission" + } + }, + "RepoIssueConfig": { + "description": "RepoIssueConfig", + "schema": { + "$ref": "#/definitions/IssueConfig" + } + }, + "RepoIssueConfigValidation": { + "description": "RepoIssueConfigValidation", + "schema": { + "$ref": "#/definitions/IssueConfigValidation" + } + }, + "RepoNewIssuePinsAllowed": { + "description": "RepoNewIssuePinsAllowed", + "schema": { + "$ref": "#/definitions/NewIssuePinsAllowed" + } + }, + "Repository": { + "description": "Repository", + "schema": { + "$ref": "#/definitions/Repository" + } + }, + "RepositoryList": { + "description": "RepositoryList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Repository" + } + } + }, + "SearchResults": { + "description": "SearchResults", + "schema": { + "$ref": "#/definitions/SearchResults" + } + }, + "Secret": { + "description": "Secret", + "schema": { + "$ref": "#/definitions/Secret" + } + }, + "SecretList": { + "description": "SecretList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Secret" + } + } + }, + "ServerVersion": { + "description": "ServerVersion", + "schema": { + "$ref": "#/definitions/ServerVersion" + } + }, + "StopWatch": { + "description": "StopWatch", + "schema": { + "$ref": "#/definitions/StopWatch" + } + }, + "StopWatchList": { + "description": "StopWatchList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/StopWatch" + } + } + }, + "StringSlice": { + "description": "StringSlice", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "Tag": { + "description": "Tag", + "schema": { + "$ref": "#/definitions/Tag" + } + }, + "TagList": { + "description": "TagList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Tag" + } + } + }, + "Team": { + "description": "Team", + "schema": { + "$ref": "#/definitions/Team" + } + }, + "TeamList": { + "description": "TeamList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Team" + } + } + }, + "TimelineList": { + "description": "TimelineList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/TimelineComment" + } + } + }, + "TopicListResponse": { + "description": "TopicListResponse", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/TopicResponse" + } + } + }, + "TopicNames": { + "description": "TopicNames", + "schema": { + "$ref": "#/definitions/TopicName" + } + }, + "TrackedTime": { + "description": "TrackedTime", + "schema": { + "$ref": "#/definitions/TrackedTime" + } + }, + "TrackedTimeList": { + "description": "TrackedTimeList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/TrackedTime" + } + } + }, + "User": { + "description": "User", + "schema": { + "$ref": "#/definitions/User" + } + }, + "UserHeatmapData": { + "description": "UserHeatmapData", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserHeatmapData" + } + } + }, + "UserList": { + "description": "UserList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + } + }, + "UserSettings": { + "description": "UserSettings", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserSettings" + } + } + }, + "WatchInfo": { + "description": "WatchInfo", + "schema": { + "$ref": "#/definitions/WatchInfo" + } + }, + "WikiCommitList": { + "description": "WikiCommitList", + "schema": { + "$ref": "#/definitions/WikiCommitList" + } + }, + "WikiPage": { + "description": "WikiPage", + "schema": { + "$ref": "#/definitions/WikiPage" + } + }, + "WikiPageList": { + "description": "WikiPageList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/WikiPageMetaData" + } + } + }, + "conflict": { + "description": "APIConflict is a conflict empty response" + }, + "empty": { + "description": "APIEmpty is an empty response" + }, + "error": { + "description": "APIError is error format response", + "headers": { + "message": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, + "forbidden": { + "description": "APIForbiddenError is a forbidden error response", + "headers": { + "message": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, + "invalidTopicsError": { + "description": "APIInvalidTopicsError is error format response to invalid topics", + "headers": { + "invalidTopics": { + "type": "array", + "items": { + "type": "string" + } + }, + "message": { + "type": "string" + } + } + }, + "notFound": { + "description": "APINotFound is a not found empty response" + }, + "parameterBodies": { + "description": "parameterBodies", + "schema": { + "$ref": "#/definitions/CreateOrUpdateSecretOption" + } + }, + "redirect": { + "description": "APIRedirect is a redirect response" + }, + "string": { + "description": "APIString is a string response", + "schema": { + "type": "string" + } + }, + "validationError": { + "description": "APIValidationError is error format response related to input validation", + "headers": { + "message": { + "type": "string" + }, + "url": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "AccessToken": { + "type": "apiKey", + "name": "access_token", + "in": "query" + }, + "AuthorizationHeaderToken": { + "description": "API tokens must be prepended with \"token\" followed by a space.", + "type": "apiKey", + "name": "Authorization", + "in": "header" + }, + "BasicAuth": { + "type": "basic" + }, + "SudoHeader": { + "description": "Sudo API request as the user provided as the key. Admin privileges are required.", + "type": "apiKey", + "name": "Sudo", + "in": "header" + }, + "SudoParam": { + "description": "Sudo API request as the user provided as the key. Admin privileges are required.", + "type": "apiKey", + "name": "sudo", + "in": "query" + }, + "TOTPHeader": { + "description": "Must be used in combination with BasicAuth if two-factor authentication is enabled.", + "type": "apiKey", + "name": "X-FORGEJO-OTP", + "in": "header" + }, + "Token": { + "type": "apiKey", + "name": "token", + "in": "query" + } + }, + "security": [ + { + "BasicAuth": [] + }, + { + "Token": [] + }, + { + "AccessToken": [] + }, + { + "AuthorizationHeaderToken": [] + }, + { + "SudoParam": [] + }, + { + "SudoHeader": [] + }, + { + "TOTPHeader": [] + } + ] +} From f8737defc6bc9cdbc2ba90941efe3101b0bb8bb2 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Wed, 10 Jan 2024 22:42:05 -0500 Subject: [PATCH 02/86] format --- generator/src/openapi.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/generator/src/openapi.rs b/generator/src/openapi.rs index effe561..3301edb 100644 --- a/generator/src/openapi.rs +++ b/generator/src/openapi.rs @@ -296,7 +296,7 @@ pub enum SecurityType { #[serde(flatten)] flow: OAuth2Flow, scopes: BTreeMap, - } + }, } #[derive(serde::Deserialize, Debug, PartialEq)] @@ -312,13 +312,13 @@ pub enum OAuth2Flow { Implicit { authorization_url: Url, }, - Password{ + Password { token_url: Url, }, - Application{ + Application { token_url: Url, }, - AccessCode{ + AccessCode { authorization_url: Url, token_url: Url, }, @@ -334,5 +334,5 @@ pub enum MaybeRef { Ref { #[serde(rename = "$ref")] _ref: String, - } + }, } From b98426f90783a8c3976f0eddcd882ff8caae9d44 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Wed, 10 Jan 2024 22:45:59 -0500 Subject: [PATCH 03/86] strongly type `Parameter.in` --- generator/src/openapi.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/generator/src/openapi.rs b/generator/src/openapi.rs index 3301edb..0540688 100644 --- a/generator/src/openapi.rs +++ b/generator/src/openapi.rs @@ -92,7 +92,7 @@ pub struct ExternalDocs { pub struct Parameter { pub name: String, #[serde(rename = "in")] - pub _in: String, + pub _in: ParameterIn, pub description: Option, pub required: Option, pub schema: Option>, @@ -118,6 +118,16 @@ pub struct Parameter { pub multiple_of: Option, } +#[derive(serde::Deserialize, Debug, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +pub enum ParameterIn { + Path, + Query, + Header, + Body, + FormData, +} + #[derive(serde::Deserialize, Debug, PartialEq)] #[serde(rename_all(deserialize = "camelCase"))] pub enum ParameterType { From 9bb65d760922af74bcd6cc51c4ec7319a4c01e36 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Mon, 15 Jan 2024 15:51:21 -0500 Subject: [PATCH 04/86] prioritize ref when deserializing `MaybeRef` --- generator/src/openapi.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generator/src/openapi.rs b/generator/src/openapi.rs index 0540688..843a20d 100644 --- a/generator/src/openapi.rs +++ b/generator/src/openapi.rs @@ -337,12 +337,12 @@ pub enum OAuth2Flow { #[derive(serde::Deserialize, Debug, PartialEq)] #[serde(untagged)] pub enum MaybeRef { - Value { - #[serde(flatten)] - value: T, - }, Ref { #[serde(rename = "$ref")] _ref: String, }, + Value { + #[serde(flatten)] + value: T, + }, } From 769521840e992451778966bb7c2a1f5eaa5541a8 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 00:09:22 -0500 Subject: [PATCH 05/86] add method generation --- Cargo.lock | 7 + generator/Cargo.toml | 1 + generator/src/main.rs | 548 ++++++++++++++++++++++++++++++++++++++- generator/src/openapi.rs | 4 +- 4 files changed, 555 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47254d3..ea64452 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -242,6 +242,7 @@ name = "generator" version = "0.1.0" dependencies = [ "eyre", + "heck", "serde", "serde_json", "url", @@ -278,6 +279,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "http" version = "0.2.9" diff --git a/generator/Cargo.toml b/generator/Cargo.toml index 91f832e..21821e0 100644 --- a/generator/Cargo.toml +++ b/generator/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] eyre = "0.6.11" +heck = "0.4.1" serde = { version = "1.0.195", features = ["derive"] } serde_json = "1.0.111" url = { version = "2.5.0", features = ["serde"] } diff --git a/generator/src/main.rs b/generator/src/main.rs index 3d5900c..79fd479 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -2,16 +2,556 @@ use std::ffi::OsString; mod openapi; +use eyre::Context; +use heck::{ToPascalCase, ToSnakeCase}; +use openapi::{ + MaybeRef, OpenApiV2, Operation, Parameter, ParameterIn, ParameterType, Primitive, Response, + Schema, SchemaType, +}; +use std::fmt::Write; + fn main() -> eyre::Result<()> { let spec = get_spec()?; - dbg!(spec); + let mut s = String::new(); + s.push_str("impl Forgejo {\n"); + for (path, item) in &spec.paths { + s.push_str(&create_methods_for_path(&spec, path, item).wrap_err_with(|| path.clone())?); + } + s.push('}'); + save_generated(&mut s)?; Ok(()) } -fn get_spec() -> eyre::Result { +fn get_spec() -> eyre::Result { let path = std::env::var_os("FORGEJO_API_SPEC_PATH") - .unwrap_or_else(|| OsString::from("./api_spec.json")); + .unwrap_or_else(|| OsString::from("./swagger.v1.json")); let file = std::fs::read(path)?; - let spec = serde_json::from_slice::(&file)?; + let spec = serde_json::from_slice::(&file)?; Ok(spec) } + +fn save_generated(contents: &str) -> eyre::Result<()> { + let path = std::env::var_os("FORGEJO_API_GENERATED_PATH") + .unwrap_or_else(|| OsString::from("./src/generated.rs")); + std::fs::write(path, contents)?; + Ok(()) +} + +fn create_methods_for_path( + spec: &OpenApiV2, + path: &str, + item: &openapi::PathItem, +) -> eyre::Result { + let mut s = String::new(); + if let Some(op) = &item.get { + s.push_str(&create_get_method(spec, path, op).wrap_err("GET")?); + } + if let Some(op) = &item.put { + s.push_str(&create_put_method(spec, path, op).wrap_err("PUT")?); + } + if let Some(op) = &item.post { + s.push_str(&create_post_method(spec, path, op).wrap_err("POST")?); + } + if let Some(op) = &item.delete { + s.push_str(&create_delete_method(spec, path, op).wrap_err("DELETE")?); + } + if let Some(op) = &item.options { + s.push_str(&create_options_method(spec, path, op).wrap_err("OPTIONS")?); + } + if let Some(op) = &item.head { + s.push_str(&create_head_method(spec, path, op).wrap_err("HEAD")?); + } + if let Some(op) = &item.patch { + s.push_str(&create_patch_method(spec, path, op).wrap_err("PATCH")?); + } + Ok(s) +} + +fn fn_signature_from_op(spec: &OpenApiV2, op: &Operation) -> eyre::Result { + let name = op + .operation_id + .as_deref() + .ok_or_else(|| eyre::eyre!("operation did not have id"))? + .to_snake_case() + .replace("o_auth2", "oauth2"); + let args = fn_args_from_op(spec, op)?; + let ty = fn_return_from_op(spec, op)?; + Ok(format!("fn {name}({args}) -> Result<{ty}, ForgejoError>")) +} + +fn fn_args_from_op(spec: &OpenApiV2, op: &Operation) -> eyre::Result { + let mut args = "&self".to_string(); + let mut has_query = false; + let mut has_headers = false; + let mut has_form = false; + if let Some(params) = &op.parameters { + for param in params { + let param = match ¶m { + MaybeRef::Value { value } => value, + MaybeRef::Ref { _ref } => eyre::bail!("todo: add deref parameters"), + }; + match param._in { + ParameterIn::Path => { + let type_name = path_param_type(¶m)?; + args.push_str(", "); + args.push_str(&sanitize_ident(param.name.to_snake_case())); + args.push_str(": "); + args.push_str(type_name); + } + ParameterIn::Query => has_query = true, + ParameterIn::Header => has_headers = true, + ParameterIn::Body => { + let schema_ref = param.schema.as_ref().unwrap(); + let ty = schema_ref_type_name(spec, &schema_ref)?; + args.push_str(", "); + args.push_str(&sanitize_ident(param.name.to_snake_case())); + args.push_str(": "); + args.push_str(&ty); + } + ParameterIn::FormData => { + args.push_str(", "); + args.push_str(&sanitize_ident(param.name.to_snake_case())); + args.push_str(": Vec"); + } + } + } + } + if has_query { + let query_ty = query_struct_name(op)?; + args.push_str(", query: "); + args.push_str(&query_ty); + } + Ok(args) +} + +fn query_struct_name(op: &Operation) -> eyre::Result { + let mut ty = op + .operation_id + .as_deref() + .ok_or_else(|| eyre::eyre!("operation did not have id"))? + .to_pascal_case() + .replace("o_auth2", "oauth2"); + ty.push_str("Query"); + Ok(ty) +} + +fn fn_return_from_op(spec: &OpenApiV2, op: &Operation) -> eyre::Result { + let mut names = op + .responses + .http_codes + .iter() + .filter(|(k, _)| k.starts_with("2")) + .map(|(_, v)| response_ref_type_name(spec, v)) + .collect::, _>>()?; + + names.sort(); + names.dedup(); + let name = match names.len() { + 0 => eyre::bail!("no type name found"), + 1 => { + let name = names.pop().unwrap(); + if name == "empty" { + "()".into() + } else { + name + } + } + 2 if names[0] == "empty" || names[1] == "empty" => { + let name = if names[0] == "empty" { + names.remove(1) + } else { + names.remove(0) + }; + format!("Option<{name}>") + } + _ => eyre::bail!("too many possible return types"), + }; + + Ok(name) +} + +fn response_ref_type_name(spec: &OpenApiV2, schema: &MaybeRef) -> eyre::Result { + let (name, response) = deref_response(spec, schema)?; + if let Some(schema) = &response.schema { + schema_ref_type_name(spec, schema) + } else if let Some(name) = name { + Ok(name.into()) + } else { + Ok("()".into()) + } +} + +fn schema_ref_type_name(spec: &OpenApiV2, schema: &MaybeRef) -> eyre::Result { + let (name, schema) = deref_definition(spec, &schema)?; + schema_type_name(spec, name, schema) +} + +fn schema_type_name( + spec: &OpenApiV2, + definition_name: Option<&str>, + schema: &Schema, +) -> eyre::Result { + if let Some(ty) = &schema._type { + match ty { + SchemaType::One(prim) => { + let name = match prim { + Primitive::String => match schema.format.as_deref() { + Some("date") => "time::Date", + Some("date-time") => "time::OffsetDateTime", + _ => "String", + } + .to_string(), + Primitive::Number => match schema.format.as_deref() { + Some("float") => "f32", + Some("double") => "f64", + _ => "f64", + } + .to_string(), + Primitive::Integer => match schema.format.as_deref() { + Some("int32") => "u32", + Some("int64") => "u64", + _ => "u32", + } + .to_string(), + Primitive::Boolean => "bool".to_string(), + Primitive::Array => { + let item_name = match &schema.items { + Some(item_schema) => schema_ref_type_name(spec, item_schema)?, + None => "serde_json::Value".into(), + }; + format!("Vec<{item_name}>") + } + Primitive::Null => "()".to_string(), + Primitive::Object => { + match (&schema.title, definition_name) { + // Some of the titles are actually descriptions; not sure why + // Checking for a space filters that out + (Some(title), _) if !title.contains(' ') => title.to_string(), + (_, Some(definition_name)) => definition_name.to_string(), + (_, None) => "serde_json::Map".to_string(), + } + } + }; + Ok(name.to_owned()) + } + SchemaType::List(list) => todo!(), + } + } else { + Ok("()".into()) + } +} + +fn path_param_type(param: &Parameter) -> eyre::Result<&'static str> { + let _type = param + ._type + .as_ref() + .ok_or_else(|| eyre::eyre!("no type provided for path param"))?; + let type_name = match _type { + ParameterType::String => match param.format.as_deref() { + Some("date") => "time::Date", + Some("date-time") => "time::OffsetDateTime", + _ => "&str", + }, + ParameterType::Number => match param.format.as_deref() { + Some("float") => "f32", + Some("double") => "f64", + _ => "f64", + }, + ParameterType::Integer => match param.format.as_deref() { + Some("int32") => "u32", + Some("int64") => "u64", + _ => "u32", + }, + ParameterType::Boolean => "bool", + ParameterType::Array => eyre::bail!("todo: support returning arrays"), + ParameterType::File => "Vec", + }; + Ok(type_name) +} + +fn method_docs(op: &Operation) -> eyre::Result { + let mut out = String::new(); + let mut prev = false; + if let Some(summary) = &op.summary { + write!(&mut out, "/// {summary}\n")?; + prev = true; + } + if let Some(params) = &op.parameters { + if prev { + out.push_str("///\n"); + } + for param in params { + let param = match ¶m { + MaybeRef::Value { value } => value, + MaybeRef::Ref { _ref } => eyre::bail!("pipis"), + }; + match param._in { + ParameterIn::Path | ParameterIn::Body | ParameterIn::FormData => { + write!(&mut out, "/// - `{}`", param.name)?; + if let Some(description) = ¶m.description { + write!(&mut out, ": {}", description)?; + } + writeln!(&mut out)?; + } + _ => (), + } + } + } + Ok(out) +} + +fn deref_response<'a>( + spec: &'a OpenApiV2, + r: &'a MaybeRef, +) -> eyre::Result<(Option<&'a str>, &'a Response)> { + let r = match r { + MaybeRef::Value { value } => return Ok((None, value)), + MaybeRef::Ref { _ref } => _ref, + }; + let name = r + .strip_prefix("#/responses/") + .ok_or_else(|| eyre::eyre!("invalid response reference"))?; + let global_responses = spec + .responses + .as_ref() + .ok_or_else(|| eyre::eyre!("no global responses"))?; + let response = global_responses + .get(name) + .ok_or_else(|| eyre::eyre!("referenced response does not exist"))?; + Ok((Some(name), response)) +} + +fn deref_definition<'a>( + spec: &'a OpenApiV2, + r: &'a MaybeRef, +) -> eyre::Result<(Option<&'a str>, &'a Schema)> { + let r = match r { + MaybeRef::Value { value } => return Ok((None, value)), + MaybeRef::Ref { _ref } => _ref, + }; + let name = r + .strip_prefix("#/definitions/") + .ok_or_else(|| eyre::eyre!("invalid definition reference"))?; + let global_definitions = spec + .definitions + .as_ref() + .ok_or_else(|| eyre::eyre!("no global definitions"))?; + let definition = global_definitions + .get(name) + .ok_or_else(|| eyre::eyre!("referenced definition does not exist"))?; + Ok((Some(name), definition)) +} + +fn create_method_body( + spec: &OpenApiV2, + method: &str, + path: &str, + op: &Operation, +) -> eyre::Result { + let request = create_method_request(spec, method, path, op)?; + let response = create_method_response(spec, method, path, op)?; + Ok(format!("{request}\n {response}")) +} + +fn create_method_request( + spec: &OpenApiV2, + method: &str, + path: &str, + op: &Operation, +) -> eyre::Result { + let mut has_query = false; + let mut has_headers = false; + let mut body_method = String::new(); + if let Some(params) = &op.parameters { + for param in params { + let param = match ¶m { + MaybeRef::Value { value } => value, + MaybeRef::Ref { _ref } => eyre::bail!("todo: add deref parameters"), + }; + match param._in { + ParameterIn::Path => (/* do nothing */), + ParameterIn::Query => has_query = true, + ParameterIn::Header => has_headers = true, + ParameterIn::Body => { + if !body_method.is_empty() { + eyre::bail!("cannot have more than one body parameter"); + } + if param_is_string(spec, param)? { + body_method = format!(".body({})", param.name); + } else { + body_method = format!(".json({})?", param.name); + } + } + ParameterIn::FormData => { + if !body_method.is_empty() { + eyre::bail!("cannot have more than one body parameter"); + } + body_method = format!(".multipart(reqwest::multipart::Form::new().part(\"attachment\", reqwest::multipart::Part::bytes({}).file_name(\"file\").mime_str(\"*/*\").unwrap()))", param.name); + } + } + } + } + let mut fmt_str = path.to_string(); + let mut fmt_args = String::new(); + if has_query { + fmt_str.push_str("?{}"); + fmt_args.push_str(", query"); + } + let path_arg = if fmt_str.contains("{") { + format!("&format!(\"{fmt_str}\"{fmt_args})") + } else { + format!("\"{fmt_str}\"") + }; + + let out = format!("let request = self.{method}({path_arg}){body_method}.build()?;"); + Ok(out) +} + +fn create_method_response( + spec: &OpenApiV2, + method: &str, + path: &str, + op: &Operation, +) -> eyre::Result { + let mut has_empty = false; + let mut only_empty = true; + for (_, res) in &op.responses.http_codes { + let name = response_ref_type_name(spec, res)?; + if name == "()" || name == "empty" { + has_empty = true; + } else { + only_empty = false; + } + } + let optional = has_empty && !only_empty; + let mut out = String::new(); + out.push_str("let response = self.execute(request).await?;\n"); + out.push_str("match response.status().as_u16() {\n"); + for (code, res) in &op.responses.http_codes { + let (_, res) = deref_response(spec, res)?; + if code.starts_with("4") { + continue; + } + out.push_str(code); + out.push_str(" => "); + let handler = match &res.schema { + Some(schema) if schema_is_string(spec, schema)? => { + if optional { + "Ok(Some(response.text().await?))" + } else { + "Ok(response.text().await?)" + } + } + Some(_) => { + if optional { + "Ok(Some(response.json().await?))" + } else { + "Ok(response.json().await?)" + } + } + None => { + if optional { + "Ok(None)" + } else { + "Ok(())" + } + } + }; + out.push_str(handler); + out.push_str(",\n"); + } + out.push_str("_ => Err(ForgejoError::UnexpectedStatusCode)\n"); + out.push_str("}\n"); + + Ok(out) +} + +fn schema_is_string(spec: &OpenApiV2, schema: &MaybeRef) -> eyre::Result { + let (_, schema) = deref_definition(spec, schema)?; + let is_str = match schema._type { + Some(SchemaType::One(Primitive::String)) => true, + _ => false, + }; + Ok(is_str) +} + +fn param_is_string(spec: &OpenApiV2, param: &Parameter) -> eyre::Result { + match param._in { + ParameterIn::Body => { + let schema_ref = param + .schema + .as_ref() + .ok_or_else(|| eyre::eyre!("body param did not have schema"))?; + schema_is_string(spec, schema_ref) + } + _ => { + let is_str = match param._type { + Some(ParameterType::String) => true, + _ => false, + }; + Ok(is_str) + } + } +} + +fn create_get_method(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Result { + let doc = method_docs(op)?; + let sig = fn_signature_from_op(spec, op)?; + let body = create_method_body(spec, "get", path, op)?; + Ok(format!("{doc}{sig} {{\n {body}\n}}\n\n")) +} + +fn create_put_method(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Result { + let doc = method_docs(op)?; + let sig = fn_signature_from_op(spec, op)?; + let body = create_method_body(spec, "put", path, op)?; + Ok(format!("{doc}{sig} {{\n {body}\n}}\n\n")) +} + +fn create_post_method(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Result { + let doc = method_docs(op)?; + let sig = fn_signature_from_op(spec, op)?; + let body = create_method_body(spec, "post", path, op)?; + Ok(format!("{doc}{sig} {{\n {body}\n}}\n\n")) +} + +fn create_delete_method(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Result { + let doc = method_docs(op)?; + let sig = fn_signature_from_op(spec, op)?; + let body = create_method_body(spec, "delete", path, op)?; + Ok(format!("{doc}{sig} {{\n {body}\n}}\n\n")) +} + +fn create_options_method(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Result { + let doc = method_docs(op)?; + let sig = fn_signature_from_op(spec, op)?; + let body = create_method_body(spec, "options", path, op)?; + Ok(format!("{doc}{sig} {{\n {body}\n}}\n\n")) +} + +fn create_head_method(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Result { + let doc = method_docs(op)?; + let sig = fn_signature_from_op(spec, op)?; + let body = create_method_body(spec, "head", path, op)?; + Ok(format!("{doc}{sig} {{\n {body}\n}}\n\n")) +} + +fn create_patch_method(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Result { + let doc = method_docs(op)?; + let sig = fn_signature_from_op(spec, op)?; + let body = create_method_body(spec, "patch", path, op)?; + Ok(format!("{doc}{sig} {{\n {body}\n}}\n\n")) +} + +fn sanitize_ident(mut s: String) -> String { + let keywords = [ + "as", "break", "const", "continue", "crate", "else", "enum", "extern", "false", "fn", + "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref", + "return", "self", "Self", "static", "struct", "super", "trait", "true", "type", "unsafe", + "use", "where", "while", + ]; + if keywords.contains(&&*s) { + s.insert_str(0, "r#"); + } + s +} diff --git a/generator/src/openapi.rs b/generator/src/openapi.rs index 843a20d..f86ab88 100644 --- a/generator/src/openapi.rs +++ b/generator/src/openapi.rs @@ -185,7 +185,7 @@ pub struct Responses { #[serde(rename_all(deserialize = "camelCase"))] pub struct Response { pub description: String, - pub schema: Option, + pub schema: Option>, pub headers: Option>, pub examples: Option>, } @@ -248,6 +248,8 @@ pub struct Schema { pub _enum: Option>, #[serde(rename = "type")] pub _type: Option, + pub properties: Option>>, + pub items: Option>>, pub discriminator: Option, pub read_only: Option, From 3d12246cb8757693ab3e75549fe5571552a17441 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 12:24:43 -0500 Subject: [PATCH 06/86] import `ForgejoError` in generated file --- generator/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/generator/src/main.rs b/generator/src/main.rs index 79fd479..d9e26b8 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -13,6 +13,7 @@ use std::fmt::Write; fn main() -> eyre::Result<()> { let spec = get_spec()?; let mut s = String::new(); + s.push_str("use crate::ForgejoError;\n"); s.push_str("impl Forgejo {\n"); for (path, item) in &spec.paths { s.push_str(&create_methods_for_path(&spec, path, item).wrap_err_with(|| path.clone())?); From 20a58df856d79ba0b5ee153aa5018e1e68d3f37d Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 12:51:30 -0500 Subject: [PATCH 07/86] methods should be `pub` and `async` --- generator/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index d9e26b8..9a8acd7 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -77,7 +77,7 @@ fn fn_signature_from_op(spec: &OpenApiV2, op: &Operation) -> eyre::Result Result<{ty}, ForgejoError>")) + Ok(format!("pub async fn {name}({args}) -> Result<{ty}, ForgejoError>")) } fn fn_args_from_op(spec: &OpenApiV2, op: &Operation) -> eyre::Result { From 12f2800b2630d354fa834be3accecef13833ebfa Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 13:07:28 -0500 Subject: [PATCH 08/86] convert path args to camel case in format string --- generator/src/main.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 9a8acd7..23a8bd0 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -392,7 +392,7 @@ fn create_method_request( } } } - let mut fmt_str = path.to_string(); + let mut fmt_str = sanitize_path_arg(path)?; let mut fmt_args = String::new(); if has_query { fmt_str.push_str("?{}"); @@ -408,6 +408,32 @@ fn create_method_request( Ok(out) } +fn sanitize_path_arg(mut path: &str) -> eyre::Result { + let mut out = String::new(); + loop { + let (head, tail) = match path.split_once("{") { + Some(i) => i, + None => { + out.push_str(path); + break; + } + }; + path = tail; + out.push_str(head); + out.push('{'); + let (head, tail) = match path.split_once("}") { + Some(i) => i, + None => { + eyre::bail!("unmatched bracket"); + } + }; + path = tail; + out.push_str(&head.to_snake_case()); + out.push('}'); + } + Ok(out) +} + fn create_method_response( spec: &OpenApiV2, method: &str, From f30b4eba308bf782eba96aae48adb63c8fd8fbca Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 14:01:37 -0500 Subject: [PATCH 09/86] autogenerate structs --- generator/src/main.rs | 60 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 23a8bd0..04a3ede 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -18,7 +18,14 @@ fn main() -> eyre::Result<()> { for (path, item) in &spec.paths { s.push_str(&create_methods_for_path(&spec, path, item).wrap_err_with(|| path.clone())?); } - s.push('}'); + s.push_str("}\n"); + + if let Some(definitions) = &spec.definitions { + for (name, schema) in definitions { + let strukt = create_struct_for_definition(&spec, name, schema)?; + s.push_str(&strukt); + } + } save_generated(&mut s)?; Ok(()) } @@ -575,10 +582,59 @@ fn sanitize_ident(mut s: String) -> String { "as", "break", "const", "continue", "crate", "else", "enum", "extern", "false", "fn", "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref", "return", "self", "Self", "static", "struct", "super", "trait", "true", "type", "unsafe", - "use", "where", "while", + "use", "where", "while", "abstract", "become", "box", "do", "final", "macro", "override", + "priv", "typeof", "unsized", "virtual", "yield", "async", "await", "dyn", "try", + "macro_rules", "union" ]; + if s == "self" { + s = "this".into(); + } if keywords.contains(&&*s) { s.insert_str(0, "r#"); } s } + +fn create_struct_for_definition(spec: &OpenApiV2, name: &str, schema: &Schema) -> eyre::Result { + if matches!(schema._type, Some(SchemaType::One(Primitive::Array))) { + return Ok(String::new()); + } + + let docs = create_struct_docs(schema)?; + let mut fields = String::new(); + let required = schema.required.as_deref().unwrap_or_default(); + if let Some(properties) = &schema.properties { + for (prop_name, prop_schema) in properties { + let prop_ty = schema_ref_type_name(spec, prop_schema)?; + let field_name = sanitize_ident(prop_name.to_snake_case()); + let field_ty = if required.contains(prop_name) { + prop_ty + } else { + format!("Option<{prop_ty}>") + }; + fields.push_str(&field_name); + fields.push_str(": "); + fields.push_str(&field_ty); + fields.push_str(",\n"); + } + } + + let out = format!("{docs}pub struct {name} {{\n{fields}}}\n\n"); + Ok(out) +} + +fn create_struct_docs(schema: &Schema) -> eyre::Result { + let doc = match &schema.description { + Some(desc) => { + let mut out = String::new(); + for line in desc.lines() { + out.push_str("/// "); + out.push_str(line); + out.push_str("\n/// \n"); + } + out + }, + None => String::new(), + }; + Ok(doc) +} From c17c1f8638ec920d185e905f7e60e56784319229 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 17:23:02 -0500 Subject: [PATCH 10/86] generate query structs --- generator/src/main.rs | 339 +++++++++++++++++++++++++++++++++++---- generator/src/openapi.rs | 2 +- 2 files changed, 313 insertions(+), 28 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 04a3ede..26e56e7 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -5,8 +5,8 @@ mod openapi; use eyre::Context; use heck::{ToPascalCase, ToSnakeCase}; use openapi::{ - MaybeRef, OpenApiV2, Operation, Parameter, ParameterIn, ParameterType, Primitive, Response, - Schema, SchemaType, + CollectionFormat, Items, MaybeRef, OpenApiV2, Operation, Parameter, ParameterIn, ParameterType, + Primitive, Response, Schema, SchemaType, }; use std::fmt::Write; @@ -26,6 +26,10 @@ fn main() -> eyre::Result<()> { s.push_str(&strukt); } } + for (path, item) in &spec.paths { + let strukt = create_query_structs_for_path(&spec, path, item)?; + s.push_str(&strukt); + } save_generated(&mut s)?; Ok(()) } @@ -84,7 +88,9 @@ fn fn_signature_from_op(spec: &OpenApiV2, op: &Operation) -> eyre::Result Result<{ty}, ForgejoError>")) + Ok(format!( + "pub async fn {name}({args}) -> Result<{ty}, ForgejoError>" + )) } fn fn_args_from_op(spec: &OpenApiV2, op: &Operation) -> eyre::Result { @@ -100,11 +106,11 @@ fn fn_args_from_op(spec: &OpenApiV2, op: &Operation) -> eyre::Result { }; match param._in { ParameterIn::Path => { - let type_name = path_param_type(¶m)?; + let type_name = param_type(¶m, false)?; args.push_str(", "); args.push_str(&sanitize_ident(param.name.to_snake_case())); args.push_str(": "); - args.push_str(type_name); + args.push_str(&type_name); } ParameterIn::Query => has_query = true, ParameterIn::Header => has_headers = true, @@ -249,32 +255,71 @@ fn schema_type_name( } } -fn path_param_type(param: &Parameter) -> eyre::Result<&'static str> { +fn param_type(param: &Parameter, owned: bool) -> eyre::Result { let _type = param ._type .as_ref() .ok_or_else(|| eyre::eyre!("no type provided for path param"))?; - let type_name = match _type { - ParameterType::String => match param.format.as_deref() { + param_type_inner(_type, param.format.as_deref(), param.items.as_ref(), owned) +} + +fn param_type_inner( + ty: &ParameterType, + format: Option<&str>, + items: Option<&Items>, + owned: bool, +) -> eyre::Result { + let ty_name = match ty { + ParameterType::String => match format.as_deref() { Some("date") => "time::Date", Some("date-time") => "time::OffsetDateTime", - _ => "&str", - }, - ParameterType::Number => match param.format.as_deref() { + _ => { + if owned { + "String" + } else { + "&str" + } + } + } + .into(), + ParameterType::Number => match format.as_deref() { Some("float") => "f32", Some("double") => "f64", _ => "f64", - }, - ParameterType::Integer => match param.format.as_deref() { + } + .into(), + ParameterType::Integer => match format.as_deref() { Some("int32") => "u32", Some("int64") => "u64", _ => "u32", - }, - ParameterType::Boolean => "bool", - ParameterType::Array => eyre::bail!("todo: support returning arrays"), - ParameterType::File => "Vec", + } + .into(), + ParameterType::Boolean => "bool".into(), + ParameterType::Array => { + let item = items + .as_ref() + .ok_or_else(|| eyre::eyre!("array must have item type defined"))?; + let item_ty_name = param_type_inner( + &item._type, + item.format.as_deref(), + item.items.as_deref(), + owned, + )?; + if owned { + format!("Vec<{item_ty_name}>") + } else { + format!("&[{item_ty_name}]") + } + } + ParameterType::File => { + if owned { + format!("Vec") + } else { + format!("&[u8]") + } + } }; - Ok(type_name) + Ok(ty_name) } fn method_docs(op: &Operation) -> eyre::Result { @@ -403,7 +448,7 @@ fn create_method_request( let mut fmt_args = String::new(); if has_query { fmt_str.push_str("?{}"); - fmt_args.push_str(", query"); + fmt_args.push_str(", query.to_string()"); } let path_arg = if fmt_str.contains("{") { format!("&format!(\"{fmt_str}\"{fmt_args})") @@ -579,12 +624,59 @@ fn create_patch_method(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re fn sanitize_ident(mut s: String) -> String { let keywords = [ - "as", "break", "const", "continue", "crate", "else", "enum", "extern", "false", "fn", - "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref", - "return", "self", "Self", "static", "struct", "super", "trait", "true", "type", "unsafe", - "use", "where", "while", "abstract", "become", "box", "do", "final", "macro", "override", - "priv", "typeof", "unsized", "virtual", "yield", "async", "await", "dyn", "try", - "macro_rules", "union" + "as", + "break", + "const", + "continue", + "crate", + "else", + "enum", + "extern", + "false", + "fn", + "for", + "if", + "impl", + "in", + "let", + "loop", + "match", + "mod", + "move", + "mut", + "pub", + "ref", + "return", + "self", + "Self", + "static", + "struct", + "super", + "trait", + "true", + "type", + "unsafe", + "use", + "where", + "while", + "abstract", + "become", + "box", + "do", + "final", + "macro", + "override", + "priv", + "typeof", + "unsized", + "virtual", + "yield", + "async", + "await", + "dyn", + "try", + "macro_rules", + "union", ]; if s == "self" { s = "this".into(); @@ -595,7 +687,11 @@ fn sanitize_ident(mut s: String) -> String { s } -fn create_struct_for_definition(spec: &OpenApiV2, name: &str, schema: &Schema) -> eyre::Result { +fn create_struct_for_definition( + spec: &OpenApiV2, + name: &str, + schema: &Schema, +) -> eyre::Result { if matches!(schema._type, Some(SchemaType::One(Primitive::Array))) { return Ok(String::new()); } @@ -633,8 +729,197 @@ fn create_struct_docs(schema: &Schema) -> eyre::Result { out.push_str("\n/// \n"); } out - }, + } None => String::new(), }; Ok(doc) } + +fn create_query_structs_for_path( + spec: &OpenApiV2, + path: &str, + item: &openapi::PathItem, +) -> eyre::Result { + let mut s = String::new(); + if let Some(op) = &item.get { + s.push_str(&create_query_struct(spec, path, op).wrap_err("GET")?); + } + if let Some(op) = &item.put { + s.push_str(&create_query_struct(spec, path, op).wrap_err("PUT")?); + } + if let Some(op) = &item.post { + s.push_str(&create_query_struct(spec, path, op).wrap_err("POST")?); + } + if let Some(op) = &item.delete { + s.push_str(&create_query_struct(spec, path, op).wrap_err("DELETE")?); + } + if let Some(op) = &item.options { + s.push_str(&create_query_struct(spec, path, op).wrap_err("OPTIONS")?); + } + if let Some(op) = &item.head { + s.push_str(&create_query_struct(spec, path, op).wrap_err("HEAD")?); + } + if let Some(op) = &item.patch { + s.push_str(&create_query_struct(spec, path, op).wrap_err("PATCH")?); + } + Ok(s) +} + +fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Result { + let params = match &op.parameters { + Some(params) => params, + None => return Ok(String::new()), + }; + + let mut fields = String::new(); + let mut imp = String::new(); + imp.push_str("let mut s = String::new();\n"); + for param in params { + let param = match ¶m { + MaybeRef::Value { value } => value, + MaybeRef::Ref { _ref } => eyre::bail!("todo: add deref parameters"), + }; + if param._in == ParameterIn::Query { + let ty = param_type(param, true)?; + let field_name = sanitize_ident(param.name.to_snake_case()); + let required = param.required.unwrap_or_default(); + fields.push_str(&field_name); + fields.push_str(": "); + if required { + fields.push_str(&ty); + } else { + fields.push_str("Option<"); + fields.push_str(&ty); + fields.push_str(">"); + } + fields.push_str(",\n"); + + let mut handler = String::new(); + let ty = param + ._type + .as_ref() + .ok_or_else(|| eyre::eyre!("no type provided for query field"))?; + if required { + writeln!(&mut handler, "let {field_name} = self.{field_name};")?; + } else { + writeln!( + &mut handler, + "if let Some({field_name}) = self.{field_name} {{" + )?; + } + match ty { + ParameterType::String => match param.format.as_deref() { + Some("date-time" | "date") => { + writeln!(&mut handler, "s.push_str(\"{}=\");", param.name)?; + writeln!(&mut handler, "{field_name}.format_into(&mut s, &time::format_description::well_known::Rfc3339).unwrap();")?; + writeln!(&mut handler, "s.push('&');")?; + } + _ => { + writeln!(&mut handler, "s.push_str(\"{}=\");", param.name)?; + writeln!(&mut handler, "s.push_str(&{field_name});")?; + writeln!(&mut handler, "s.push('&');")?; + } + }, + ParameterType::Number | ParameterType::Integer | ParameterType::Boolean => { + writeln!( + &mut handler, + "s.write_fmt(format_args!(\"{}={{}}&\", {field_name})).unwrap();", + param.name + )?; + } + ParameterType::Array => { + let format = param.collection_format.unwrap_or(CollectionFormat::Csv); + let item = param + .items + .as_ref() + .ok_or_else(|| eyre::eyre!("array must have item type defined"))?; + let item_pusher = match item._type { + ParameterType::String => { + match param.format.as_deref() { + Some("date-time" | "date") => { + "item.format_into(&mut s, &time::format_description::well_known::Rfc3339).unwrap();" + }, + _ => { + "s.push_str(&item);" + } + } + }, + ParameterType::Number | + ParameterType::Integer | + ParameterType::Boolean => { + "s.write_fmt(format_args!(\"{{item}}\")).unwrap();" + }, + ParameterType::Array => { + eyre::bail!("nested arrays not supported in query"); + }, + ParameterType::File => eyre::bail!("cannot send file in query"), + }; + match format { + CollectionFormat::Csv => { + handler.push_str(&simple_query_array(param, item_pusher, &field_name, ",")?); + } + CollectionFormat::Ssv => { + handler.push_str(&simple_query_array(param, item_pusher, &field_name, " ")?); + } + CollectionFormat::Tsv => { + handler.push_str(&simple_query_array(param, item_pusher, &field_name, "\\t")?); + } + CollectionFormat::Pipes => { + handler.push_str(&simple_query_array(param, item_pusher, &field_name, "|")?); + } + CollectionFormat::Multi => { + writeln!(&mut handler, "")?; + writeln!(&mut handler, "if !{field_name}.is_empty() {{")?; + writeln!( + &mut handler, + "for (i, item) in {field_name}.iter().enumerate() {{" + )?; + writeln!(&mut handler, "s.push_str(\"{}=\");", param.name)?; + handler.push_str(item_pusher); + handler.push('\n'); + writeln!(&mut handler, "s.push('&')")?; + writeln!(&mut handler, "}}")?; + writeln!(&mut handler, "}}")?; + } + } + } + ParameterType::File => eyre::bail!("cannot send file in query"), + } + if !required { + writeln!(&mut handler, "}}")?; + } + imp.push_str(&handler); + } + } + imp.push_str("s\n"); + if fields.is_empty() { + return Ok(String::new()); + } else { + let op_name = op + .operation_id + .as_ref() + .ok_or_else(|| eyre::eyre!("no op id found"))? + .to_pascal_case(); + return Ok(format!("pub struct {op_name}Query {{\n{fields}\n}}\n\nimpl {op_name}Query {{\nfn to_string(&self) -> String {{\n{imp}\n}}\n}}")); + } +} + +fn simple_query_array(param: &Parameter, item_pusher: &str, name: &str, sep: &str) -> eyre::Result { + let mut out = String::new(); + writeln!(&mut out, "s.push_str(\"{}=\");", param.name)?; + writeln!(&mut out, "")?; + writeln!(&mut out, "if !{name}.is_empty() {{")?; + writeln!( + &mut out, + "for (i, item) in {name}.iter().enumerate() {{" + )?; + out.push_str(item_pusher); + out.push('\n'); + writeln!(&mut out, "if i < {name}.len() - 1 {{")?; + writeln!(&mut out, "s.push('{sep}')")?; + writeln!(&mut out, "}}")?; + writeln!(&mut out, "}}")?; + writeln!(&mut out, "s.push('&')")?; + writeln!(&mut out, "}}")?; + Ok(out) +} diff --git a/generator/src/openapi.rs b/generator/src/openapi.rs index f86ab88..79a57d3 100644 --- a/generator/src/openapi.rs +++ b/generator/src/openapi.rs @@ -139,7 +139,7 @@ pub enum ParameterType { File, } -#[derive(serde::Deserialize, Debug, PartialEq)] +#[derive(serde::Deserialize, Debug, PartialEq, Clone, Copy)] #[serde(rename_all(deserialize = "camelCase"))] pub enum CollectionFormat { Csv, From 4c7ec23ab72087f7f150ca578cca8c615c603d7f Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 17:23:51 -0500 Subject: [PATCH 11/86] impl on `crate::Forgejo` instead of `Forgejo` --- generator/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 26e56e7..e735d7b 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> { let spec = get_spec()?; let mut s = String::new(); s.push_str("use crate::ForgejoError;\n"); - s.push_str("impl Forgejo {\n"); + s.push_str("impl crate::Forgejo {\n"); for (path, item) in &spec.paths { s.push_str(&create_methods_for_path(&spec, path, item).wrap_err_with(|| path.clone())?); } From 41c710281dd61ddacac759077de77ab826be1727 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 17:27:03 -0500 Subject: [PATCH 12/86] sanitize body arg --- generator/src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index e735d7b..184e65d 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -421,6 +421,7 @@ fn create_method_request( MaybeRef::Value { value } => value, MaybeRef::Ref { _ref } => eyre::bail!("todo: add deref parameters"), }; + let name = sanitize_ident(param.name.to_snake_case()); match param._in { ParameterIn::Path => (/* do nothing */), ParameterIn::Query => has_query = true, @@ -430,16 +431,16 @@ fn create_method_request( eyre::bail!("cannot have more than one body parameter"); } if param_is_string(spec, param)? { - body_method = format!(".body({})", param.name); + body_method = format!(".body({name})"); } else { - body_method = format!(".json({})?", param.name); + body_method = format!(".json({name})?"); } } ParameterIn::FormData => { if !body_method.is_empty() { eyre::bail!("cannot have more than one body parameter"); } - body_method = format!(".multipart(reqwest::multipart::Form::new().part(\"attachment\", reqwest::multipart::Part::bytes({}).file_name(\"file\").mime_str(\"*/*\").unwrap()))", param.name); + body_method = format!(".multipart(reqwest::multipart::Form::new().part(\"attachment\", reqwest::multipart::Part::bytes({name}).file_name(\"file\").mime_str(\"*/*\").unwrap()))"); } } } From b111e3352d9196300add000d52ff3829b6a9c470 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 17:29:32 -0500 Subject: [PATCH 13/86] convert to snake case inside of `sanitize_ident` --- generator/src/main.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 184e65d..032742c 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -108,7 +108,7 @@ fn fn_args_from_op(spec: &OpenApiV2, op: &Operation) -> eyre::Result { ParameterIn::Path => { let type_name = param_type(¶m, false)?; args.push_str(", "); - args.push_str(&sanitize_ident(param.name.to_snake_case())); + args.push_str(&sanitize_ident(¶m.name)); args.push_str(": "); args.push_str(&type_name); } @@ -118,13 +118,13 @@ fn fn_args_from_op(spec: &OpenApiV2, op: &Operation) -> eyre::Result { let schema_ref = param.schema.as_ref().unwrap(); let ty = schema_ref_type_name(spec, &schema_ref)?; args.push_str(", "); - args.push_str(&sanitize_ident(param.name.to_snake_case())); + args.push_str(&sanitize_ident(¶m.name)); args.push_str(": "); args.push_str(&ty); } ParameterIn::FormData => { args.push_str(", "); - args.push_str(&sanitize_ident(param.name.to_snake_case())); + args.push_str(&sanitize_ident(¶m.name)); args.push_str(": Vec"); } } @@ -421,7 +421,7 @@ fn create_method_request( MaybeRef::Value { value } => value, MaybeRef::Ref { _ref } => eyre::bail!("todo: add deref parameters"), }; - let name = sanitize_ident(param.name.to_snake_case()); + let name = sanitize_ident(¶m.name); match param._in { ParameterIn::Path => (/* do nothing */), ParameterIn::Query => has_query = true, @@ -623,7 +623,8 @@ fn create_patch_method(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re Ok(format!("{doc}{sig} {{\n {body}\n}}\n\n")) } -fn sanitize_ident(mut s: String) -> String { +fn sanitize_ident(s: &str) -> String { + let mut s = s.to_snake_case(); let keywords = [ "as", "break", @@ -703,7 +704,7 @@ fn create_struct_for_definition( if let Some(properties) = &schema.properties { for (prop_name, prop_schema) in properties { let prop_ty = schema_ref_type_name(spec, prop_schema)?; - let field_name = sanitize_ident(prop_name.to_snake_case()); + let field_name = sanitize_ident(prop_name); let field_ty = if required.contains(prop_name) { prop_ty } else { @@ -782,7 +783,7 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re }; if param._in == ParameterIn::Query { let ty = param_type(param, true)?; - let field_name = sanitize_ident(param.name.to_snake_case()); + let field_name = sanitize_ident(¶m.name); let required = param.required.unwrap_or_default(); fields.push_str(&field_name); fields.push_str(": "); From 2f60a9293340265a4c9a9c5a783fd9dea0f2e7ce Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 17:49:00 -0500 Subject: [PATCH 14/86] add type parameters to `serde_json::Map` --- generator/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 032742c..69b1262 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -242,7 +242,7 @@ fn schema_type_name( // Checking for a space filters that out (Some(title), _) if !title.contains(' ') => title.to_string(), (_, Some(definition_name)) => definition_name.to_string(), - (_, None) => "serde_json::Map".to_string(), + (_, None) => "serde_json::Map".to_string(), } } }; From 2859fd132e9e9acc025addb7a9d6c179b22bca35 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:03:44 -0500 Subject: [PATCH 15/86] add missing arg to `UnexpectedStatusCode` --- generator/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 69b1262..44911b9 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -540,7 +540,7 @@ fn create_method_response( out.push_str(handler); out.push_str(",\n"); } - out.push_str("_ => Err(ForgejoError::UnexpectedStatusCode)\n"); + out.push_str("_ => Err(ForgejoError::UnexpectedStatusCode(response.status()))\n"); out.push_str("}\n"); Ok(out) From 70b4081cde6504d1c1cdb05b9f3d34c841ece2f5 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:09:13 -0500 Subject: [PATCH 16/86] simple recursion prevention --- generator/src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 44911b9..cb34843 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -705,10 +705,11 @@ fn create_struct_for_definition( for (prop_name, prop_schema) in properties { let prop_ty = schema_ref_type_name(spec, prop_schema)?; let field_name = sanitize_ident(prop_name); - let field_ty = if required.contains(prop_name) { - prop_ty - } else { - format!("Option<{prop_ty}>") + let field_ty = match (!required.contains(prop_name), prop_ty == name) { + (false, false) => prop_ty, + (false, true) => format!("Box<{prop_ty}>"), + (true, false) => format!("Option<{prop_ty}>"), + (true, true) => format!("Option>"), }; fields.push_str(&field_name); fields.push_str(": "); From edf4646953ed46add123c71f1d31f002f2609dab Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:12:56 -0500 Subject: [PATCH 17/86] add derives to generated structs --- generator/src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index cb34843..94c1c87 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -711,6 +711,11 @@ fn create_struct_for_definition( (true, false) => format!("Option<{prop_ty}>"), (true, true) => format!("Option>"), }; + if &field_name != prop_name { + fields.push_str("#[serde(rename = \""); + fields.push_str(prop_name); + fields.push_str("\")]\n"); + } fields.push_str(&field_name); fields.push_str(": "); fields.push_str(&field_ty); @@ -718,7 +723,7 @@ fn create_struct_for_definition( } } - let out = format!("{docs}pub struct {name} {{\n{fields}}}\n\n"); + let out = format!("{docs}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]\npub struct {name} {{\n{fields}}}\n\n"); Ok(out) } From fed24b52ec70e33decf063f9866e6c9d9fc7243b Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:18:38 -0500 Subject: [PATCH 18/86] only check 200 responses for if optional --- generator/src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 94c1c87..49e540f 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -495,8 +495,11 @@ fn create_method_response( ) -> eyre::Result { let mut has_empty = false; let mut only_empty = true; - for (_, res) in &op.responses.http_codes { + for (code, res) in &op.responses.http_codes { let name = response_ref_type_name(spec, res)?; + if !code.starts_with("2") { + continue; + } if name == "()" || name == "empty" { has_empty = true; } else { @@ -509,7 +512,7 @@ fn create_method_response( out.push_str("match response.status().as_u16() {\n"); for (code, res) in &op.responses.http_codes { let (_, res) = deref_response(spec, res)?; - if code.starts_with("4") { + if !code.starts_with("2") { continue; } out.push_str(code); From f8bbf570e178f67b5e206e9f7720a1f8c8787006 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:20:17 -0500 Subject: [PATCH 19/86] `RequestBuilder::json` takes reference, doesn't return result --- generator/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 49e540f..67e44aa 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -433,7 +433,7 @@ fn create_method_request( if param_is_string(spec, param)? { body_method = format!(".body({name})"); } else { - body_method = format!(".json({name})?"); + body_method = format!(".json(&{name})"); } } ParameterIn::FormData => { From 9bd1a137b8dbb9f8d58f752cd948c4cfe419847b Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:36:50 -0500 Subject: [PATCH 20/86] use `write!` instead of `.write_fmt` --- generator/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 67e44aa..5fb8e9d 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -14,6 +14,7 @@ fn main() -> eyre::Result<()> { let spec = get_spec()?; let mut s = String::new(); s.push_str("use crate::ForgejoError;\n"); + s.push_str("use std::fmt::Write;\n"); s.push_str("impl crate::Forgejo {\n"); for (path, item) in &spec.paths { s.push_str(&create_methods_for_path(&spec, path, item).wrap_err_with(|| path.clone())?); @@ -834,7 +835,7 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re ParameterType::Number | ParameterType::Integer | ParameterType::Boolean => { writeln!( &mut handler, - "s.write_fmt(format_args!(\"{}={{}}&\", {field_name})).unwrap();", + "write!(&mut s, \"{}={{}}&\", {field_name}).unwrap();", param.name )?; } @@ -858,7 +859,7 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re ParameterType::Number | ParameterType::Integer | ParameterType::Boolean => { - "s.write_fmt(format_args!(\"{{item}}\")).unwrap();" + "write!(&mut s, \"{item}\").unwrap();" }, ParameterType::Array => { eyre::bail!("nested arrays not supported in query"); From ed1092bc9e9309bcb902253e294c1e03cba0b9c5 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:37:31 -0500 Subject: [PATCH 21/86] use `OffsetDateTime::format` instead of `format_into` --- generator/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 5fb8e9d..be20c25 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -823,7 +823,7 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re ParameterType::String => match param.format.as_deref() { Some("date-time" | "date") => { writeln!(&mut handler, "s.push_str(\"{}=\");", param.name)?; - writeln!(&mut handler, "{field_name}.format_into(&mut s, &time::format_description::well_known::Rfc3339).unwrap();")?; + writeln!(&mut handler, "s.push_str(&{field_name}.format(&time::format_description::well_known::Rfc3339).unwrap());")?; writeln!(&mut handler, "s.push('&');")?; } _ => { @@ -849,7 +849,7 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re ParameterType::String => { match param.format.as_deref() { Some("date-time" | "date") => { - "item.format_into(&mut s, &time::format_description::well_known::Rfc3339).unwrap();" + "s.push_str(&item.format(&time::format_description::well_known::Rfc3339).unwrap());" }, _ => { "s.push_str(&item);" From 0565c3f1c607c9bb98b056732e71d6cb0c0fbf8f Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:38:02 -0500 Subject: [PATCH 22/86] remove unnecessary enumeration --- generator/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index be20c25..46b9984 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -884,7 +884,7 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re writeln!(&mut handler, "if !{field_name}.is_empty() {{")?; writeln!( &mut handler, - "for (i, item) in {field_name}.iter().enumerate() {{" + "for item in {field_name} {{" )?; writeln!(&mut handler, "s.push_str(\"{}=\");", param.name)?; handler.push_str(item_pusher); From 53922bc4657e4e7fad8d6abc5ec14963835db6f3 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:38:24 -0500 Subject: [PATCH 23/86] make `*Query::to_string` take `self` --- generator/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 46b9984..1b17240 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -912,7 +912,7 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re .as_ref() .ok_or_else(|| eyre::eyre!("no op id found"))? .to_pascal_case(); - return Ok(format!("pub struct {op_name}Query {{\n{fields}\n}}\n\nimpl {op_name}Query {{\nfn to_string(&self) -> String {{\n{imp}\n}}\n}}")); + return Ok(format!("pub struct {op_name}Query {{\n{fields}\n}}\n\nimpl {op_name}Query {{\nfn to_string(self) -> String {{\n{imp}\n}}\n}}")); } } From 61e24b800d4107bf8ec4fb3053620a1a64652013 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:55:19 -0500 Subject: [PATCH 24/86] guess which types are url by field name --- generator/src/main.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 1b17240..b0da534 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -709,12 +709,19 @@ fn create_struct_for_definition( for (prop_name, prop_schema) in properties { let prop_ty = schema_ref_type_name(spec, prop_schema)?; let field_name = sanitize_ident(prop_name); - let field_ty = match (!required.contains(prop_name), prop_ty == name) { - (false, false) => prop_ty, - (false, true) => format!("Box<{prop_ty}>"), - (true, false) => format!("Option<{prop_ty}>"), - (true, true) => format!("Option>"), - }; + let mut field_ty = prop_ty.clone(); + if field_name.ends_with("url") && field_ty == "String" { + field_ty = "url::Url".into() + } + if field_ty == name { + field_ty = format!("Box<{field_ty}>") + } + if !required.contains(prop_name) { + field_ty = format!("Option<{field_ty}>") + } + if field_ty == "Option" { + fields.push_str("#[serde(deserialize_with = \"crate::none_if_blank_url\")]\n"); + } if &field_name != prop_name { fields.push_str("#[serde(rename = \""); fields.push_str(prop_name); From c83eecc7ff90fa03e843b751e2c64c9639d065fc Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 18:59:46 -0500 Subject: [PATCH 25/86] praise rustfmt --- generator/src/main.rs | 45 ++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index b0da534..24ff7e2 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -875,24 +875,41 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re }; match format { CollectionFormat::Csv => { - handler.push_str(&simple_query_array(param, item_pusher, &field_name, ",")?); + handler.push_str(&simple_query_array( + param, + item_pusher, + &field_name, + ",", + )?); } CollectionFormat::Ssv => { - handler.push_str(&simple_query_array(param, item_pusher, &field_name, " ")?); + handler.push_str(&simple_query_array( + param, + item_pusher, + &field_name, + " ", + )?); } CollectionFormat::Tsv => { - handler.push_str(&simple_query_array(param, item_pusher, &field_name, "\\t")?); + handler.push_str(&simple_query_array( + param, + item_pusher, + &field_name, + "\\t", + )?); } CollectionFormat::Pipes => { - handler.push_str(&simple_query_array(param, item_pusher, &field_name, "|")?); + handler.push_str(&simple_query_array( + param, + item_pusher, + &field_name, + "|", + )?); } CollectionFormat::Multi => { writeln!(&mut handler, "")?; writeln!(&mut handler, "if !{field_name}.is_empty() {{")?; - writeln!( - &mut handler, - "for item in {field_name} {{" - )?; + writeln!(&mut handler, "for item in {field_name} {{")?; writeln!(&mut handler, "s.push_str(\"{}=\");", param.name)?; handler.push_str(item_pusher); handler.push('\n'); @@ -923,15 +940,17 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re } } -fn simple_query_array(param: &Parameter, item_pusher: &str, name: &str, sep: &str) -> eyre::Result { +fn simple_query_array( + param: &Parameter, + item_pusher: &str, + name: &str, + sep: &str, +) -> eyre::Result { let mut out = String::new(); writeln!(&mut out, "s.push_str(\"{}=\");", param.name)?; writeln!(&mut out, "")?; writeln!(&mut out, "if !{name}.is_empty() {{")?; - writeln!( - &mut out, - "for (i, item) in {name}.iter().enumerate() {{" - )?; + writeln!(&mut out, "for (i, item) in {name}.iter().enumerate() {{")?; out.push_str(item_pusher); out.push('\n'); writeln!(&mut out, "if i < {name}.len() - 1 {{")?; From a0fbf64fcecda60e9306c079bdde069857e17ca7 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 19:05:39 -0500 Subject: [PATCH 26/86] put structs in a module --- generator/src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generator/src/main.rs b/generator/src/main.rs index 24ff7e2..6ca30d0 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -14,13 +14,15 @@ fn main() -> eyre::Result<()> { let spec = get_spec()?; let mut s = String::new(); s.push_str("use crate::ForgejoError;\n"); - s.push_str("use std::fmt::Write;\n"); s.push_str("impl crate::Forgejo {\n"); for (path, item) in &spec.paths { s.push_str(&create_methods_for_path(&spec, path, item).wrap_err_with(|| path.clone())?); } s.push_str("}\n"); + s.push_str("use structs::*;\n"); + s.push_str("pub mod structs {\n"); + s.push_str("use std::fmt::Write;\n"); if let Some(definitions) = &spec.definitions { for (name, schema) in definitions { let strukt = create_struct_for_definition(&spec, name, schema)?; @@ -31,6 +33,7 @@ fn main() -> eyre::Result<()> { let strukt = create_query_structs_for_path(&spec, path, item)?; s.push_str(&strukt); } + s.push_str("\n}"); save_generated(&mut s)?; Ok(()) } @@ -936,7 +939,7 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re .as_ref() .ok_or_else(|| eyre::eyre!("no op id found"))? .to_pascal_case(); - return Ok(format!("pub struct {op_name}Query {{\n{fields}\n}}\n\nimpl {op_name}Query {{\nfn to_string(self) -> String {{\n{imp}\n}}\n}}")); + return Ok(format!("pub struct {op_name}Query {{\n{fields}\n}}\n\nimpl {op_name}Query {{\npub(crate) fn to_string(self) -> String {{\n{imp}\n}}\n}}")); } } From 92c913c457d41b4246e1d382b28fcc24510f0034 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 16 Jan 2024 19:13:45 -0500 Subject: [PATCH 27/86] make generated fields public --- generator/src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generator/src/main.rs b/generator/src/main.rs index 6ca30d0..193d437 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -730,6 +730,7 @@ fn create_struct_for_definition( fields.push_str(prop_name); fields.push_str("\")]\n"); } + fields.push_str("pub "); fields.push_str(&field_name); fields.push_str(": "); fields.push_str(&field_ty); @@ -805,6 +806,7 @@ fn create_query_struct(spec: &OpenApiV2, path: &str, op: &Operation) -> eyre::Re let ty = param_type(param, true)?; let field_name = sanitize_ident(¶m.name); let required = param.required.unwrap_or_default(); + fields.push_str("pub "); fields.push_str(&field_name); fields.push_str(": "); if required { From 77b390575a42e7ac8bf6db2c9a4d6ed0c525e8f8 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Thu, 18 Jan 2024 13:41:48 -0500 Subject: [PATCH 28/86] rename `userGetOauth2Application` to `userGetOAuth2Applications` --- swagger.v1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swagger.v1.json b/swagger.v1.json index c3be7d6..fa4880f 100644 --- a/swagger.v1.json +++ b/swagger.v1.json @@ -14673,7 +14673,7 @@ "user" ], "summary": "List the authenticated user's oauth2 applications", - "operationId": "userGetOauth2Application", + "operationId": "userGetOAuth2Applications", "parameters": [ { "type": "integer", From 81b17abc8aa286e7cc94b08079832916b5e89d10 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Thu, 18 Jan 2024 13:44:07 -0500 Subject: [PATCH 29/86] replace with generated api --- src/admin.rs | 502 -- src/generated.rs | 12253 ++++++++++++++++++++++++++++++++++++++++++ src/issue.rs | 347 -- src/lib.rs | 220 +- src/misc.rs | 162 - src/notification.rs | 273 - src/organization.rs | 30 - src/package.rs | 174 - src/repository.rs | 743 --- src/user.rs | 59 - 10 files changed, 12272 insertions(+), 2491 deletions(-) delete mode 100644 src/admin.rs create mode 100644 src/generated.rs delete mode 100644 src/issue.rs delete mode 100644 src/misc.rs delete mode 100644 src/notification.rs delete mode 100644 src/organization.rs delete mode 100644 src/package.rs delete mode 100644 src/repository.rs delete mode 100644 src/user.rs diff --git a/src/admin.rs b/src/admin.rs deleted file mode 100644 index 560d6c6..0000000 --- a/src/admin.rs +++ /dev/null @@ -1,502 +0,0 @@ -use super::*; - -use std::collections::BTreeMap; -use std::fmt::Write; - -impl Forgejo { - pub async fn admin_get_crons(&self, query: CronQuery) -> Result, ForgejoError> { - self.get(&query.path()).await - } - - pub async fn admin_run_cron(&self, name: &str) -> Result<(), ForgejoError> { - self.post_unit(&format!("admin/cron/{name}"), &()).await - } - - pub async fn admin_get_emails( - &self, - query: EmailListQuery, - ) -> Result, ForgejoError> { - self.get(&query.path()).await - } - - pub async fn admin_search_emails( - &self, - query: EmailSearchQuery, - ) -> Result, ForgejoError> { - self.get(&query.path()).await - } - - pub async fn admin_get_hooks(&self, query: HookQuery) -> Result, ForgejoError> { - self.get(&query.path()).await - } - - pub async fn admin_create_hook(&self, opt: CreateHookOption) -> Result { - self.post("admin/hooks", &opt).await - } - - pub async fn admin_get_hook(&self, id: u64) -> Result, ForgejoError> { - self.get_opt(&format!("admin/hooks/{id}")).await - } - - pub async fn admin_delete_hook(&self, id: u64) -> Result<(), ForgejoError> { - self.delete(&format!("admin/hooks/{id}")).await - } - - pub async fn admin_edit_hook( - &self, - id: u64, - opt: EditHookOption, - ) -> Result { - self.patch(&format!("admin/hooks/{id}"), &opt).await - } - - pub async fn admin_get_orgs( - &self, - query: AdminOrganizationQuery, - ) -> Result, ForgejoError> { - self.get(&query.path()).await - } - - pub async fn admin_unadopted_repos( - &self, - query: UnadoptedRepoQuery, - ) -> Result, ForgejoError> { - self.get(&query.path()).await - } - - pub async fn admin_adopt(&self, owner: &str, repo: &str) -> Result<(), ForgejoError> { - self.post(&format!("admin/unadopted/{owner}/{repo}"), &()) - .await - } - - pub async fn admin_delete_unadopted( - &self, - owner: &str, - repo: &str, - ) -> Result<(), ForgejoError> { - self.delete(&format!("admin/unadopted/{owner}/{repo}")) - .await - } - - pub async fn admin_users(&self, query: AdminUserQuery) -> Result, ForgejoError> { - self.get(&query.path()).await - } - - pub async fn admin_create_user(&self, opt: CreateUserOption) -> Result { - self.post("admin/users", &opt).await - } - - pub async fn admin_delete_user(&self, user: &str, purge: bool) -> Result<(), ForgejoError> { - self.delete(&format!("admin/users/{user}?purge={purge}")) - .await - } - - pub async fn admin_edit_user( - &self, - user: &str, - opt: CreateUserOption, - ) -> Result { - self.patch(&format!("admin/users/{user}"), &opt).await - } - - pub async fn admin_add_key( - &self, - user: &str, - opt: CreateKeyOption, - ) -> Result { - self.post(&format!("admin/users/{user}/keys"), &opt).await - } - - pub async fn admin_delete_key(&self, user: &str, id: u64) -> Result<(), ForgejoError> { - self.delete(&format!("admin/users/{user}/keys/{id}")).await - } - - pub async fn admin_create_org( - &self, - owner: &str, - opt: CreateOrgOption, - ) -> Result { - self.post(&format!("admin/users/{owner}/orgs"), &opt).await - } - - pub async fn admin_rename_user( - &self, - user: &str, - opt: RenameUserOption, - ) -> Result<(), ForgejoError> { - self.post_unit(&format!("admin/users/{user}/rename"), &opt) - .await - } - - pub async fn admin_create_repo( - &self, - owner: &str, - opt: CreateRepoOption, - ) -> Result { - self.post(&format!("admin/users/{owner}/repos"), &opt).await - } -} - -#[derive(serde::Deserialize, Debug, PartialEq)] -pub struct Cron { - pub exec_times: u64, - pub name: String, - #[serde(with = "time::serde::rfc3339")] - pub next: time::OffsetDateTime, - #[serde(with = "time::serde::rfc3339")] - pub prev: time::OffsetDateTime, - pub schedule: String, -} - -#[derive(Default, Debug)] -pub struct CronQuery { - pub page: Option, - pub limit: Option, -} - -impl CronQuery { - fn path(&self) -> String { - let mut s = String::from("admin/cron?"); - if let Some(page) = self.page { - s.push_str("page="); - s.write_fmt(format_args!("{page}")) - .expect("writing to string can't fail"); - s.push('&'); - } - if let Some(limit) = self.limit { - s.push_str("limit="); - s.write_fmt(format_args!("{limit}")) - .expect("writing to string can't fail"); - s.push('&'); - } - s - } -} - -#[derive(serde::Deserialize, Debug, PartialEq)] -pub struct Email { - pub email: String, - pub primary: bool, - pub user_id: u64, - pub username: String, - pub verified: bool, -} - -#[derive(Default, Debug)] -pub struct EmailListQuery { - pub page: Option, - pub limit: Option, -} - -impl EmailListQuery { - fn path(&self) -> String { - let mut s = String::from("admin/emails?"); - if let Some(page) = self.page { - s.push_str("page="); - s.write_fmt(format_args!("{page}")) - .expect("writing to string can't fail"); - s.push('&'); - } - if let Some(limit) = self.limit { - s.push_str("limit="); - s.write_fmt(format_args!("{limit}")) - .expect("writing to string can't fail"); - s.push('&'); - } - s - } -} - -#[derive(Default, Debug)] -pub struct EmailSearchQuery { - pub query: String, - pub page: Option, - pub limit: Option, -} - -impl EmailSearchQuery { - fn path(&self) -> String { - let mut s = String::from("admin/emails/search?"); - if !self.query.is_empty() { - s.push_str("q="); - s.push_str(&self.query); - s.push('&'); - } - if let Some(page) = self.page { - s.push_str("page="); - s.write_fmt(format_args!("{page}")) - .expect("writing to string can't fail"); - s.push('&'); - } - if let Some(limit) = self.limit { - s.push_str("limit="); - s.write_fmt(format_args!("{limit}")) - .expect("writing to string can't fail"); - s.push('&'); - } - s - } -} - -#[derive(serde::Deserialize, Debug, PartialEq)] -pub struct Hook { - pub active: bool, - pub authorization_header: String, - pub branch_filter: String, - pub config: std::collections::BTreeMap, - #[serde(with = "time::serde::rfc3339")] - pub created_at: time::OffsetDateTime, - pub events: Vec, - pub id: u64, - #[serde(rename = "type")] - pub _type: HookType, - #[serde(with = "time::serde::rfc3339")] - pub updated_at: time::OffsetDateTime, -} - -#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq)] -#[non_exhaustive] -#[serde(rename_all = "lowercase")] -pub enum HookType { - Forgejo, - Dingtalk, - Discord, - Gitea, - Gogs, - Msteams, - Slack, - Telegram, - Feishu, - Wechatwork, - Packagist, -} - -#[derive(Default, Debug)] -pub struct HookQuery { - pub page: Option, - pub limit: Option, -} - -impl HookQuery { - fn path(&self) -> String { - let mut s = String::from("admin/hooks?"); - if let Some(page) = self.page { - s.push_str("page="); - s.write_fmt(format_args!("{page}")) - .expect("writing to string can't fail"); - s.push('&'); - } - if let Some(limit) = self.limit { - s.push_str("limit="); - s.write_fmt(format_args!("{limit}")) - .expect("writing to string can't fail"); - s.push('&'); - } - s - } -} - -#[derive(serde::Serialize, Debug, PartialEq)] -pub struct CreateHookOption { - pub active: Option, - pub authorization_header: Option, - pub branch_filter: Option, - pub config: CreateHookOptionConfig, - pub events: Vec, - #[serde(rename = "type")] - pub _type: HookType, -} - -#[derive(serde::Serialize, Debug, PartialEq)] -pub struct CreateHookOptionConfig { - pub content_type: String, - pub url: Url, - #[serde(flatten)] - pub other: BTreeMap, -} - -#[derive(serde::Serialize, Debug, PartialEq, Default)] -pub struct EditHookOption { - pub active: Option, - pub authorization_header: Option, - pub branch_filter: Option, - pub config: Option>, - pub events: Option>, -} - -#[derive(Default, Debug)] -pub struct AdminOrganizationQuery { - pub page: Option, - pub limit: Option, -} - -impl AdminOrganizationQuery { - fn path(&self) -> String { - let mut s = String::from("admin/orgs?"); - if let Some(page) = self.page { - s.push_str("page="); - s.write_fmt(format_args!("{page}")) - .expect("writing to string can't fail"); - s.push('&'); - } - if let Some(limit) = self.limit { - s.push_str("limit="); - s.write_fmt(format_args!("{limit}")) - .expect("writing to string can't fail"); - s.push('&'); - } - s - } -} - -#[derive(Default, Debug)] -pub struct UnadoptedRepoQuery { - pub page: Option, - pub limit: Option, - pub pattern: String, -} - -impl UnadoptedRepoQuery { - fn path(&self) -> String { - let mut s = String::from("admin/unadopted?"); - if let Some(page) = self.page { - s.push_str("page="); - s.write_fmt(format_args!("{page}")) - .expect("writing to string can't fail"); - s.push('&'); - } - if let Some(limit) = self.limit { - s.push_str("limit="); - s.write_fmt(format_args!("{limit}")) - .expect("writing to string can't fail"); - s.push('&'); - } - if !self.pattern.is_empty() { - s.push_str("pattern="); - s.push_str(&self.pattern); - s.push('&'); - } - s - } -} - -#[derive(Default, Debug)] -pub struct AdminUserQuery { - pub source_id: Option, - pub login_name: String, - pub page: Option, - pub limit: Option, -} - -impl AdminUserQuery { - fn path(&self) -> String { - let mut s = String::from("admin/users?"); - if let Some(source_id) = self.source_id { - s.push_str("source_id="); - s.write_fmt(format_args!("{source_id}")) - .expect("writing to string can't fail"); - s.push('&'); - } - if !self.login_name.is_empty() { - s.push_str("login_name="); - s.push_str(&self.login_name); - s.push('&'); - } - if let Some(page) = self.page { - s.push_str("page="); - s.write_fmt(format_args!("{page}")) - .expect("writing to string can't fail"); - s.push('&'); - } - if let Some(limit) = self.limit { - s.push_str("limit="); - s.write_fmt(format_args!("{limit}")) - .expect("writing to string can't fail"); - s.push('&'); - } - s - } -} - -#[derive(serde::Serialize, Debug, PartialEq)] -pub struct CreateUserOption { - #[serde(with = "time::serde::rfc3339::option")] - pub created_at: Option, - pub email: String, - pub full_name: Option, - pub login_name: Option, - pub must_change_password: bool, - pub password: String, - pub restricted: bool, - pub send_notify: bool, - pub source_id: Option, - pub username: String, - pub visibility: String, -} - -#[derive(serde::Serialize, Debug, PartialEq, Default)] -pub struct EditUserOption { - pub active: Option, - pub admin: Option, - pub allow_create_organization: Option, - pub allow_git_hook: Option, - pub allow_import_local: Option, - pub description: Option, - pub email: Option, - pub full_name: Option, - pub location: Option, - pub login_name: Option, - pub max_repo_creation: Option, - pub must_change_password: Option, - pub password: Option, - pub prohibit_login: Option, - pub restricted: Option, - pub source_id: Option, - pub visibility: Option, - pub website: Option, -} - -#[derive(serde::Serialize, Debug, PartialEq)] -pub struct CreateKeyOption { - pub key: String, - pub read_only: Option, - pub title: String, -} - -#[derive(serde::Deserialize, Debug, PartialEq)] -pub struct PublicKey { - #[serde(with = "time::serde::rfc3339")] - pub created_at: time::OffsetDateTime, - pub fingerprint: String, - pub id: u64, - pub key: String, - pub key_type: String, - pub read_only: Option, - pub title: String, - pub url: Option, - pub user: User, -} - -#[derive(serde::Serialize, Debug, PartialEq)] -pub struct CreateOrgOption { - pub description: Option, - pub full_name: Option, - pub location: Option, - pub repo_admin_change_team_access: Option, - pub username: String, - pub visibility: OrgVisibility, - pub website: Option, -} - -#[derive(serde::Serialize, Debug, PartialEq)] -#[serde(rename_all = "lowercase")] -pub enum OrgVisibility { - Public, - Limited, - Private, -} - -#[derive(serde::Serialize, Debug, PartialEq)] -pub struct RenameUserOption { - pub new_username: String, -} diff --git a/src/generated.rs b/src/generated.rs new file mode 100644 index 0000000..0486e27 --- /dev/null +++ b/src/generated.rs @@ -0,0 +1,12253 @@ +use crate::ForgejoError; +impl crate::Forgejo { + /// Returns the Person actor for a user + /// + /// - `user-id`: user ID of the user + pub async fn activitypub_person(&self, user_id: u32) -> Result { + let request = self + .get(&format!("/activitypub/user-id/{user_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 + /// + /// - `user-id`: user ID of the user + pub async fn activitypub_person_inbox(&self, user_id: u32) -> Result<(), ForgejoError> { + let request = self + .post(&format!("/activitypub/user-id/{user_id}/inbox")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List cron tasks + /// + pub async fn admin_cron_list( + &self, + query: AdminCronListQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/admin/cron?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Run cron task + /// + /// - `task`: task to run + pub async fn admin_cron_run(&self, task: &str) -> Result<(), ForgejoError> { + let request = self.post(&format!("/admin/cron/{task}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List all emails + /// + pub async fn admin_get_all_emails( + &self, + query: AdminGetAllEmailsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/admin/emails?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Search all emails + /// + pub async fn admin_search_emails( + &self, + query: AdminSearchEmailsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/admin/emails/search?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List system's webhooks + /// + pub async fn admin_list_hooks( + &self, + query: AdminListHooksQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/admin/hooks?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a hook + /// + /// - `body` + pub async fn admin_create_hook(&self, body: CreateHookOption) -> Result { + let request = self.post("/admin/hooks").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 hook + /// + /// - `id`: id of the hook to get + pub async fn admin_get_hook(&self, id: u64) -> Result { + let request = self.get(&format!("/admin/hooks/{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 hook + /// + /// - `id`: id of the hook to delete + pub async fn admin_delete_hook(&self, id: u64) -> Result<(), ForgejoError> { + let request = self.delete(&format!("/admin/hooks/{id}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a hook + /// + /// - `id`: id of the hook to update + /// - `body` + pub async fn admin_edit_hook( + &self, + id: u64, + body: EditHookOption, + ) -> Result { + let request = self + .patch(&format!("/admin/hooks/{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 all organizations + /// + pub async fn admin_get_all_orgs( + &self, + query: AdminGetAllOrgsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/admin/orgs?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List unadopted repositories + /// + pub async fn admin_unadopted_list( + &self, + query: AdminUnadoptedListQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/admin/unadopted?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Adopt unadopted files as a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn admin_adopt_repository( + &self, + owner: &str, + repo: &str, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!("/admin/unadopted/{owner}/{repo}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete unadopted files + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn admin_delete_unadopted_repository( + &self, + owner: &str, + repo: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/admin/unadopted/{owner}/{repo}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Search users according filter conditions + /// + pub async fn admin_search_users( + &self, + query: AdminSearchUsersQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/admin/users?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a user + /// + /// - `body` + pub async fn admin_create_user(&self, body: CreateUserOption) -> Result { + let request = self.post("/admin/users").json(&body).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a user + /// + /// - `username`: username of user to delete + pub async fn admin_delete_user( + &self, + username: &str, + query: AdminDeleteUserQuery, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/admin/users/{username}?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit an existing user + /// + /// - `username`: username of user to edit + /// - `body` + pub async fn admin_edit_user( + &self, + username: &str, + body: EditUserOption, + ) -> Result { + let request = self + .patch(&format!("/admin/users/{username}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a public key on behalf of a user + /// + /// - `username`: username of the user + /// - `key` + pub async fn admin_create_public_key( + &self, + username: &str, + key: CreateKeyOption, + ) -> Result { + let request = self + .post(&format!("/admin/users/{username}/keys")) + .json(&key) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a user's public key + /// + /// - `username`: username of user + /// - `id`: id of the key to delete + pub async fn admin_delete_user_public_key( + &self, + username: &str, + id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/admin/users/{username}/keys/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create an organization + /// + /// - `username`: username of the user that will own the created organization + /// - `organization` + pub async fn admin_create_org( + &self, + username: &str, + organization: CreateOrgOption, + ) -> Result { + let request = self + .post(&format!("/admin/users/{username}/orgs")) + .json(&organization) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Rename a user + /// + /// - `username`: existing username of user + /// - `body` + pub async fn admin_rename_user( + &self, + username: &str, + body: RenameUserOption, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!("/admin/users/{username}/rename")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a repository on behalf of a user + /// + /// - `username`: username of the user. This user will own the created repository + /// - `repository` + pub async fn admin_create_repo( + &self, + username: &str, + repository: CreateRepoOption, + ) -> Result { + let request = self + .post(&format!("/admin/users/{username}/repos")) + .json(&repository) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns a list of all gitignore templates + pub async fn list_gitignores_templates(&self) -> Result, ForgejoError> { + let request = self.get("/gitignore/templates").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns information about a gitignore template + /// + /// - `name`: name of the template + pub async fn get_gitignore_template_info( + &self, + name: &str, + ) -> Result { + let request = self.get(&format!("/gitignore/templates/{name}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns a list of all label templates + pub async fn list_label_templates(&self) -> Result, ForgejoError> { + let request = self.get("/label/templates").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns all labels in a template + /// + /// - `name`: name of the template + pub async fn get_label_template_info( + &self, + name: &str, + ) -> Result, ForgejoError> { + let request = self.get(&format!("/label/templates/{name}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns a list of all license templates + pub async fn list_license_templates( + &self, + ) -> Result, ForgejoError> { + let request = self.get("/licenses").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns information about a license template + /// + /// - `name`: name of the license + pub async fn get_license_template_info( + &self, + name: &str, + ) -> Result { + let request = self.get(&format!("/licenses/{name}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Render a markdown document as HTML + /// + /// - `body` + pub async fn render_markdown(&self, body: MarkdownOption) -> Result { + let request = self.post("/markdown").json(&body).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.text().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Render raw markdown as HTML + /// + /// - `body`: Request body to render + pub async fn render_markdown_raw(&self, body: String) -> Result { + let request = self.post("/markdown/raw").body(body).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.text().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Render a markup document as HTML + /// + /// - `body` + pub async fn render_markup(&self, body: MarkupOption) -> Result { + let request = self.post("/markup").json(&body).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.text().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns the nodeinfo of the Gitea application + pub async fn get_node_info(&self) -> Result { + let request = self.get("/nodeinfo").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List users's notification threads + /// + pub async fn notify_get_list( + &self, + query: NotifyGetListQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/notifications?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Mark notification threads as read, pinned or unread + /// + pub async fn notify_read_list( + &self, + query: NotifyReadListQuery, + ) -> Result, ForgejoError> { + let request = self + .put(&format!("/notifications?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 205 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check if unread notifications exist + pub async fn notify_new_available(&self) -> Result { + let request = self.get("/notifications/new").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get notification thread by ID + /// + /// - `id`: id of notification thread + pub async fn notify_get_thread(&self, id: &str) -> Result { + let request = self.get(&format!("/notifications/threads/{id}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Mark notification thread as read by ID + /// + /// - `id`: id of notification thread + pub async fn notify_read_thread( + &self, + id: &str, + query: NotifyReadThreadQuery, + ) -> Result { + let request = self + .patch(&format!( + "/notifications/threads/{id}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 205 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a repository in an organization + /// + /// - `org`: name of organization + /// - `body` + pub async fn create_org_repo_deprecated( + &self, + org: &str, + body: CreateRepoOption, + ) -> Result { + let request = self + .post(&format!("/org/{org}/repos")) + .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 list of organizations + /// + pub async fn org_get_all( + &self, + query: OrgGetAllQuery, + ) -> Result, ForgejoError> { + let request = self.get(&format!("/orgs?{}", query.to_string())).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create an organization + /// + /// - `organization` + pub async fn org_create( + &self, + organization: CreateOrgOption, + ) -> Result { + let request = self.post("/orgs").json(&organization).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get an organization + /// + /// - `org`: name of the organization to get + pub async fn org_get(&self, org: &str) -> Result { + let request = self.get(&format!("/orgs/{org}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete an organization + /// + /// - `org`: organization that is to be deleted + pub async fn org_delete(&self, org: &str) -> Result<(), ForgejoError> { + let request = self.delete(&format!("/orgs/{org}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit an organization + /// + /// - `org`: name of the organization to edit + /// - `body` + pub async fn org_edit( + &self, + org: &str, + body: EditOrgOption, + ) -> Result { + let request = self.patch(&format!("/orgs/{org}")).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 an organization's actions secrets + /// + /// - `org`: name of the organization + pub async fn org_list_actions_secrets( + &self, + org: &str, + query: OrgListActionsSecretsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/orgs/{org}/actions/secrets?{}", + query.to_string() + )) + .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 an organization + /// + /// - `org`: name of organization + /// - `secretname`: name of the secret + /// - `body` + pub async fn update_org_secret( + &self, + org: &str, + secretname: &str, + body: CreateOrUpdateSecretOption, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("/orgs/{org}/actions/secrets/{secretname}")) + .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 secret in an organization + /// + /// - `org`: name of organization + /// - `secretname`: name of the secret + pub async fn delete_org_secret(&self, org: &str, secretname: &str) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/orgs/{org}/actions/secrets/{secretname}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List an organization's activity feeds + /// + /// - `org`: name of the org + pub async fn org_list_activity_feeds( + &self, + org: &str, + query: OrgListActivityFeedsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/orgs/{org}/activities/feeds?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update Avatar + /// + /// - `org`: name of the organization + /// - `body` + pub async fn org_update_avatar( + &self, + org: &str, + body: UpdateUserAvatarOption, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!("/orgs/{org}/avatar")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete Avatar + /// + /// - `org`: name of the organization + pub async fn org_delete_avatar(&self, org: &str) -> Result<(), ForgejoError> { + let request = self.delete(&format!("/orgs/{org}/avatar")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Blocks a user from the organization + /// + /// - `org`: name of the org + /// - `username`: username of the user + pub async fn org_block_user(&self, org: &str, username: &str) -> Result<(), ForgejoError> { + let request = self.put(&format!("/orgs/{org}/block/{username}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List an organization's webhooks + /// + /// - `org`: name of the organization + pub async fn org_list_hooks( + &self, + org: &str, + query: OrgListHooksQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/orgs/{org}/hooks?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a hook + /// + /// - `org`: name of the organization + /// - `body` + pub async fn org_create_hook( + &self, + org: &str, + body: CreateHookOption, + ) -> Result { + let request = self + .post(&format!("/orgs/{org}/hooks")) + .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 hook + /// + /// - `org`: name of the organization + /// - `id`: id of the hook to get + pub async fn org_get_hook(&self, org: &str, id: u64) -> Result { + let request = self.get(&format!("/orgs/{org}/hooks/{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 hook + /// + /// - `org`: name of the organization + /// - `id`: id of the hook to delete + pub async fn org_delete_hook(&self, org: &str, id: u64) -> Result<(), ForgejoError> { + let request = self.delete(&format!("/orgs/{org}/hooks/{id}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a hook + /// + /// - `org`: name of the organization + /// - `id`: id of the hook to update + /// - `body` + pub async fn org_edit_hook( + &self, + org: &str, + id: u64, + body: EditHookOption, + ) -> Result { + let request = self + .patch(&format!("/orgs/{org}/hooks/{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 an organization's labels + /// + /// - `org`: name of the organization + pub async fn org_list_labels( + &self, + org: &str, + query: OrgListLabelsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/orgs/{org}/labels?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a label for an organization + /// + /// - `org`: name of the organization + /// - `body` + pub async fn org_create_label( + &self, + org: &str, + body: CreateLabelOption, + ) -> Result { + let request = self + .post(&format!("/orgs/{org}/labels")) + .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 single label + /// + /// - `org`: name of the organization + /// - `id`: id of the label to get + pub async fn org_get_label(&self, org: &str, id: u64) -> Result { + let request = self.get(&format!("/orgs/{org}/labels/{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 label + /// + /// - `org`: name of the organization + /// - `id`: id of the label to delete + pub async fn org_delete_label(&self, org: &str, id: u64) -> Result<(), ForgejoError> { + let request = self.delete(&format!("/orgs/{org}/labels/{id}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a label + /// + /// - `org`: name of the organization + /// - `id`: id of the label to edit + /// - `body` + pub async fn org_edit_label( + &self, + org: &str, + id: u64, + body: EditLabelOption, + ) -> Result { + let request = self + .patch(&format!("/orgs/{org}/labels/{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 the organization's blocked users + /// + /// - `org`: name of the org + pub async fn org_list_blocked_users( + &self, + org: &str, + query: OrgListBlockedUsersQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/orgs/{org}/list_blocked?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List an organization's members + /// + /// - `org`: name of the organization + pub async fn org_list_members( + &self, + org: &str, + query: OrgListMembersQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/orgs/{org}/members?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check if a user is a member of an organization + /// + /// - `org`: name of the organization + /// - `username`: username of the user + pub async fn org_is_member(&self, org: &str, username: &str) -> Result<(), ForgejoError> { + let request = self + .get(&format!("/orgs/{org}/members/{username}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove a member from an organization + /// + /// - `org`: name of the organization + /// - `username`: username of the user + pub async fn org_delete_member(&self, org: &str, username: &str) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/orgs/{org}/members/{username}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List an organization's public members + /// + /// - `org`: name of the organization + pub async fn org_list_public_members( + &self, + org: &str, + query: OrgListPublicMembersQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/orgs/{org}/public_members?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check if a user is a public member of an organization + /// + /// - `org`: name of the organization + /// - `username`: username of the user + pub async fn org_is_public_member( + &self, + org: &str, + username: &str, + ) -> Result<(), ForgejoError> { + let request = self + .get(&format!("/orgs/{org}/public_members/{username}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Publicize a user's membership + /// + /// - `org`: name of the organization + /// - `username`: username of the user + pub async fn org_publicize_member( + &self, + org: &str, + username: &str, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("/orgs/{org}/public_members/{username}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Conceal a user's membership + /// + /// - `org`: name of the organization + /// - `username`: username of the user + pub async fn org_conceal_member(&self, org: &str, username: &str) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/orgs/{org}/public_members/{username}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List an organization's repos + /// + /// - `org`: name of the organization + pub async fn org_list_repos( + &self, + org: &str, + query: OrgListReposQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/orgs/{org}/repos?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a repository in an organization + /// + /// - `org`: name of organization + /// - `body` + pub async fn create_org_repo( + &self, + org: &str, + body: CreateRepoOption, + ) -> Result { + let request = self + .post(&format!("/orgs/{org}/repos")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List an organization's teams + /// + /// - `org`: name of the organization + pub async fn org_list_teams( + &self, + org: &str, + query: OrgListTeamsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/orgs/{org}/teams?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a team + /// + /// - `org`: name of the organization + /// - `body` + pub async fn org_create_team( + &self, + org: &str, + body: CreateTeamOption, + ) -> Result { + let request = self + .post(&format!("/orgs/{org}/teams")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Search for teams within an organization + /// + /// - `org`: name of the organization + pub async fn team_search( + &self, + org: &str, + query: TeamSearchQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/orgs/{org}/teams/search?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Unblock a user from the organization + /// + /// - `org`: name of the org + /// - `username`: username of the user + pub async fn org_unblock_user(&self, org: &str, username: &str) -> Result<(), ForgejoError> { + let request = self + .put(&format!("/orgs/{org}/unblock/{username}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Gets all packages of an owner + /// + /// - `owner`: owner of the packages + pub async fn list_packages( + &self, + owner: &str, + query: ListPackagesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/packages/{owner}?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Gets a package + /// + /// - `owner`: owner of the package + /// - `type`: type of the package + /// - `name`: name of the package + /// - `version`: version of the package + pub async fn get_package( + &self, + owner: &str, + r#type: &str, + name: &str, + version: &str, + ) -> Result { + let request = self + .get(&format!("/packages/{owner}/{type}/{name}/{version}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a package + /// + /// - `owner`: owner of the package + /// - `type`: type of the package + /// - `name`: name of the package + /// - `version`: version of the package + pub async fn delete_package( + &self, + owner: &str, + r#type: &str, + name: &str, + version: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/packages/{owner}/{type}/{name}/{version}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Gets all files of a package + /// + /// - `owner`: owner of the package + /// - `type`: type of the package + /// - `name`: name of the package + /// - `version`: version of the package + pub async fn list_package_files( + &self, + owner: &str, + r#type: &str, + name: &str, + version: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/packages/{owner}/{type}/{name}/{version}/files")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Search for issues across the repositories that the user has access to + /// + pub async fn issue_search_issues( + &self, + query: IssueSearchIssuesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/issues/search?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Migrate a remote git repository + /// + /// - `body` + pub async fn repo_migrate(&self, body: MigrateRepoOptions) -> Result { + let request = self.post("/repos/migrate").json(&body).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Search for repositories + /// + pub async fn repo_search(&self, query: RepoSearchQuery) -> Result { + let request = self + .get(&format!("/repos/search?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_get(&self, owner: &str, repo: &str) -> Result { + let request = self.get(&format!("/repos/{owner}/{repo}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a repository + /// + /// - `owner`: owner of the repo to delete + /// - `repo`: name of the repo to delete + pub async fn repo_delete(&self, owner: &str, repo: &str) -> Result<(), ForgejoError> { + let request = self.delete(&format!("/repos/{owner}/{repo}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a repository's properties. Only fields that are set will be changed. + /// + /// - `owner`: owner of the repo to edit + /// - `repo`: name of the repo to edit + /// - `body`: Properties of a repo that you can edit + pub async fn repo_edit( + &self, + owner: &str, + repo: &str, + body: EditRepoOption, + ) -> Result { + let request = self + .patch(&format!("/repos/{owner}/{repo}")) + .json(&body) + .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 + /// - `repo`: name of the repository + /// - `secretname`: name of the secret + /// - `body` + pub async fn update_repo_secret( + &self, + owner: &str, + repo: &str, + secretname: &str, + body: CreateOrUpdateSecretOption, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!( + "/repos/{owner}/{repo}/actions/secrets/{secretname}" + )) + .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 secret in a repository + /// + /// - `owner`: owner of the repository + /// - `repo`: name of the repository + /// - `secretname`: name of the secret + pub async fn delete_repo_secret( + &self, + owner: &str, + repo: &str, + secretname: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/actions/secrets/{secretname}" + )) + .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 + /// - `repo`: name of the repo + pub async fn repo_list_activity_feeds( + &self, + owner: &str, + repo: &str, + query: RepoListActivityFeedsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/activities/feeds?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get an archive of a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `archive`: the git reference for download with attached archive format (e.g. master.zip) + pub async fn repo_get_archive( + &self, + owner: &str, + repo: &str, + archive: &str, + ) -> Result<(), ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/archive/{archive}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Return all users that have write access and can be assigned to issues + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_get_assignees( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/assignees")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update avatar + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_update_avatar( + &self, + owner: &str, + repo: &str, + body: UpdateRepoAvatarOption, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!("/repos/{owner}/{repo}/avatar")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete avatar + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_delete_avatar(&self, owner: &str, repo: &str) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/avatar")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List branch protections for a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_branch_protection( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/branch_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 branch protections for a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_create_branch_protection( + &self, + owner: &str, + repo: &str, + body: CreateBranchProtectionOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/branch_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 branch protection for the repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `name`: name of protected branch + pub async fn repo_get_branch_protection( + &self, + owner: &str, + repo: &str, + name: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/branch_protections/{name}")) + .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 branch protection for the repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `name`: name of protected branch + pub async fn repo_delete_branch_protection( + &self, + owner: &str, + repo: &str, + name: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/branch_protections/{name}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a branch protections for a repository. Only fields that are set will be changed + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `name`: name of protected branch + /// - `body` + pub async fn repo_edit_branch_protection( + &self, + owner: &str, + repo: &str, + name: &str, + body: EditBranchProtectionOption, + ) -> Result { + let request = self + .patch(&format!("/repos/{owner}/{repo}/branch_protections/{name}")) + .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 branches + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_branches( + &self, + owner: &str, + repo: &str, + query: RepoListBranchesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/branches?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a branch + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_create_branch( + &self, + owner: &str, + repo: &str, + body: CreateBranchRepoOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/branches")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Retrieve a specific branch from a repository, including its effective branch protection + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `branch`: branch to get + pub async fn repo_get_branch( + &self, + owner: &str, + repo: &str, + branch: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/branches/{branch}")) + .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 branch from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `branch`: branch to delete + pub async fn repo_delete_branch( + &self, + owner: &str, + repo: &str, + branch: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/branches/{branch}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repository's collaborators + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_collaborators( + &self, + owner: &str, + repo: &str, + query: RepoListCollaboratorsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/collaborators?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check if a user is a collaborator of a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `collaborator`: username of the collaborator + pub async fn repo_check_collaborator( + &self, + owner: &str, + repo: &str, + collaborator: &str, + ) -> Result<(), ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/collaborators/{collaborator}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a collaborator to a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `collaborator`: username of the collaborator to add + /// - `body` + pub async fn repo_add_collaborator( + &self, + owner: &str, + repo: &str, + collaborator: &str, + body: AddCollaboratorOption, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!( + "/repos/{owner}/{repo}/collaborators/{collaborator}" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a collaborator from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `collaborator`: username of the collaborator to delete + pub async fn repo_delete_collaborator( + &self, + owner: &str, + repo: &str, + collaborator: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/collaborators/{collaborator}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get repository permissions for a user + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `collaborator`: username of the collaborator + pub async fn repo_get_repo_permissions( + &self, + owner: &str, + repo: &str, + collaborator: &str, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/collaborators/{collaborator}/permission" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a list of all commits from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_get_all_commits( + &self, + owner: &str, + repo: &str, + query: RepoGetAllCommitsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/commits?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a commit's combined status, by branch/tag/commit reference + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `ref`: name of branch/tag/commit + pub async fn repo_get_combined_status_by_ref( + &self, + owner: &str, + repo: &str, + r#ref: &str, + query: RepoGetCombinedStatusByRefQuery, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/commits/{ref}/status?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a commit's statuses, by branch/tag/commit reference + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `ref`: name of branch/tag/commit + pub async fn repo_list_statuses_by_ref( + &self, + owner: &str, + repo: &str, + r#ref: &str, + query: RepoListStatusesByRefQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/commits/{ref}/statuses?{}", + query.to_string() + )) + .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 + /// - `repo`: name of the repo + pub async fn repo_get_contents_list( + &self, + owner: &str, + repo: &str, + query: RepoGetContentsListQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/contents?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Modify multiple files in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_change_files( + &self, + owner: &str, + repo: &str, + body: ChangeFilesOptions, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/contents")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Gets the metadata and contents (if a file) of an entry in a repository, or a list of entries if a dir + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `filepath`: path of the dir, file, symlink or submodule in the repo + pub async fn repo_get_contents( + &self, + owner: &str, + repo: &str, + filepath: &str, + query: RepoGetContentsQuery, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/contents/{filepath}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a file in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `filepath`: path of the file to update + /// - `body` + pub async fn repo_update_file( + &self, + owner: &str, + repo: &str, + filepath: &str, + body: UpdateFileOptions, + ) -> Result { + let request = self + .put(&format!("/repos/{owner}/{repo}/contents/{filepath}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a file in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `filepath`: path of the file to create + /// - `body` + pub async fn repo_create_file( + &self, + owner: &str, + repo: &str, + filepath: &str, + body: CreateFileOptions, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/contents/{filepath}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a file in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `filepath`: path of the file to delete + /// - `body` + pub async fn repo_delete_file( + &self, + owner: &str, + repo: &str, + filepath: &str, + body: DeleteFileOptions, + ) -> Result { + let request = self + .delete(&format!("/repos/{owner}/{repo}/contents/{filepath}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Apply diff patch to repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_apply_diff_patch( + &self, + owner: &str, + repo: &str, + body: UpdateFileOptions, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/diffpatch")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get the EditorConfig definitions of a file in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `filepath`: filepath of file to get + pub async fn repo_get_editor_config( + &self, + owner: &str, + repo: &str, + filepath: &str, + query: RepoGetEditorConfigQuery, + ) -> Result<(), ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/editorconfig/{filepath}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repository's forks + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn list_forks( + &self, + owner: &str, + repo: &str, + query: ListForksQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/forks?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Fork a repository + /// + /// - `owner`: owner of the repo to fork + /// - `repo`: name of the repo to fork + /// - `body` + pub async fn create_fork( + &self, + owner: &str, + repo: &str, + body: CreateForkOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/forks")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 202 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Gets the blob of a repository. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `sha`: sha of the commit + pub async fn get_blob( + &self, + owner: &str, + repo: &str, + sha: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/git/blobs/{sha}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a single commit from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `sha`: a git ref or commit sha + pub async fn repo_get_single_commit( + &self, + owner: &str, + repo: &str, + sha: &str, + query: RepoGetSingleCommitQuery, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/git/commits/{sha}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a commit's diff or patch + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `sha`: SHA of the commit to get + /// - `diffType`: whether the output is diff or patch + pub async fn repo_download_commit_diff_or_patch( + &self, + owner: &str, + repo: &str, + sha: &str, + diff_type: &str, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/git/commits/{sha}.{diff_type}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.text().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a note corresponding to a single commit from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `sha`: a git ref or commit sha + pub async fn repo_get_note( + &self, + owner: &str, + repo: &str, + sha: &str, + query: RepoGetNoteQuery, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/git/notes/{sha}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get specified ref or filtered repository's refs + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_all_git_refs( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/git/refs")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get specified ref or filtered repository's refs + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `ref`: part or full name of the ref + pub async fn repo_list_git_refs( + &self, + owner: &str, + repo: &str, + r#ref: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/git/refs/{ref}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Gets the tag object of an annotated tag (not lightweight tags) + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `sha`: sha of the tag. The Git tags API only supports annotated tag objects, not lightweight tags. + pub async fn get_annotated_tag( + &self, + owner: &str, + repo: &str, + sha: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/git/tags/{sha}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Gets the tree of a repository. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `sha`: sha of the commit + pub async fn get_tree( + &self, + owner: &str, + repo: &str, + sha: &str, + query: GetTreeQuery, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/git/trees/{sha}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the hooks in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_hooks( + &self, + owner: &str, + repo: &str, + query: RepoListHooksQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/hooks?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a hook + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_create_hook( + &self, + owner: &str, + repo: &str, + body: CreateHookOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/hooks")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the Git hooks in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_git_hooks( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/hooks/git")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a Git hook + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the hook to get + pub async fn repo_get_git_hook( + &self, + owner: &str, + repo: &str, + id: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/hooks/git/{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 Git hook in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the hook to get + pub async fn repo_delete_git_hook( + &self, + owner: &str, + repo: &str, + id: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/hooks/git/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a Git hook in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the hook to get + /// - `body` + pub async fn repo_edit_git_hook( + &self, + owner: &str, + repo: &str, + id: &str, + body: EditGitHookOption, + ) -> Result { + let request = self + .patch(&format!("/repos/{owner}/{repo}/hooks/git/{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())), + } + } + + /// Get a hook + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the hook to get + pub async fn repo_get_hook( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/hooks/{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 hook in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the hook to delete + pub async fn repo_delete_hook( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/hooks/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a hook in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: index of the hook + /// - `body` + pub async fn repo_edit_hook( + &self, + owner: &str, + repo: &str, + id: u64, + body: EditHookOption, + ) -> Result { + let request = self + .patch(&format!("/repos/{owner}/{repo}/hooks/{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())), + } + } + + /// Test a push webhook + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the hook to test + pub async fn repo_test_hook( + &self, + owner: &str, + repo: &str, + id: u64, + query: RepoTestHookQuery, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/hooks/{id}/tests?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns the issue config for a repo + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_get_issue_config( + &self, + owner: &str, + repo: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/issue_config")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns the validation information for a issue config + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_validate_issue_config( + &self, + owner: &str, + repo: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/issue_config/validate")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get available issue templates for a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_get_issue_templates( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/issue_templates")) + .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 issues + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn issue_list_issues( + &self, + owner: &str, + repo: &str, + query: IssueListIssuesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create an issue. If using deadline only the date will be taken into account, and time of day ignored. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn issue_create_issue( + &self, + owner: &str, + repo: &str, + body: CreateIssueOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/issues")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List all comments in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn issue_get_repo_comments( + &self, + owner: &str, + repo: &str, + query: IssueGetRepoCommentsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/comments?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a comment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the comment + pub async fn issue_get_comment( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/issues/comments/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(Some(response.json().await?)), + 204 => Ok(None), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a comment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of comment to delete + pub async fn issue_delete_comment( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/issues/comments/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a comment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the comment to edit + /// - `body` + pub async fn issue_edit_comment( + &self, + owner: &str, + repo: &str, + id: u64, + body: EditIssueCommentOption, + ) -> Result, ForgejoError> { + let request = self + .patch(&format!("/repos/{owner}/{repo}/issues/comments/{id}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(Some(response.json().await?)), + 204 => Ok(None), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List comment's attachments + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the comment + pub async fn issue_list_issue_comment_attachments( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/comments/{id}/assets" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a comment attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the comment + /// - `attachment`: attachment to upload + pub async fn issue_create_issue_comment_attachment( + &self, + owner: &str, + repo: &str, + id: u64, + attachment: Vec, + query: IssueCreateIssueCommentAttachmentQuery, + ) -> Result { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/issues/comments/{id}/assets?{}", + query.to_string() + )) + .multipart( + reqwest::multipart::Form::new().part( + "attachment", + reqwest::multipart::Part::bytes(attachment) + .file_name("file") + .mime_str("*/*") + .unwrap(), + ), + ) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a comment attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the comment + /// - `attachment_id`: id of the attachment to get + pub async fn issue_get_issue_comment_attachment( + &self, + owner: &str, + repo: &str, + id: u64, + attachment_id: u64, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/comments/{id}/assets/{attachment_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 comment attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the comment + /// - `attachment_id`: id of the attachment to delete + pub async fn issue_delete_issue_comment_attachment( + &self, + owner: &str, + repo: &str, + id: u64, + attachment_id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/issues/comments/{id}/assets/{attachment_id}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a comment attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the comment + /// - `attachment_id`: id of the attachment to edit + /// - `body` + pub async fn issue_edit_issue_comment_attachment( + &self, + owner: &str, + repo: &str, + id: u64, + attachment_id: u64, + body: EditAttachmentOptions, + ) -> Result { + let request = self + .patch(&format!( + "/repos/{owner}/{repo}/issues/comments/{id}/assets/{attachment_id}" + )) + .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 list of reactions from a comment of an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the comment to edit + pub async fn issue_get_comment_reactions( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/comments/{id}/reactions" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a reaction to a comment of an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the comment to edit + /// - `content` + pub async fn issue_post_comment_reaction( + &self, + owner: &str, + repo: &str, + id: u64, + content: EditReactionOption, + ) -> Result { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/issues/comments/{id}/reactions" + )) + .json(&content) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove a reaction from a comment of an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the comment to edit + /// - `content` + pub async fn issue_delete_comment_reaction( + &self, + owner: &str, + repo: &str, + id: u64, + content: EditReactionOption, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/issues/comments/{id}/reactions" + )) + .json(&content) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repo's pinned issues + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_pinned_issues( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/issues/pinned")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue to get + pub async fn issue_get_issue( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/issues/{index}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of issue to delete + pub async fn issue_delete( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/issues/{index}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit an issue. If using deadline only the date will be taken into account, and time of day ignored. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue to edit + /// - `body` + pub async fn issue_edit_issue( + &self, + owner: &str, + repo: &str, + index: u64, + body: EditIssueOption, + ) -> Result { + let request = self + .patch(&format!("/repos/{owner}/{repo}/issues/{index}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List issue's attachments + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + pub async fn issue_list_issue_attachments( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/issues/{index}/assets")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create an issue attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `attachment`: attachment to upload + pub async fn issue_create_issue_attachment( + &self, + owner: &str, + repo: &str, + index: u64, + attachment: Vec, + query: IssueCreateIssueAttachmentQuery, + ) -> Result { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/issues/{index}/assets?{}", + query.to_string() + )) + .multipart( + reqwest::multipart::Form::new().part( + "attachment", + reqwest::multipart::Part::bytes(attachment) + .file_name("file") + .mime_str("*/*") + .unwrap(), + ), + ) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get an issue attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `attachment_id`: id of the attachment to get + pub async fn issue_get_issue_attachment( + &self, + owner: &str, + repo: &str, + index: u64, + attachment_id: u64, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/{index}/assets/{attachment_id}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete an issue attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `attachment_id`: id of the attachment to delete + pub async fn issue_delete_issue_attachment( + &self, + owner: &str, + repo: &str, + index: u64, + attachment_id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/issues/{index}/assets/{attachment_id}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit an issue attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `attachment_id`: id of the attachment to edit + /// - `body` + pub async fn issue_edit_issue_attachment( + &self, + owner: &str, + repo: &str, + index: u64, + attachment_id: u64, + body: EditAttachmentOptions, + ) -> Result { + let request = self + .patch(&format!( + "/repos/{owner}/{repo}/issues/{index}/assets/{attachment_id}" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List issues that are blocked by this issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + pub async fn issue_list_blocks( + &self, + owner: &str, + repo: &str, + index: &str, + query: IssueListBlocksQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/{index}/blocks?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Block the issue given in the body by the issue in path + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `body` + pub async fn issue_create_issue_blocking( + &self, + owner: &str, + repo: &str, + index: &str, + body: IssueMeta, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/issues/{index}/blocks")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Unblock the issue given in the body by the issue in path + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `body` + pub async fn issue_remove_issue_blocking( + &self, + owner: &str, + repo: &str, + index: &str, + body: IssueMeta, + ) -> Result { + let request = self + .delete(&format!("/repos/{owner}/{repo}/issues/{index}/blocks")) + .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 all comments on an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + pub async fn issue_get_comments( + &self, + owner: &str, + repo: &str, + index: u64, + query: IssueGetCommentsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/{index}/comments?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a comment to an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `body` + pub async fn issue_create_comment( + &self, + owner: &str, + repo: &str, + index: u64, + body: CreateIssueCommentOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/issues/{index}/comments")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a comment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: this parameter is ignored + /// - `id`: id of comment to delete + pub async fn issue_delete_comment_deprecated( + &self, + owner: &str, + repo: &str, + index: u32, + id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/issues/{index}/comments/{id}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a comment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: this parameter is ignored + /// - `id`: id of the comment to edit + /// - `body` + pub async fn issue_edit_comment_deprecated( + &self, + owner: &str, + repo: &str, + index: u32, + id: u64, + body: EditIssueCommentOption, + ) -> Result, ForgejoError> { + let request = self + .patch(&format!( + "/repos/{owner}/{repo}/issues/{index}/comments/{id}" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(Some(response.json().await?)), + 204 => Ok(None), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Set an issue deadline. If set to null, the deadline is deleted. If using deadline only the date will be taken into account, and time of day ignored. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue to create or update a deadline on + /// - `body` + pub async fn issue_edit_issue_deadline( + &self, + owner: &str, + repo: &str, + index: u64, + body: EditDeadlineOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/issues/{index}/deadline")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List an issue's dependencies, i.e all issues that block this issue. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + pub async fn issue_list_issue_dependencies( + &self, + owner: &str, + repo: &str, + index: &str, + query: IssueListIssueDependenciesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/{index}/dependencies?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Make the issue in the url depend on the issue in the form. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `body` + pub async fn issue_create_issue_dependencies( + &self, + owner: &str, + repo: &str, + index: &str, + body: IssueMeta, + ) -> Result { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/issues/{index}/dependencies" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove an issue dependency + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `body` + pub async fn issue_remove_issue_dependencies( + &self, + owner: &str, + repo: &str, + index: &str, + body: IssueMeta, + ) -> Result { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/issues/{index}/dependencies" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get an issue's labels + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + pub async fn issue_get_labels( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/issues/{index}/labels")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Replace an issue's labels + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `body` + pub async fn issue_replace_labels( + &self, + owner: &str, + repo: &str, + index: u64, + body: IssueLabelsOption, + ) -> Result, ForgejoError> { + let request = self + .put(&format!("/repos/{owner}/{repo}/issues/{index}/labels")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a label to an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `body` + pub async fn issue_add_label( + &self, + owner: &str, + repo: &str, + index: u64, + body: IssueLabelsOption, + ) -> Result, ForgejoError> { + let request = self + .post(&format!("/repos/{owner}/{repo}/issues/{index}/labels")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove all labels from an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `body` + pub async fn issue_clear_labels( + &self, + owner: &str, + repo: &str, + index: u64, + body: DeleteLabelsOption, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/issues/{index}/labels")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove a label from an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `id`: id of the label to remove + /// - `body` + pub async fn issue_remove_label( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + body: DeleteLabelsOption, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/issues/{index}/labels/{id}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Pin an Issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of issue to pin + pub async fn pin_issue(&self, owner: &str, repo: &str, index: u64) -> Result<(), ForgejoError> { + let request = self + .post(&format!("/repos/{owner}/{repo}/issues/{index}/pin")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Unpin an Issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of issue to unpin + pub async fn unpin_issue( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/issues/{index}/pin")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Moves the Pin to the given Position + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of issue + /// - `position`: the new position + pub async fn move_issue_pin( + &self, + owner: &str, + repo: &str, + index: u64, + position: u64, + ) -> Result<(), ForgejoError> { + let request = self + .patch(&format!( + "/repos/{owner}/{repo}/issues/{index}/pin/{position}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a list reactions of an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + pub async fn issue_get_issue_reactions( + &self, + owner: &str, + repo: &str, + index: u64, + query: IssueGetIssueReactionsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/{index}/reactions?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a reaction to an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `content` + pub async fn issue_post_issue_reaction( + &self, + owner: &str, + repo: &str, + index: u64, + content: EditReactionOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/issues/{index}/reactions")) + .json(&content) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove a reaction from an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `content` + pub async fn issue_delete_issue_reaction( + &self, + owner: &str, + repo: &str, + index: u64, + content: EditReactionOption, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/issues/{index}/reactions")) + .json(&content) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete an issue's existing stopwatch. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue to stop the stopwatch on + pub async fn issue_delete_stop_watch( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/issues/{index}/stopwatch/delete" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Start stopwatch on an issue. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue to create the stopwatch on + pub async fn issue_start_stop_watch( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/issues/{index}/stopwatch/start" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Stop an issue's existing stopwatch. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue to stop the stopwatch on + pub async fn issue_stop_stop_watch( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/issues/{index}/stopwatch/stop" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get users who subscribed on an issue. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + pub async fn issue_subscriptions( + &self, + owner: &str, + repo: &str, + index: u64, + query: IssueSubscriptionsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/{index}/subscriptions?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check if user is subscribed to an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + pub async fn issue_check_subscription( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/{index}/subscriptions/check" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Subscribe user to issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `user`: user to subscribe + pub async fn issue_add_subscription( + &self, + owner: &str, + repo: &str, + index: u64, + user: &str, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!( + "/repos/{owner}/{repo}/issues/{index}/subscriptions/{user}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + 201 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Unsubscribe user from issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `user`: user witch unsubscribe + pub async fn issue_delete_subscription( + &self, + owner: &str, + repo: &str, + index: u64, + user: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/issues/{index}/subscriptions/{user}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + 201 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List all comments and events on an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + pub async fn issue_get_comments_and_timeline( + &self, + owner: &str, + repo: &str, + index: u64, + query: IssueGetCommentsAndTimelineQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/{index}/timeline?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List an issue's tracked times + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + pub async fn issue_tracked_times( + &self, + owner: &str, + repo: &str, + index: u64, + query: IssueTrackedTimesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/issues/{index}/times?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add tracked time to a issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `body` + pub async fn issue_add_time( + &self, + owner: &str, + repo: &str, + index: u64, + body: AddTimeOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/issues/{index}/times")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Reset a tracked time of an issue + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue to add tracked time to + pub async fn issue_reset_time( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/issues/{index}/times")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete specific tracked time + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the issue + /// - `id`: id of time to delete + pub async fn issue_delete_time( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/issues/{index}/times/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repository's keys + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_keys( + &self, + owner: &str, + repo: &str, + query: RepoListKeysQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/keys?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a key to a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_create_key( + &self, + owner: &str, + repo: &str, + body: CreateKeyOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/keys")) + .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 repository's key by id + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the key to get + pub async fn repo_get_key( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/keys/{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 key from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the key to delete + pub async fn repo_delete_key( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/keys/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get all of a repository's labels + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn issue_list_labels( + &self, + owner: &str, + repo: &str, + query: IssueListLabelsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/labels?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a label + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn issue_create_label( + &self, + owner: &str, + repo: &str, + body: CreateLabelOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/labels")) + .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 single label + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the label to get + pub async fn issue_get_label( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/labels/{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 label + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the label to delete + pub async fn issue_delete_label( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/labels/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a label + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the label to edit + /// - `body` + pub async fn issue_edit_label( + &self, + owner: &str, + repo: &str, + id: u64, + body: EditLabelOption, + ) -> Result { + let request = self + .patch(&format!("/repos/{owner}/{repo}/labels/{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())), + } + } + + /// Get languages and number of bytes of code written + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_get_languages( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/languages")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a file or it's LFS object from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `filepath`: filepath of the file to get + pub async fn repo_get_raw_file_or_lfs( + &self, + owner: &str, + repo: &str, + filepath: &str, + query: RepoGetRawFileOrLfsQuery, + ) -> Result<(), ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/media/{filepath}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get all of a repository's opened milestones + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn issue_get_milestones_list( + &self, + owner: &str, + repo: &str, + query: IssueGetMilestonesListQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/milestones?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a milestone + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn issue_create_milestone( + &self, + owner: &str, + repo: &str, + body: CreateMilestoneOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/milestones")) + .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 milestone + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: the milestone to get, identified by ID and if not available by name + pub async fn issue_get_milestone( + &self, + owner: &str, + repo: &str, + id: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/milestones/{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 milestone + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: the milestone to delete, identified by ID and if not available by name + pub async fn issue_delete_milestone( + &self, + owner: &str, + repo: &str, + id: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/milestones/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a milestone + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: the milestone to edit, identified by ID and if not available by name + /// - `body` + pub async fn issue_edit_milestone( + &self, + owner: &str, + repo: &str, + id: &str, + body: EditMilestoneOption, + ) -> Result { + let request = self + .patch(&format!("/repos/{owner}/{repo}/milestones/{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())), + } + } + + /// Sync a mirrored repository + /// + /// - `owner`: owner of the repo to sync + /// - `repo`: name of the repo to sync + pub async fn repo_mirror_sync(&self, owner: &str, repo: &str) -> Result<(), ForgejoError> { + let request = self + .post(&format!("/repos/{owner}/{repo}/mirror-sync")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns if new Issue Pins are allowed + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_new_pin_allowed( + &self, + owner: &str, + repo: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/new_pin_allowed")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List users's notification threads on a specific repo + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn notify_get_repo_list( + &self, + owner: &str, + repo: &str, + query: NotifyGetRepoListQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/notifications?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Mark notification threads as read, pinned or unread on a specific repo + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn notify_read_repo_list( + &self, + owner: &str, + repo: &str, + query: NotifyReadRepoListQuery, + ) -> Result, ForgejoError> { + let request = self + .put(&format!( + "/repos/{owner}/{repo}/notifications?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 205 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repo's pull requests + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_pull_requests( + &self, + owner: &str, + repo: &str, + query: RepoListPullRequestsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/pulls?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_create_pull_request( + &self, + owner: &str, + repo: &str, + body: CreatePullRequestOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/pulls")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repo's pinned pull requests + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_pinned_pull_requests( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/pulls/pinned")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request to get + pub async fn repo_get_pull_request( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/pulls/{index}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a pull request. If using deadline only the date will be taken into account, and time of day ignored. + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request to edit + /// - `body` + pub async fn repo_edit_pull_request( + &self, + owner: &str, + repo: &str, + index: u64, + body: EditPullRequestOption, + ) -> Result { + let request = self + .patch(&format!("/repos/{owner}/{repo}/pulls/{index}")) + .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 pull request diff or patch + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request to get + /// - `diffType`: whether the output is diff or patch + pub async fn repo_download_pull_diff_or_patch( + &self, + owner: &str, + repo: &str, + index: u64, + diff_type: &str, + query: RepoDownloadPullDiffOrPatchQuery, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/pulls/{index}.{diff_type}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.text().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get commits for a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request to get + pub async fn repo_get_pull_request_commits( + &self, + owner: &str, + repo: &str, + index: u64, + query: RepoGetPullRequestCommitsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/pulls/{index}/commits?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get changed files for a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request to get + pub async fn repo_get_pull_request_files( + &self, + owner: &str, + repo: &str, + index: u64, + query: RepoGetPullRequestFilesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/pulls/{index}/files?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check if a pull request has been merged + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + pub async fn repo_pull_request_is_merged( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result<(), ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/pulls/{index}/merge")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Merge a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request to merge + /// - `body` + pub async fn repo_merge_pull_request( + &self, + owner: &str, + repo: &str, + index: u64, + body: MergePullRequestOption, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!("/repos/{owner}/{repo}/pulls/{index}/merge")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Cancel the scheduled auto merge for the given pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request to merge + pub async fn repo_cancel_scheduled_auto_merge( + &self, + owner: &str, + repo: &str, + index: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/pulls/{index}/merge")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// create review requests for a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `body` + pub async fn repo_create_pull_review_requests( + &self, + owner: &str, + repo: &str, + index: u64, + body: PullReviewRequestOptions, + ) -> Result, ForgejoError> { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/pulls/{index}/requested_reviewers" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// cancel review requests for a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `body` + pub async fn repo_delete_pull_review_requests( + &self, + owner: &str, + repo: &str, + index: u64, + body: PullReviewRequestOptions, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/pulls/{index}/requested_reviewers" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List all reviews for a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + pub async fn repo_list_pull_reviews( + &self, + owner: &str, + repo: &str, + index: u64, + query: RepoListPullReviewsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/pulls/{index}/reviews?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a review to an pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `body` + pub async fn repo_create_pull_review( + &self, + owner: &str, + repo: &str, + index: u64, + body: CreatePullReviewOptions, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/pulls/{index}/reviews")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a specific review for a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `id`: id of the review + pub async fn repo_get_pull_review( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/pulls/{index}/reviews/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Submit a pending review to an pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `id`: id of the review + /// - `body` + pub async fn repo_submit_pull_review( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + body: SubmitPullReviewOptions, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/pulls/{index}/reviews/{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())), + } + } + + /// Delete a specific review from a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `id`: id of the review + pub async fn repo_delete_pull_review( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/pulls/{index}/reviews/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a specific review for a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `id`: id of the review + pub async fn repo_get_pull_review_comments( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Dismiss a review for a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `id`: id of the review + /// - `body` + pub async fn repo_dismiss_pull_review( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + body: DismissPullReviewOptions, + ) -> Result { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/pulls/{index}/reviews/{id}/dismissals" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Cancel to dismiss a review for a pull request + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `id`: id of the review + pub async fn repo_un_dismiss_pull_review( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + ) -> Result { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/pulls/{index}/reviews/{id}/undismissals" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Merge PR's baseBranch into headBranch + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request to get + pub async fn repo_update_pull_request( + &self, + owner: &str, + repo: &str, + index: u64, + query: RepoUpdatePullRequestQuery, + ) -> Result<(), ForgejoError> { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/pulls/{index}/update?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get all push mirrors of the repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_push_mirrors( + &self, + owner: &str, + repo: &str, + query: RepoListPushMirrorsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/push_mirrors?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// add a push mirror to the repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_add_push_mirror( + &self, + owner: &str, + repo: &str, + body: CreatePushMirrorOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/push_mirrors")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Sync all push mirrored repository + /// + /// - `owner`: owner of the repo to sync + /// - `repo`: name of the repo to sync + pub async fn repo_push_mirror_sync(&self, owner: &str, repo: &str) -> Result<(), ForgejoError> { + let request = self + .post(&format!("/repos/{owner}/{repo}/push_mirrors-sync")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get push mirror of the repository by remoteName + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `name`: remote name of push mirror + pub async fn repo_get_push_mirror_by_remote_name( + &self, + owner: &str, + repo: &str, + name: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/push_mirrors/{name}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// deletes a push mirror from a repository by remoteName + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `name`: remote name of the pushMirror + pub async fn repo_delete_push_mirror( + &self, + owner: &str, + repo: &str, + name: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/push_mirrors/{name}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a file from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `filepath`: filepath of the file to get + pub async fn repo_get_raw_file( + &self, + owner: &str, + repo: &str, + filepath: &str, + query: RepoGetRawFileQuery, + ) -> Result<(), ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/raw/{filepath}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repo's releases + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_releases( + &self, + owner: &str, + repo: &str, + query: RepoListReleasesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/releases?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a release + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_create_release( + &self, + owner: &str, + repo: &str, + body: CreateReleaseOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/releases")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Gets the most recent non-prerelease, non-draft release of a repository, sorted by created_at + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_get_latest_release( + &self, + owner: &str, + repo: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/releases/latest")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a release by tag name + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `tag`: tag name of the release to get + pub async fn repo_get_release_by_tag( + &self, + owner: &str, + repo: &str, + tag: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/releases/tags/{tag}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a release by tag name + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `tag`: tag name of the release to delete + pub async fn repo_delete_release_by_tag( + &self, + owner: &str, + repo: &str, + tag: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/releases/tags/{tag}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a release + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the release to get + pub async fn repo_get_release( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/releases/{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 release + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the release to delete + pub async fn repo_delete_release( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/releases/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a release + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the release to edit + /// - `body` + pub async fn repo_edit_release( + &self, + owner: &str, + repo: &str, + id: u64, + body: EditReleaseOption, + ) -> Result { + let request = self + .patch(&format!("/repos/{owner}/{repo}/releases/{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 release's attachments + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the release + pub async fn repo_list_release_attachments( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/releases/{id}/assets")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a release attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the release + /// - `attachment`: attachment to upload + pub async fn repo_create_release_attachment( + &self, + owner: &str, + repo: &str, + id: u64, + attachment: Vec, + query: RepoCreateReleaseAttachmentQuery, + ) -> Result { + let request = self + .post(&format!( + "/repos/{owner}/{repo}/releases/{id}/assets?{}", + query.to_string() + )) + .multipart( + reqwest::multipart::Form::new().part( + "attachment", + reqwest::multipart::Part::bytes(attachment) + .file_name("file") + .mime_str("*/*") + .unwrap(), + ), + ) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a release attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the release + /// - `attachment_id`: id of the attachment to get + pub async fn repo_get_release_attachment( + &self, + owner: &str, + repo: &str, + id: u64, + attachment_id: u64, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/releases/{id}/assets/{attachment_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 release attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the release + /// - `attachment_id`: id of the attachment to delete + pub async fn repo_delete_release_attachment( + &self, + owner: &str, + repo: &str, + id: u64, + attachment_id: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "/repos/{owner}/{repo}/releases/{id}/assets/{attachment_id}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a release attachment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `id`: id of the release + /// - `attachment_id`: id of the attachment to edit + /// - `body` + pub async fn repo_edit_release_attachment( + &self, + owner: &str, + repo: &str, + id: u64, + attachment_id: u64, + body: EditAttachmentOptions, + ) -> Result { + let request = self + .patch(&format!( + "/repos/{owner}/{repo}/releases/{id}/assets/{attachment_id}" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Return all users that can be requested to review in this repo + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_get_reviewers( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/reviewers")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get signing-key.gpg for given repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_signing_key(&self, owner: &str, repo: &str) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/signing-key.gpg")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.text().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repo's stargazers + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_stargazers( + &self, + owner: &str, + repo: &str, + query: RepoListStargazersQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/stargazers?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a commit's statuses + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `sha`: sha of the commit + pub async fn repo_list_statuses( + &self, + owner: &str, + repo: &str, + sha: &str, + query: RepoListStatusesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/statuses/{sha}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a commit status + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `sha`: sha of the commit + /// - `body` + pub async fn repo_create_status( + &self, + owner: &str, + repo: &str, + sha: &str, + body: CreateStatusOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/statuses/{sha}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repo's watchers + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_subscribers( + &self, + owner: &str, + repo: &str, + query: RepoListSubscribersQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/subscribers?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check if the current user is watching a repo + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn user_current_check_subscription( + &self, + owner: &str, + repo: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/subscription")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Watch a repo + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn user_current_put_subscription( + &self, + owner: &str, + repo: &str, + ) -> Result { + let request = self + .put(&format!("/repos/{owner}/{repo}/subscription")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Unwatch a repo + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn user_current_delete_subscription( + &self, + owner: &str, + repo: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/subscription")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repository's tags + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_tags( + &self, + owner: &str, + repo: &str, + query: RepoListTagsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/tags?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a new git tag in a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_create_tag( + &self, + owner: &str, + repo: &str, + body: CreateTagOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/tags")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get the tag of a repository by tag name + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `tag`: name of tag + pub async fn repo_get_tag( + &self, + owner: &str, + repo: &str, + tag: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/tags/{tag}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a repository's tag by name + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `tag`: name of tag to delete + pub async fn repo_delete_tag( + &self, + owner: &str, + repo: &str, + tag: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/tags/{tag}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repository's teams + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_teams( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self.get(&format!("/repos/{owner}/{repo}/teams")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check if a team is assigned to a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `team`: team name + pub async fn repo_check_team( + &self, + owner: &str, + repo: &str, + team: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/teams/{team}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a team to a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `team`: team name + pub async fn repo_add_team( + &self, + owner: &str, + repo: &str, + team: &str, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("/repos/{owner}/{repo}/teams/{team}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a team from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `team`: team name + pub async fn repo_delete_team( + &self, + owner: &str, + repo: &str, + team: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/teams/{team}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a repo's tracked times + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_tracked_times( + &self, + owner: &str, + repo: &str, + query: RepoTrackedTimesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/times?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a user's tracked times in a repo + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `user`: username of user + pub async fn user_tracked_times( + &self, + owner: &str, + repo: &str, + user: &str, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/repos/{owner}/{repo}/times/{user}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get list of topics that a repository has + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_topics( + &self, + owner: &str, + repo: &str, + query: RepoListTopicsQuery, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/topics?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Replace list of topics for a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_update_topics( + &self, + owner: &str, + repo: &str, + body: RepoTopicOptions, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("/repos/{owner}/{repo}/topics")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a topic to a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `topic`: name of the topic to add + pub async fn repo_add_topic( + &self, + owner: &str, + repo: &str, + topic: &str, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("/repos/{owner}/{repo}/topics/{topic}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a topic from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `topic`: name of the topic to delete + pub async fn repo_delete_topic( + &self, + owner: &str, + repo: &str, + topic: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/topics/{topic}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Transfer a repo ownership + /// + /// - `owner`: owner of the repo to transfer + /// - `repo`: name of the repo to transfer + /// - `body`: Transfer Options + pub async fn repo_transfer( + &self, + owner: &str, + repo: &str, + body: TransferRepoOption, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/transfer")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 202 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Accept a repo transfer + /// + /// - `owner`: owner of the repo to transfer + /// - `repo`: name of the repo to transfer + pub async fn accept_repo_transfer( + &self, + owner: &str, + repo: &str, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/transfer/accept")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 202 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Reject a repo transfer + /// + /// - `owner`: owner of the repo to transfer + /// - `repo`: name of the repo to transfer + pub async fn reject_repo_transfer( + &self, + owner: &str, + repo: &str, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/transfer/reject")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a wiki page + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body` + pub async fn repo_create_wiki_page( + &self, + owner: &str, + repo: &str, + body: CreateWikiPageOptions, + ) -> Result { + let request = self + .post(&format!("/repos/{owner}/{repo}/wiki/new")) + .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 wiki page + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `pageName`: name of the page + pub async fn repo_get_wiki_page( + &self, + owner: &str, + repo: &str, + page_name: &str, + ) -> Result { + let request = self + .get(&format!("/repos/{owner}/{repo}/wiki/page/{page_name}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a wiki page + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `pageName`: name of the page + pub async fn repo_delete_wiki_page( + &self, + owner: &str, + repo: &str, + page_name: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/repos/{owner}/{repo}/wiki/page/{page_name}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a wiki page + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `pageName`: name of the page + /// - `body` + pub async fn repo_edit_wiki_page( + &self, + owner: &str, + repo: &str, + page_name: &str, + body: CreateWikiPageOptions, + ) -> Result { + let request = self + .patch(&format!("/repos/{owner}/{repo}/wiki/page/{page_name}")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get all wiki pages + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_get_wiki_pages( + &self, + owner: &str, + repo: &str, + query: RepoGetWikiPagesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/wiki/pages?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get revisions of a wiki page + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `pageName`: name of the page + pub async fn repo_get_wiki_page_revisions( + &self, + owner: &str, + repo: &str, + page_name: &str, + query: RepoGetWikiPageRevisionsQuery, + ) -> Result { + let request = self + .get(&format!( + "/repos/{owner}/{repo}/wiki/revisions/{page_name}?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a repository using a template + /// + /// - `template_owner`: name of the template repository owner + /// - `template_repo`: name of the template repository + /// - `body` + pub async fn generate_repo( + &self, + template_owner: &str, + template_repo: &str, + body: GenerateRepoOption, + ) -> Result { + let request = self + .post(&format!("/repos/{template_owner}/{template_repo}/generate")) + .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 repository by id + /// + /// - `id`: id of the repo to get + pub async fn repo_get_by_id(&self, id: u64) -> Result { + let request = self.get(&format!("/repositories/{id}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get instance's global settings for api + pub async fn get_general_api_settings(&self) -> Result { + let request = self.get("/settings/api").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get instance's global settings for Attachment + pub async fn get_general_attachment_settings( + &self, + ) -> Result { + let request = self.get("/settings/attachment").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get instance's global settings for repositories + pub async fn get_general_repository_settings( + &self, + ) -> Result { + let request = self.get("/settings/repository").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get instance's global settings for ui + pub async fn get_general_ui_settings(&self) -> Result { + let request = self.get("/settings/ui").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get default signing-key.gpg + pub async fn get_signing_key(&self) -> Result { + let request = self.get("/signing-key.gpg").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.text().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a team + /// + /// - `id`: id of the team to get + pub async fn org_get_team(&self, id: u64) -> Result { + let request = self.get(&format!("/teams/{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 team + /// + /// - `id`: id of the team to delete + pub async fn org_delete_team(&self, id: u64) -> Result<(), ForgejoError> { + let request = self.delete(&format!("/teams/{id}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Edit a team + /// + /// - `id`: id of the team to edit + /// - `body` + pub async fn org_edit_team(&self, id: u32, body: EditTeamOption) -> Result { + let request = self.patch(&format!("/teams/{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 team's activity feeds + /// + /// - `id`: id of the team + pub async fn org_list_team_activity_feeds( + &self, + id: u64, + query: OrgListTeamActivityFeedsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/teams/{id}/activities/feeds?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a team's members + /// + /// - `id`: id of the team + pub async fn org_list_team_members( + &self, + id: u64, + query: OrgListTeamMembersQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/teams/{id}/members?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a particular member of team + /// + /// - `id`: id of the team + /// - `username`: username of the member to list + pub async fn org_list_team_member( + &self, + id: u64, + username: &str, + ) -> Result { + let request = self + .get(&format!("/teams/{id}/members/{username}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a team member + /// + /// - `id`: id of the team + /// - `username`: username of the user to add + pub async fn org_add_team_member(&self, id: u64, username: &str) -> Result<(), ForgejoError> { + let request = self + .put(&format!("/teams/{id}/members/{username}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove a team member + /// + /// - `id`: id of the team + /// - `username`: username of the user to remove + pub async fn org_remove_team_member( + &self, + id: u64, + username: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/teams/{id}/members/{username}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a team's repos + /// + /// - `id`: id of the team + pub async fn org_list_team_repos( + &self, + id: u64, + query: OrgListTeamReposQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/teams/{id}/repos?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a particular repo of team + /// + /// - `id`: id of the team + /// - `org`: organization that owns the repo to list + /// - `repo`: name of the repo to list + pub async fn org_list_team_repo( + &self, + id: u64, + org: &str, + repo: &str, + ) -> Result { + let request = self + .get(&format!("/teams/{id}/repos/{org}/{repo}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a repository to a team + /// + /// - `id`: id of the team + /// - `org`: organization that owns the repo to add + /// - `repo`: name of the repo to add + pub async fn org_add_team_repository( + &self, + id: u64, + org: &str, + repo: &str, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("/teams/{id}/repos/{org}/{repo}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove a repository from a team + /// + /// - `id`: id of the team + /// - `org`: organization that owns the repo to remove + /// - `repo`: name of the repo to remove + pub async fn org_remove_team_repository( + &self, + id: u64, + org: &str, + repo: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/teams/{id}/repos/{org}/{repo}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// search topics via keyword + /// + pub async fn topic_search( + &self, + query: TopicSearchQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/topics/search?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get the authenticated user + pub async fn user_get_current(&self) -> Result { + let request = self.get("/user").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 user scope + /// + /// - `secretname`: name of the secret + /// - `body` + pub async fn update_user_secret( + &self, + secretname: &str, + body: CreateOrUpdateSecretOption, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("/user/actions/secrets/{secretname}")) + .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 secret in a user scope + /// + /// - `secretname`: name of the secret + pub async fn delete_user_secret(&self, secretname: &str) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/user/actions/secrets/{secretname}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the authenticated user's oauth2 applications + /// + pub async fn user_get_oauth2_applications( + &self, + query: UserGetOAuth2ApplicationsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/applications/oauth2?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// creates a new OAuth2 application + /// + /// - `body` + pub async fn user_create_oauth2_application( + &self, + body: CreateOAuth2ApplicationOptions, + ) -> Result { + let request = self.post("/user/applications/oauth2").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 an OAuth2 Application + /// + /// - `id`: Application ID to be found + pub async fn user_get_oauth2_application( + &self, + id: u64, + ) -> Result { + let request = self + .get(&format!("/user/applications/oauth2/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// delete an OAuth2 Application + /// + /// - `id`: token to be deleted + pub async fn user_delete_oauth2_application(&self, id: u64) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/user/applications/oauth2/{id}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// update an OAuth2 Application, this includes regenerating the client secret + /// + /// - `id`: application to be updated + /// - `body` + pub async fn user_update_oauth2_application( + &self, + id: u64, + body: CreateOAuth2ApplicationOptions, + ) -> Result { + let request = self + .patch(&format!("/user/applications/oauth2/{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())), + } + } + + /// Update Avatar + /// + /// - `body` + pub async fn user_update_avatar( + &self, + body: UpdateUserAvatarOption, + ) -> Result<(), ForgejoError> { + let request = self.post("/user/avatar").json(&body).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete Avatar + pub async fn user_delete_avatar(&self) -> Result<(), ForgejoError> { + let request = self.delete("/user/avatar").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Blocks a user from the doer. + /// + /// - `username`: username of the user + pub async fn user_block_user(&self, username: &str) -> Result<(), ForgejoError> { + let request = self.put(&format!("/user/block/{username}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the authenticated user's email addresses + pub async fn user_list_emails(&self) -> Result, ForgejoError> { + let request = self.get("/user/emails").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add email addresses + /// + /// - `body` + pub async fn user_add_email( + &self, + body: CreateEmailOption, + ) -> Result, ForgejoError> { + let request = self.post("/user/emails").json(&body).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete email addresses + /// + /// - `body` + pub async fn user_delete_email(&self, body: DeleteEmailOption) -> Result<(), ForgejoError> { + let request = self.delete("/user/emails").json(&body).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the authenticated user's followers + /// + pub async fn user_current_list_followers( + &self, + query: UserCurrentListFollowersQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/followers?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the users that the authenticated user is following + /// + pub async fn user_current_list_following( + &self, + query: UserCurrentListFollowingQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/following?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check whether a user is followed by the authenticated user + /// + /// - `username`: username of followed user + pub async fn user_current_check_following(&self, username: &str) -> Result<(), ForgejoError> { + let request = self.get(&format!("/user/following/{username}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Follow a user + /// + /// - `username`: username of user to follow + pub async fn user_current_put_follow(&self, username: &str) -> Result<(), ForgejoError> { + let request = self.put(&format!("/user/following/{username}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Unfollow a user + /// + /// - `username`: username of user to unfollow + pub async fn user_current_delete_follow(&self, username: &str) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/user/following/{username}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a Token to verify + pub async fn get_verification_token(&self) -> Result { + let request = self.get("/user/gpg_key_token").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.text().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Verify a GPG key + pub async fn user_verify_gpg_key(&self) -> Result { + let request = self.post("/user/gpg_key_verify").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the authenticated user's GPG keys + /// + pub async fn user_current_list_gpg_keys( + &self, + query: UserCurrentListGpgKeysQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/gpg_keys?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a GPG key + /// + /// - `Form` + pub async fn user_current_post_gpg_key( + &self, + form: CreateGPGKeyOption, + ) -> Result { + let request = self.post("/user/gpg_keys").json(&form).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a GPG key + /// + /// - `id`: id of key to get + pub async fn user_current_get_gpg_key(&self, id: u64) -> Result { + let request = self.get(&format!("/user/gpg_keys/{id}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove a GPG key + /// + /// - `id`: id of key to delete + pub async fn user_current_delete_gpg_key(&self, id: u64) -> Result<(), ForgejoError> { + let request = self.delete(&format!("/user/gpg_keys/{id}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the authenticated user's webhooks + /// + pub async fn user_list_hooks( + &self, + query: UserListHooksQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/hooks?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a hook + /// + /// - `body` + pub async fn user_create_hook(&self, body: CreateHookOption) -> Result { + let request = self.post("/user/hooks").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 hook + /// + /// - `id`: id of the hook to get + pub async fn user_get_hook(&self, id: u64) -> Result { + let request = self.get(&format!("/user/hooks/{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 hook + /// + /// - `id`: id of the hook to delete + pub async fn user_delete_hook(&self, id: u64) -> Result<(), ForgejoError> { + let request = self.delete(&format!("/user/hooks/{id}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update a hook + /// + /// - `id`: id of the hook to update + /// - `body` + pub async fn user_edit_hook( + &self, + id: u64, + body: EditHookOption, + ) -> Result { + let request = self + .patch(&format!("/user/hooks/{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 the authenticated user's public keys + /// + pub async fn user_current_list_keys( + &self, + query: UserCurrentListKeysQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/keys?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a public key + /// + /// - `body` + pub async fn user_current_post_key( + &self, + body: CreateKeyOption, + ) -> Result { + let request = self.post("/user/keys").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 public key + /// + /// - `id`: id of key to get + pub async fn user_current_get_key(&self, id: u64) -> Result { + let request = self.get(&format!("/user/keys/{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 public key + /// + /// - `id`: id of key to delete + pub async fn user_current_delete_key(&self, id: u64) -> Result<(), ForgejoError> { + let request = self.delete(&format!("/user/keys/{id}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the authenticated user's blocked users + /// + pub async fn user_list_blocked_users( + &self, + query: UserListBlockedUsersQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/list_blocked?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the current user's organizations + /// + pub async fn org_list_current_user_orgs( + &self, + query: OrgListCurrentUserOrgsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/orgs?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the repos that the authenticated user owns + /// + pub async fn user_current_list_repos( + &self, + query: UserCurrentListReposQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/repos?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create a repository + /// + /// - `body` + pub async fn create_current_user_repo( + &self, + body: CreateRepoOption, + ) -> Result { + let request = self.post("/user/repos").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 user settings + pub async fn get_user_settings(&self) -> Result, ForgejoError> { + let request = self.get("/user/settings").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Update user settings + /// + /// - `body` + pub async fn update_user_settings( + &self, + body: UserSettingsOptions, + ) -> Result, ForgejoError> { + let request = self.patch("/user/settings").json(&body).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// The repos that the authenticated user has starred + /// + pub async fn user_current_list_starred( + &self, + query: UserCurrentListStarredQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/starred?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Whether the authenticated is starring the repo + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn user_current_check_starring( + &self, + owner: &str, + repo: &str, + ) -> Result<(), ForgejoError> { + let request = self.get(&format!("/user/starred/{owner}/{repo}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Star the given repo + /// + /// - `owner`: owner of the repo to star + /// - `repo`: name of the repo to star + pub async fn user_current_put_star(&self, owner: &str, repo: &str) -> Result<(), ForgejoError> { + let request = self.put(&format!("/user/starred/{owner}/{repo}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Unstar the given repo + /// + /// - `owner`: owner of the repo to unstar + /// - `repo`: name of the repo to unstar + pub async fn user_current_delete_star( + &self, + owner: &str, + repo: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/user/starred/{owner}/{repo}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get list of all existing stopwatches + /// + pub async fn user_get_stop_watches( + &self, + query: UserGetStopWatchesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/stopwatches?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List repositories watched by the authenticated user + /// + pub async fn user_current_list_subscriptions( + &self, + query: UserCurrentListSubscriptionsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/subscriptions?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List all the teams a user belongs to + /// + pub async fn user_list_teams( + &self, + query: UserListTeamsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/teams?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the current user's tracked times + /// + pub async fn user_current_tracked_times( + &self, + query: UserCurrentTrackedTimesQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/user/times?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Unblocks a user from the doer. + /// + /// - `username`: username of the user + pub async fn user_unblock_user(&self, username: &str) -> Result<(), ForgejoError> { + let request = self.put(&format!("/user/unblock/{username}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Search for users + /// + pub async fn user_search( + &self, + query: UserSearchQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/users/search?{}", query.to_string())) + .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 + /// + /// - `username`: username of user to get + pub async fn user_get(&self, username: &str) -> Result { + let request = self.get(&format!("/users/{username}")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a user's activity feeds + /// + /// - `username`: username of user + pub async fn user_list_activity_feeds( + &self, + username: &str, + query: UserListActivityFeedsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/users/{username}/activities/feeds?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the given user's followers + /// + /// - `username`: username of user + pub async fn user_list_followers( + &self, + username: &str, + query: UserListFollowersQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/users/{username}/followers?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the users that the given user is following + /// + /// - `username`: username of user + pub async fn user_list_following( + &self, + username: &str, + query: UserListFollowingQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/users/{username}/following?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check if one user is following another user + /// + /// - `username`: username of following user + /// - `target`: username of followed user + pub async fn user_check_following( + &self, + username: &str, + target: &str, + ) -> Result<(), ForgejoError> { + let request = self + .get(&format!("/users/{username}/following/{target}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the given user's GPG keys + /// + /// - `username`: username of user + pub async fn user_list_gpg_keys( + &self, + username: &str, + query: UserListGpgKeysQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/users/{username}/gpg_keys?{}", query.to_string())) + .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's heatmap + /// + /// - `username`: username of user to get + pub async fn user_get_heatmap_data( + &self, + username: &str, + ) -> Result, ForgejoError> { + let request = self.get(&format!("/users/{username}/heatmap")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the given user's public keys + /// + /// - `username`: username of user + pub async fn user_list_keys( + &self, + username: &str, + query: UserListKeysQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/users/{username}/keys?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List a user's organizations + /// + /// - `username`: username of user + pub async fn org_list_user_orgs( + &self, + username: &str, + query: OrgListUserOrgsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/users/{username}/orgs?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get user permissions in organization + /// + /// - `username`: username of user + /// - `org`: name of the organization + pub async fn org_get_user_permissions( + &self, + username: &str, + org: &str, + ) -> Result { + let request = self + .get(&format!("/users/{username}/orgs/{org}/permissions")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the repos owned by the given user + /// + /// - `username`: username of user + pub async fn user_list_repos( + &self, + username: &str, + query: UserListReposQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/users/{username}/repos?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// The repos that the given user has starred + /// + /// - `username`: username of user + pub async fn user_list_starred( + &self, + username: &str, + query: UserListStarredQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/users/{username}/starred?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the repositories watched by a user + /// + /// - `username`: username of the user + pub async fn user_list_subscriptions( + &self, + username: &str, + query: UserListSubscriptionsQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!( + "/users/{username}/subscriptions?{}", + query.to_string() + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// List the authenticated user's access tokens + /// + /// - `username`: username of user + pub async fn user_get_tokens( + &self, + username: &str, + query: UserGetTokensQuery, + ) -> Result, ForgejoError> { + let request = self + .get(&format!("/users/{username}/tokens?{}", query.to_string())) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Create an access token + /// + /// - `username`: username of user + /// - `body` + pub async fn user_create_token( + &self, + username: &str, + body: CreateAccessTokenOption, + ) -> Result { + let request = self + .post(&format!("/users/{username}/tokens")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 201 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// delete an access token + /// + /// - `username`: username of user + /// - `token`: token to be deleted, identified by ID and if not available by name + pub async fn user_delete_access_token( + &self, + username: &str, + token: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("/users/{username}/tokens/{token}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Returns the version of the Gitea application + pub async fn get_version(&self) -> Result { + let request = self.get("/version").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } +} +use structs::*; +pub mod structs { + use std::fmt::Write; + /// APIError is an api error with a message + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct APIError { + pub message: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct AccessToken { + pub id: Option, + pub name: Option, + pub scopes: Option>, + pub sha1: Option, + pub token_last_eight: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Activity { + pub act_user: Option, + pub act_user_id: Option, + pub comment: Option, + pub comment_id: Option, + pub content: Option, + pub created: Option, + pub id: Option, + pub is_private: Option, + pub op_type: Option, + pub ref_name: Option, + pub repo: Option, + pub repo_id: Option, + pub user_id: Option, + } + + /// ActivityPub type + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct ActivityPub { + #[serde(rename = "@context")] + pub context: Option, + } + + /// AddCollaboratorOption options when adding a user as a collaborator of a repository + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct AddCollaboratorOption { + pub permission: Option, + } + + /// AddTimeOption options for adding time to an issue + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct AddTimeOption { + pub created: Option, + pub time: u64, + pub user_name: Option, + } + + /// AnnotatedTag represents an annotated tag + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct AnnotatedTag { + pub message: Option, + pub object: Option, + pub sha: Option, + pub tag: Option, + pub tagger: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + pub verification: Option, + } + + /// AnnotatedTagObject contains meta information of the tag object + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct AnnotatedTagObject { + pub sha: Option, + #[serde(rename = "type")] + pub r#type: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// Attachment a generic attachment + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Attachment { + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub browser_download_url: Option, + pub created_at: Option, + pub download_count: Option, + pub id: Option, + pub name: Option, + pub size: Option, + pub uuid: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct BlockedUser { + pub block_id: Option, + pub created_at: Option, + } + + /// Branch represents a repository branch + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Branch { + pub commit: Option, + pub effective_branch_protection_name: Option, + pub enable_status_check: Option, + pub name: Option, + pub protected: Option, + pub required_approvals: Option, + pub status_check_contexts: Option>, + pub user_can_merge: Option, + pub user_can_push: Option, + } + + /// BranchProtection represents a branch protection for a repository + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct BranchProtection { + pub approvals_whitelist_teams: Option>, + pub approvals_whitelist_username: Option>, + pub block_on_official_review_requests: Option, + pub block_on_outdated_branch: Option, + pub block_on_rejected_reviews: Option, + pub branch_name: Option, + pub created_at: Option, + pub dismiss_stale_approvals: Option, + pub enable_approvals_whitelist: Option, + pub enable_merge_whitelist: Option, + pub enable_push: Option, + pub enable_push_whitelist: Option, + pub enable_status_check: Option, + pub merge_whitelist_teams: Option>, + pub merge_whitelist_usernames: Option>, + pub protected_file_patterns: Option, + pub push_whitelist_deploy_keys: Option, + pub push_whitelist_teams: Option>, + pub push_whitelist_usernames: Option>, + pub require_signed_commits: Option, + pub required_approvals: Option, + pub rule_name: Option, + pub status_check_contexts: Option>, + pub unprotected_file_patterns: Option, + pub updated_at: Option, + } + + /// ChangeFileOperation for creating, updating or deleting a file + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct ChangeFileOperation { + pub content: Option, + pub from_path: Option, + pub operation: String, + pub path: String, + pub sha: Option, + } + + /// ChangeFilesOptions options for creating, updating or deleting multiple files + /// + /// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct ChangeFilesOptions { + pub author: Option, + pub branch: Option, + pub committer: Option, + pub dates: Option, + pub files: Vec, + pub message: Option, + pub new_branch: Option, + pub signoff: Option, + } + + /// ChangedFile store information about files affected by the pull request + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct ChangedFile { + pub additions: Option, + pub changes: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub contents_url: Option, + pub deletions: Option, + pub filename: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub previous_filename: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub raw_url: Option, + pub status: Option, + } + + /// CombinedStatus holds the combined state of several statuses for a single commit + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CombinedStatus { + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub commit_url: Option, + pub repository: Option, + pub sha: Option, + pub state: Option, + pub statuses: Option>, + pub total_count: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// Comment represents a comment on a commit or issue + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Comment { + pub assets: Option>, + pub body: Option, + pub created_at: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub id: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub issue_url: Option, + pub original_author: Option, + pub original_author_id: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub pull_request_url: Option, + pub updated_at: Option, + pub user: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Commit { + pub author: Option, + pub commit: Option, + pub committer: Option, + pub created: Option, + pub files: Option>, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub parents: Option>, + pub sha: Option, + pub stats: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// CommitAffectedFiles store information about files affected by the commit + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CommitAffectedFiles { + pub filename: Option, + pub status: Option, + } + + /// CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CommitDateOptions { + pub author: Option, + pub committer: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CommitMeta { + pub created: Option, + pub sha: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// CommitStats is statistics for a RepoCommit + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CommitStats { + pub additions: Option, + pub deletions: Option, + pub total: Option, + } + + /// CommitStatus holds a single status of a single Commit + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CommitStatus { + pub context: Option, + pub created_at: Option, + pub creator: Option, + pub description: Option, + pub id: Option, + pub status: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub target_url: Option, + pub updated_at: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// CommitStatusState holds the state of a CommitStatus + /// + /// It can be "pending", "success", "error" and "failure" + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CommitStatusState {} + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CommitUser { + pub date: Option, + pub email: Option, + pub name: Option, + } + + /// ContentsResponse contains information about a repo's entry's (dir, file, symlink, submodule) metadata and content + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct ContentsResponse { + #[serde(rename = "_links")] + pub links: Option, + pub content: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub download_url: Option, + pub encoding: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub git_url: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub last_commit_sha: Option, + pub name: Option, + pub path: Option, + pub sha: Option, + pub size: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub submodule_git_url: Option, + pub target: Option, + #[serde(rename = "type")] + pub r#type: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// CreateAccessTokenOption options when create access token + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateAccessTokenOption { + pub name: String, + pub scopes: Option>, + } + + /// CreateBranchProtectionOption options for creating a branch protection + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateBranchProtectionOption { + pub approvals_whitelist_teams: Option>, + pub approvals_whitelist_username: Option>, + pub block_on_official_review_requests: Option, + pub block_on_outdated_branch: Option, + pub block_on_rejected_reviews: Option, + pub branch_name: Option, + pub dismiss_stale_approvals: Option, + pub enable_approvals_whitelist: Option, + pub enable_merge_whitelist: Option, + pub enable_push: Option, + pub enable_push_whitelist: Option, + pub enable_status_check: Option, + pub merge_whitelist_teams: Option>, + pub merge_whitelist_usernames: Option>, + pub protected_file_patterns: Option, + pub push_whitelist_deploy_keys: Option, + pub push_whitelist_teams: Option>, + pub push_whitelist_usernames: Option>, + pub require_signed_commits: Option, + pub required_approvals: Option, + pub rule_name: Option, + pub status_check_contexts: Option>, + pub unprotected_file_patterns: Option, + } + + /// CreateBranchRepoOption options when creating a branch in a repository + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateBranchRepoOption { + pub new_branch_name: String, + pub old_branch_name: Option, + pub old_ref_name: Option, + } + + /// CreateEmailOption options when creating email addresses + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateEmailOption { + pub emails: Option>, + } + + /// CreateFileOptions options for creating files + /// + /// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateFileOptions { + pub author: Option, + pub branch: Option, + pub committer: Option, + pub content: String, + pub dates: Option, + pub message: Option, + pub new_branch: Option, + pub signoff: Option, + } + + /// CreateForkOption options for creating a fork + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateForkOption { + pub name: Option, + pub organization: Option, + } + + /// CreateGPGKeyOption options create user GPG key + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateGPGKeyOption { + pub armored_public_key: String, + pub armored_signature: Option, + } + + /// CreateHookOption options when create a hook + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateHookOption { + pub active: Option, + pub authorization_header: Option, + pub branch_filter: Option, + pub config: CreateHookOptionConfig, + pub events: Option>, + #[serde(rename = "type")] + pub r#type: String, + } + + /// CreateHookOptionConfig has all config options in it + /// + /// required are "content_type" and "url" Required + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateHookOptionConfig {} + + /// CreateIssueCommentOption options for creating a comment on an issue + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateIssueCommentOption { + pub body: String, + pub updated_at: Option, + } + + /// CreateIssueOption options to create one issue + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateIssueOption { + pub assignee: Option, + pub assignees: Option>, + pub body: Option, + pub closed: Option, + pub due_date: Option, + pub labels: Option>, + pub milestone: Option, + #[serde(rename = "ref")] + pub r#ref: Option, + pub title: String, + } + + /// CreateKeyOption options when creating a key + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateKeyOption { + pub key: String, + pub read_only: Option, + pub title: String, + } + + /// CreateLabelOption options for creating a label + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateLabelOption { + pub color: String, + pub description: Option, + pub exclusive: Option, + pub is_archived: Option, + pub name: String, + } + + /// CreateMilestoneOption options for creating a milestone + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateMilestoneOption { + pub description: Option, + pub due_on: Option, + pub state: Option, + pub title: Option, + } + + /// CreateOAuth2ApplicationOptions holds options to create an oauth2 application + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateOAuth2ApplicationOptions { + pub confidential_client: Option, + pub name: Option, + pub redirect_uris: Option>, + } + + /// CreateOrUpdateSecretOption options when creating or updating secret + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateOrUpdateSecretOption { + pub data: String, + } + + /// CreateOrgOption options for creating an organization + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateOrgOption { + pub description: Option, + pub email: Option, + pub full_name: Option, + pub location: Option, + pub repo_admin_change_team_access: Option, + pub username: String, + pub visibility: Option, + pub website: Option, + } + + /// CreatePullRequestOption options when creating a pull request + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreatePullRequestOption { + pub assignee: Option, + pub assignees: Option>, + pub base: Option, + pub body: Option, + pub due_date: Option, + pub head: Option, + pub labels: Option>, + pub milestone: Option, + pub title: Option, + } + + /// CreatePullReviewComment represent a review comment for creation api + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreatePullReviewComment { + pub body: Option, + pub new_position: Option, + pub old_position: Option, + pub path: Option, + } + + /// CreatePullReviewOptions are options to create a pull review + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreatePullReviewOptions { + pub body: Option, + pub comments: Option>, + pub commit_id: Option, + pub event: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreatePushMirrorOption { + pub interval: Option, + pub remote_address: Option, + pub remote_password: Option, + pub remote_username: Option, + pub sync_on_commit: Option, + } + + /// CreateReleaseOption options when creating a release + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateReleaseOption { + pub body: Option, + pub draft: Option, + pub name: Option, + pub prerelease: Option, + pub tag_name: String, + pub target_commitish: Option, + } + + /// CreateRepoOption options when creating repository + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateRepoOption { + pub auto_init: Option, + pub default_branch: Option, + pub description: Option, + pub gitignores: Option, + pub issue_labels: Option, + pub license: Option, + pub name: String, + pub private: Option, + pub readme: Option, + pub template: Option, + pub trust_model: Option, + } + + /// CreateStatusOption holds the information needed to create a new CommitStatus for a Commit + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateStatusOption { + pub context: Option, + pub description: Option, + pub state: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub target_url: Option, + } + + /// CreateTagOption options when creating a tag + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateTagOption { + pub message: Option, + pub tag_name: String, + pub target: Option, + } + + /// CreateTeamOption options for creating a team + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateTeamOption { + pub can_create_org_repo: Option, + pub description: Option, + pub includes_all_repositories: Option, + pub name: String, + pub permission: Option, + pub units: Option>, + pub units_map: Option>, + } + + /// CreateUserOption create user options + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateUserOption { + pub created_at: Option, + pub email: String, + pub full_name: Option, + pub login_name: Option, + pub must_change_password: Option, + pub password: Option, + pub restricted: Option, + pub send_notify: Option, + pub source_id: Option, + pub username: String, + pub visibility: Option, + } + + /// CreateWikiPageOptions form for creating wiki + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct CreateWikiPageOptions { + pub content_base64: Option, + pub message: Option, + pub title: Option, + } + + /// Cron represents a Cron task + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Cron { + pub exec_times: Option, + pub name: Option, + pub next: Option, + pub prev: Option, + pub schedule: Option, + } + + /// DeleteEmailOption options when deleting email addresses + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct DeleteEmailOption { + pub emails: Option>, + } + + /// DeleteFileOptions options for deleting files (used for other File structs below) + /// + /// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct DeleteFileOptions { + pub author: Option, + pub branch: Option, + pub committer: Option, + pub dates: Option, + pub message: Option, + pub new_branch: Option, + pub sha: String, + pub signoff: Option, + } + + /// DeleteLabelOption options for deleting a label + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct DeleteLabelsOption { + pub updated_at: Option, + } + + /// DeployKey a deploy key + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct DeployKey { + pub created_at: Option, + pub fingerprint: Option, + pub id: Option, + pub key: Option, + pub key_id: Option, + pub read_only: Option, + pub repository: Option, + pub title: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// DismissPullReviewOptions are options to dismiss a pull review + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct DismissPullReviewOptions { + pub message: Option, + pub priors: Option, + } + + /// EditAttachmentOptions options for editing attachments + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditAttachmentOptions { + pub name: Option, + } + + /// EditBranchProtectionOption options for editing a branch protection + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditBranchProtectionOption { + pub approvals_whitelist_teams: Option>, + pub approvals_whitelist_username: Option>, + pub block_on_official_review_requests: Option, + pub block_on_outdated_branch: Option, + pub block_on_rejected_reviews: Option, + pub dismiss_stale_approvals: Option, + pub enable_approvals_whitelist: Option, + pub enable_merge_whitelist: Option, + pub enable_push: Option, + pub enable_push_whitelist: Option, + pub enable_status_check: Option, + pub merge_whitelist_teams: Option>, + pub merge_whitelist_usernames: Option>, + pub protected_file_patterns: Option, + pub push_whitelist_deploy_keys: Option, + pub push_whitelist_teams: Option>, + pub push_whitelist_usernames: Option>, + pub require_signed_commits: Option, + pub required_approvals: Option, + pub status_check_contexts: Option>, + pub unprotected_file_patterns: Option, + } + + /// EditDeadlineOption options for creating a deadline + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditDeadlineOption { + pub due_date: time::OffsetDateTime, + } + + /// EditGitHookOption options when modifying one Git hook + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditGitHookOption { + pub content: Option, + } + + /// EditHookOption options when modify one hook + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditHookOption { + pub active: Option, + pub authorization_header: Option, + pub branch_filter: Option, + pub config: Option>, + pub events: Option>, + } + + /// EditIssueCommentOption options for editing a comment + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditIssueCommentOption { + pub body: String, + pub updated_at: Option, + } + + /// EditIssueOption options for editing an issue + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditIssueOption { + pub assignee: Option, + pub assignees: Option>, + pub body: Option, + pub due_date: Option, + pub milestone: Option, + #[serde(rename = "ref")] + pub r#ref: Option, + pub state: Option, + pub title: Option, + pub unset_due_date: Option, + pub updated_at: Option, + } + + /// EditLabelOption options for editing a label + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditLabelOption { + pub color: Option, + pub description: Option, + pub exclusive: Option, + pub is_archived: Option, + pub name: Option, + } + + /// EditMilestoneOption options for editing a milestone + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditMilestoneOption { + pub description: Option, + pub due_on: Option, + pub state: Option, + pub title: Option, + } + + /// EditOrgOption options for editing an organization + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditOrgOption { + pub description: Option, + pub email: Option, + pub full_name: Option, + pub location: Option, + pub repo_admin_change_team_access: Option, + pub visibility: Option, + pub website: Option, + } + + /// EditPullRequestOption options when modify pull request + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditPullRequestOption { + pub allow_maintainer_edit: Option, + pub assignee: Option, + pub assignees: Option>, + pub base: Option, + pub body: Option, + pub due_date: Option, + pub labels: Option>, + pub milestone: Option, + pub state: Option, + pub title: Option, + pub unset_due_date: Option, + } + + /// EditReactionOption contain the reaction type + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditReactionOption { + pub content: Option, + } + + /// EditReleaseOption options when editing a release + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditReleaseOption { + pub body: Option, + pub draft: Option, + pub name: Option, + pub prerelease: Option, + pub tag_name: Option, + pub target_commitish: Option, + } + + /// EditRepoOption options when editing a repository's properties + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditRepoOption { + pub allow_manual_merge: Option, + pub allow_merge_commits: Option, + pub allow_rebase: Option, + pub allow_rebase_explicit: Option, + pub allow_rebase_update: Option, + pub allow_squash_merge: Option, + pub archived: Option, + pub autodetect_manual_merge: Option, + pub default_allow_maintainer_edit: Option, + pub default_branch: Option, + pub default_delete_branch_after_merge: Option, + pub default_merge_style: Option, + pub description: Option, + pub enable_prune: Option, + pub external_tracker: Option, + pub external_wiki: Option, + pub has_actions: Option, + pub has_issues: Option, + pub has_packages: Option, + pub has_projects: Option, + pub has_pull_requests: Option, + pub has_releases: Option, + pub has_wiki: Option, + pub ignore_whitespace_conflicts: Option, + pub internal_tracker: Option, + pub mirror_interval: Option, + pub name: Option, + pub private: Option, + pub template: Option, + pub website: Option, + } + + /// EditTeamOption options for editing a team + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditTeamOption { + pub can_create_org_repo: Option, + pub description: Option, + pub includes_all_repositories: Option, + pub name: String, + pub permission: Option, + pub units: Option>, + pub units_map: Option>, + } + + /// EditUserOption edit user options + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct EditUserOption { + pub active: Option, + pub admin: Option, + pub allow_create_organization: Option, + pub allow_git_hook: Option, + pub allow_import_local: Option, + pub description: Option, + pub email: Option, + pub full_name: Option, + pub location: Option, + pub login_name: String, + pub max_repo_creation: Option, + pub must_change_password: Option, + pub password: Option, + pub prohibit_login: Option, + pub restricted: Option, + pub source_id: u64, + pub visibility: Option, + pub website: Option, + } + + /// Email an email address belonging to a user + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Email { + pub email: Option, + pub primary: Option, + pub user_id: Option, + pub username: Option, + pub verified: Option, + } + + /// ExternalTracker represents settings for external tracker + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct ExternalTracker { + pub external_tracker_format: Option, + pub external_tracker_regexp_pattern: Option, + pub external_tracker_style: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub external_tracker_url: Option, + } + + /// ExternalWiki represents setting for external wiki + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct ExternalWiki { + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub external_wiki_url: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct FileCommitResponse { + pub author: Option, + pub committer: Option, + pub created: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub message: Option, + pub parents: Option>, + pub sha: Option, + pub tree: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// FileDeleteResponse contains information about a repo's file that was deleted + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct FileDeleteResponse { + pub commit: Option, + pub content: Option<()>, + pub verification: Option, + } + + /// FileLinksResponse contains the links for a repo's file + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct FileLinksResponse { + pub git: Option, + pub html: Option, + #[serde(rename = "self")] + pub this: Option, + } + + /// FileResponse contains information about a repo's file + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct FileResponse { + pub commit: Option, + pub content: Option, + pub verification: Option, + } + + /// FilesResponse contains information about multiple files from a repo + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct FilesResponse { + pub commit: Option, + pub files: Option>, + pub verification: Option, + } + + /// GPGKey a user GPG key to sign commit and tag in repository + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GPGKey { + pub can_certify: Option, + pub can_encrypt_comms: Option, + pub can_encrypt_storage: Option, + pub can_sign: Option, + pub created_at: Option, + pub emails: Option>, + pub expires_at: Option, + pub id: Option, + pub key_id: Option, + pub primary_key_id: Option, + pub public_key: Option, + pub subkeys: Option>, + pub verified: Option, + } + + /// GPGKeyEmail an email attached to a GPGKey + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GPGKeyEmail { + pub email: Option, + pub verified: Option, + } + + /// GeneralAPISettings contains global api settings exposed by it + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GeneralAPISettings { + pub default_git_trees_per_page: Option, + pub default_max_blob_size: Option, + pub default_paging_num: Option, + pub max_response_items: Option, + } + + /// GeneralAttachmentSettings contains global Attachment settings exposed by API + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GeneralAttachmentSettings { + pub allowed_types: Option, + pub enabled: Option, + pub max_files: Option, + pub max_size: Option, + } + + /// GeneralRepoSettings contains global repository settings exposed by API + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GeneralRepoSettings { + pub http_git_disabled: Option, + pub lfs_disabled: Option, + pub migrations_disabled: Option, + pub mirrors_disabled: Option, + pub stars_disabled: Option, + pub time_tracking_disabled: Option, + } + + /// GeneralUISettings contains global ui settings exposed by API + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GeneralUISettings { + pub allowed_reactions: Option>, + pub custom_emojis: Option>, + pub default_theme: Option, + } + + /// GenerateRepoOption options when creating repository using a template + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GenerateRepoOption { + pub avatar: Option, + pub default_branch: Option, + pub description: Option, + pub git_content: Option, + pub git_hooks: Option, + pub labels: Option, + pub name: String, + pub owner: String, + pub private: Option, + pub protected_branch: Option, + pub topics: Option, + pub webhooks: Option, + } + + /// GitBlobResponse represents a git blob + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GitBlobResponse { + pub content: Option, + pub encoding: Option, + pub sha: Option, + pub size: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// GitEntry represents a git tree + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GitEntry { + pub mode: Option, + pub path: Option, + pub sha: Option, + pub size: Option, + #[serde(rename = "type")] + pub r#type: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// GitHook represents a Git repository hook + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GitHook { + pub content: Option, + pub is_active: Option, + pub name: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GitObject { + pub sha: Option, + #[serde(rename = "type")] + pub r#type: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// GitTreeResponse returns a git tree + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GitTreeResponse { + pub page: Option, + pub sha: Option, + pub total_count: Option, + pub tree: Option>, + pub truncated: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// GitignoreTemplateInfo name and text of a gitignore template + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct GitignoreTemplateInfo { + pub name: Option, + pub source: Option, + } + + /// Hook a hook is a web hook when one repository changed + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Hook { + pub active: Option, + pub authorization_header: Option, + pub branch_filter: Option, + pub config: Option>, + pub created_at: Option, + pub events: Option>, + pub id: Option, + #[serde(rename = "type")] + pub r#type: Option, + pub updated_at: Option, + } + + /// Identity for a person's identity like an author or committer + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Identity { + pub email: Option, + pub name: Option, + } + + /// InternalTracker represents settings for internal tracker + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct InternalTracker { + pub allow_only_contributors_to_track_time: Option, + pub enable_issue_dependencies: Option, + pub enable_time_tracker: Option, + } + + /// Issue represents an issue in a repository + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Issue { + pub assets: Option>, + pub assignee: Option, + pub assignees: Option>, + pub body: Option, + pub closed_at: Option, + pub comments: Option, + pub created_at: Option, + pub due_date: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub id: Option, + pub is_locked: Option, + pub labels: Option>, + pub milestone: Option, + pub number: Option, + pub original_author: Option, + pub original_author_id: Option, + pub pin_order: Option, + pub pull_request: Option, + #[serde(rename = "ref")] + pub r#ref: Option, + pub repository: Option, + pub state: Option, + pub title: Option, + pub updated_at: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + pub user: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct IssueConfig { + pub blank_issues_enabled: Option, + pub contact_links: Option>, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct IssueConfigContactLink { + pub about: Option, + pub name: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct IssueConfigValidation { + pub message: Option, + pub valid: Option, + } + + /// IssueDeadline represents an issue deadline + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct IssueDeadline { + pub due_date: Option, + } + + /// IssueFormField represents a form field + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct IssueFormField { + pub attributes: Option>, + pub id: Option, + #[serde(rename = "type")] + pub r#type: Option, + pub validations: Option>, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct IssueFormFieldType {} + + /// IssueLabelsOption a collection of labels + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct IssueLabelsOption { + pub labels: Option>, + pub updated_at: Option, + } + + /// IssueMeta basic issue information + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct IssueMeta { + pub index: Option, + pub owner: Option, + pub repo: Option, + } + + /// IssueTemplate represents an issue template for a repository + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct IssueTemplate { + pub about: Option, + pub body: Option>, + pub content: Option, + pub file_name: Option, + pub labels: Option>, + pub name: Option, + #[serde(rename = "ref")] + pub r#ref: Option, + pub title: Option, + } + + /// Label a label to an issue or a pr + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Label { + pub color: Option, + pub description: Option, + pub exclusive: Option, + pub id: Option, + pub is_archived: Option, + pub name: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// LabelTemplate info of a Label template + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct LabelTemplate { + pub color: Option, + pub description: Option, + pub exclusive: Option, + pub name: Option, + } + + /// LicensesInfo contains information about a License + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct LicenseTemplateInfo { + pub body: Option, + pub implementation: Option, + pub key: Option, + pub name: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// LicensesListEntry is used for the API + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct LicensesTemplateListEntry { + pub key: Option, + pub name: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// MarkdownOption markdown options + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct MarkdownOption { + #[serde(rename = "Context")] + pub context: Option, + #[serde(rename = "Mode")] + pub mode: Option, + #[serde(rename = "Text")] + pub text: Option, + #[serde(rename = "Wiki")] + pub wiki: Option, + } + + /// MarkupOption markup options + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct MarkupOption { + #[serde(rename = "Context")] + pub context: Option, + #[serde(rename = "FilePath")] + pub file_path: Option, + #[serde(rename = "Mode")] + pub mode: Option, + #[serde(rename = "Text")] + pub text: Option, + #[serde(rename = "Wiki")] + pub wiki: Option, + } + + /// MergePullRequestForm form for merging Pull Request + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct MergePullRequestOption { + #[serde(rename = "Do")] + pub r#do: String, + #[serde(rename = "MergeCommitID")] + pub merge_commit_id: Option, + #[serde(rename = "MergeMessageField")] + pub merge_message_field: Option, + #[serde(rename = "MergeTitleField")] + pub merge_title_field: Option, + pub delete_branch_after_merge: Option, + pub force_merge: Option, + pub head_commit_id: Option, + pub merge_when_checks_succeed: Option, + } + + /// MigrateRepoOptions options for migrating repository's + /// + /// this is used to interact with api v1 + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct MigrateRepoOptions { + pub auth_password: Option, + pub auth_token: Option, + pub auth_username: Option, + pub clone_addr: String, + pub description: Option, + pub issues: Option, + pub labels: Option, + pub lfs: Option, + pub lfs_endpoint: Option, + pub milestones: Option, + pub mirror: Option, + pub mirror_interval: Option, + pub private: Option, + pub pull_requests: Option, + pub releases: Option, + pub repo_name: String, + pub repo_owner: Option, + pub service: Option, + pub uid: Option, + pub wiki: Option, + } + + /// Milestone milestone is a collection of issues on one repository + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Milestone { + pub closed_at: Option, + pub closed_issues: Option, + pub created_at: Option, + pub description: Option, + pub due_on: Option, + pub id: Option, + pub open_issues: Option, + pub state: Option, + pub title: Option, + pub updated_at: Option, + } + + /// NewIssuePinsAllowed represents an API response that says if new Issue Pins are allowed + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct NewIssuePinsAllowed { + pub issues: Option, + pub pull_requests: Option, + } + + /// NodeInfo contains standardized way of exposing metadata about a server running one of the distributed social networks + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct NodeInfo { + pub metadata: Option>, + #[serde(rename = "openRegistrations")] + pub open_registrations: Option, + pub protocols: Option>, + pub services: Option, + pub software: Option, + pub usage: Option, + pub version: Option, + } + + /// NodeInfoServices contains the third party sites this server can connect to via their application API + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct NodeInfoServices { + pub inbound: Option>, + pub outbound: Option>, + } + + /// NodeInfoSoftware contains Metadata about server software in use + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct NodeInfoSoftware { + pub homepage: Option, + pub name: Option, + pub repository: Option, + pub version: Option, + } + + /// NodeInfoUsage contains usage statistics for this server + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct NodeInfoUsage { + #[serde(rename = "localComments")] + pub local_comments: Option, + #[serde(rename = "localPosts")] + pub local_posts: Option, + pub users: Option, + } + + /// NodeInfoUsageUsers contains statistics about the users of this server + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct NodeInfoUsageUsers { + #[serde(rename = "activeHalfyear")] + pub active_halfyear: Option, + #[serde(rename = "activeMonth")] + pub active_month: Option, + pub total: Option, + } + + /// Note contains information related to a git note + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Note { + pub commit: Option, + pub message: Option, + } + + /// NotificationCount number of unread notifications + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct NotificationCount { + pub new: Option, + } + + /// NotificationSubject contains the notification subject (Issue/Pull/Commit) + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct NotificationSubject { + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub latest_comment_html_url: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub latest_comment_url: Option, + pub state: Option, + pub title: Option, + #[serde(rename = "type")] + pub r#type: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// NotificationThread expose Notification on API + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct NotificationThread { + pub id: Option, + pub pinned: Option, + pub repository: Option, + pub subject: Option, + pub unread: Option, + pub updated_at: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// NotifySubjectType represent type of notification subject + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct NotifySubjectType {} + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct OAuth2Application { + pub client_id: Option, + pub client_secret: Option, + pub confidential_client: Option, + pub created: Option, + pub id: Option, + pub name: Option, + pub redirect_uris: Option>, + } + + /// Organization represents an organization + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Organization { + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub avatar_url: Option, + pub description: Option, + pub email: Option, + pub full_name: Option, + pub id: Option, + pub location: Option, + pub name: Option, + pub repo_admin_change_team_access: Option, + pub username: Option, + pub visibility: Option, + pub website: Option, + } + + /// OrganizationPermissions list different users permissions on an organization + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct OrganizationPermissions { + pub can_create_repository: Option, + pub can_read: Option, + pub can_write: Option, + pub is_admin: Option, + pub is_owner: Option, + } + + /// PRBranchInfo information about a branch + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PRBranchInfo { + pub label: Option, + #[serde(rename = "ref")] + pub r#ref: Option, + pub repo: Option, + pub repo_id: Option, + pub sha: Option, + } + + /// Package represents a package + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Package { + pub created_at: Option, + pub creator: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub id: Option, + pub name: Option, + pub owner: Option, + pub repository: Option, + #[serde(rename = "type")] + pub r#type: Option, + pub version: Option, + } + + /// PackageFile represents a package file + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PackageFile { + #[serde(rename = "Size")] + pub size: Option, + pub id: Option, + pub md5: Option, + pub name: Option, + pub sha1: Option, + pub sha256: Option, + pub sha512: Option, + } + + /// PayloadCommit represents a commit + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PayloadCommit { + pub added: Option>, + pub author: Option, + pub committer: Option, + pub id: Option, + pub message: Option, + pub modified: Option>, + pub removed: Option>, + pub timestamp: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + pub verification: Option, + } + + /// PayloadCommitVerification represents the GPG verification of a commit + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PayloadCommitVerification { + pub payload: Option, + pub reason: Option, + pub signature: Option, + pub signer: Option, + pub verified: Option, + } + + /// PayloadUser represents the author or committer of a commit + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PayloadUser { + pub email: Option, + pub name: Option, + pub username: Option, + } + + /// Permission represents a set of permissions + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Permission { + pub admin: Option, + pub pull: Option, + pub push: Option, + } + + /// PublicKey publickey is a user key to push code to repository + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PublicKey { + pub created_at: Option, + pub fingerprint: Option, + pub id: Option, + pub key: Option, + pub key_type: Option, + pub read_only: Option, + pub title: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + pub user: Option, + } + + /// PullRequest represents a pull request + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PullRequest { + pub allow_maintainer_edit: Option, + pub assignee: Option, + pub assignees: Option>, + pub base: Option, + pub body: Option, + pub closed_at: Option, + pub comments: Option, + pub created_at: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub diff_url: Option, + pub due_date: Option, + pub head: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub id: Option, + pub is_locked: Option, + pub labels: Option>, + pub merge_base: Option, + pub merge_commit_sha: Option, + pub mergeable: Option, + pub merged: Option, + pub merged_at: Option, + pub merged_by: Option, + pub milestone: Option, + pub number: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub patch_url: Option, + pub pin_order: Option, + pub requested_reviewers: Option>, + pub state: Option, + pub title: Option, + pub updated_at: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + pub user: Option, + } + + /// PullRequestMeta PR info if an issue is a PR + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PullRequestMeta { + pub merged: Option, + pub merged_at: Option, + } + + /// PullReview represents a pull request review + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PullReview { + pub body: Option, + pub comments_count: Option, + pub commit_id: Option, + pub dismissed: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub id: Option, + pub official: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub pull_request_url: Option, + pub stale: Option, + pub state: Option, + pub submitted_at: Option, + pub team: Option, + pub updated_at: Option, + pub user: Option, + } + + /// PullReviewComment represents a comment on a pull request review + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PullReviewComment { + pub body: Option, + pub commit_id: Option, + pub created_at: Option, + pub diff_hunk: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub id: Option, + pub original_commit_id: Option, + pub original_position: Option, + pub path: Option, + pub position: Option, + pub pull_request_review_id: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub pull_request_url: Option, + pub resolver: Option, + pub updated_at: Option, + pub user: Option, + } + + /// PullReviewRequestOptions are options to add or remove pull review requests + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PullReviewRequestOptions { + pub reviewers: Option>, + pub team_reviewers: Option>, + } + + /// PushMirror represents information of a push mirror + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct PushMirror { + pub created: Option, + pub interval: Option, + pub last_error: Option, + pub last_update: Option, + pub remote_address: Option, + pub remote_name: Option, + pub repo_name: Option, + pub sync_on_commit: Option, + } + + /// Reaction contain one reaction + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Reaction { + pub content: Option, + pub created_at: Option, + pub user: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Reference { + pub object: Option, + #[serde(rename = "ref")] + pub r#ref: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + } + + /// Release represents a repository release + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Release { + pub assets: Option>, + pub author: Option, + pub body: Option, + pub created_at: Option, + pub draft: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub id: Option, + pub name: Option, + pub prerelease: Option, + pub published_at: Option, + pub tag_name: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub tarball_url: Option, + pub target_commitish: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub upload_url: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub zipball_url: Option, + } + + /// RenameUserOption options when renaming a user + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct RenameUserOption { + pub new_username: String, + } + + /// RepoCollaboratorPermission to get repository permission for a collaborator + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct RepoCollaboratorPermission { + pub permission: Option, + pub role_name: Option, + pub user: Option, + } + + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct RepoCommit { + pub author: Option, + pub committer: Option, + pub message: Option, + pub tree: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + pub verification: Option, + } + + /// RepoTopicOptions a collection of repo topic names + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct RepoTopicOptions { + pub topics: Option>, + } + + /// RepoTransfer represents a pending repo transfer + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct RepoTransfer { + pub doer: Option, + pub recipient: Option, + pub teams: Option>, + } + + /// Repository represents a repository + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Repository { + pub allow_merge_commits: Option, + pub allow_rebase: Option, + pub allow_rebase_explicit: Option, + pub allow_rebase_update: Option, + pub allow_squash_merge: Option, + pub archived: Option, + pub archived_at: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub avatar_url: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub clone_url: Option, + pub created_at: Option, + pub default_allow_maintainer_edit: Option, + pub default_branch: Option, + pub default_delete_branch_after_merge: Option, + pub default_merge_style: Option, + pub description: Option, + pub empty: Option, + pub external_tracker: Option, + pub external_wiki: Option, + pub fork: Option, + pub forks_count: Option, + pub full_name: Option, + pub has_actions: Option, + pub has_issues: Option, + pub has_packages: Option, + pub has_projects: Option, + pub has_pull_requests: Option, + pub has_releases: Option, + pub has_wiki: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub id: Option, + pub ignore_whitespace_conflicts: Option, + pub internal: Option, + pub internal_tracker: Option, + pub language: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub languages_url: Option, + pub link: Option, + pub mirror: Option, + pub mirror_interval: Option, + pub mirror_updated: Option, + pub name: Option, + pub open_issues_count: Option, + pub open_pr_counter: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub original_url: Option, + pub owner: Option, + pub parent: Option>, + pub permissions: Option, + pub private: Option, + pub release_counter: Option, + pub repo_transfer: Option, + pub size: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub ssh_url: Option, + pub stars_count: Option, + pub template: Option, + pub updated_at: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, + pub watchers_count: Option, + pub website: Option, + } + + /// RepositoryMeta basic repository information + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct RepositoryMeta { + pub full_name: Option, + pub id: Option, + pub name: Option, + pub owner: Option, + } + + /// ReviewStateType review state type + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct ReviewStateType {} + + /// SearchResults results of a successful search + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct SearchResults { + pub data: Option>, + pub ok: Option, + } + + /// Secret represents a secret + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Secret { + pub created_at: Option, + pub name: Option, + } + + /// ServerVersion wraps the version of the server + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct ServerVersion { + pub version: Option, + } + + /// StateType issue state type + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct StateType {} + + /// StopWatch represent a running stopwatch + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct StopWatch { + pub created: Option, + pub duration: Option, + pub issue_index: Option, + pub issue_title: Option, + pub repo_name: Option, + pub repo_owner_name: Option, + pub seconds: Option, + } + + /// SubmitPullReviewOptions are options to submit a pending pull review + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct SubmitPullReviewOptions { + pub body: Option, + pub event: Option, + } + + /// Tag represents a repository tag + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Tag { + pub commit: Option, + pub id: Option, + pub message: Option, + pub name: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub tarball_url: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub zipball_url: Option, + } + + /// Team represents a team in an organization + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct Team { + pub can_create_org_repo: Option, + pub description: Option, + pub id: Option, + pub includes_all_repositories: Option, + pub name: Option, + pub organization: Option, + pub permission: Option, + pub units: Option>, + pub units_map: Option>, + } + + /// TimeStamp defines a timestamp + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct TimeStamp {} + + /// TimelineComment represents a timeline comment (comment of any type) on a commit or issue + /// + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] + pub struct TimelineComment { + pub assignee: Option, + pub assignee_team: Option, + pub body: Option, + pub created_at: Option, + pub dependent_issue: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub html_url: Option, + pub id: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub issue_url: Option, + pub label: Option