Thanks to visit codestin.com
Credit goes to github.com

Skip to content

docs: api root, buildinfo, csp #5493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 137 additions & 2 deletions coderd/apidoc/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/": {
"get": {
"produces": [
"application/json"
],
"tags": [
"General"
],
"summary": "API root handler",
"operationId": "api-root-handler",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.Response"
}
}
}
}
},
"/applications/auth-redirect": {
"get": {
"security": [
Expand Down Expand Up @@ -116,6 +136,62 @@ const docTemplate = `{
}
}
},
"/buildinfo": {
"get": {
"produces": [
"application/json"
],
"tags": [
"General"
],
"summary": "Build info",
"operationId": "build-info",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.BuildInfoResponse"
}
}
}
}
},
"/csp/reports": {
"post": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"text/plain"
],
"tags": [
"General"
],
"summary": "Report CSP violations",
"operationId": "report-csp-violations",
"parameters": [
{
"description": "Violation report",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/coderd.cspViolation"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/organizations/{organization-id}/templates/": {
"post": {
"security": [
Expand Down Expand Up @@ -352,6 +428,26 @@ const docTemplate = `{
}
}
},
"/updatecheck": {
"get": {
"produces": [
"application/json"
],
"tags": [
"General"
],
"summary": "Update check",
"operationId": "update-check",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.UpdateCheckResponse"
}
}
}
}
},
"/users/{user}/workspace/{workspacename}": {
"get": {
"security": [
Expand Down Expand Up @@ -730,6 +826,15 @@ const docTemplate = `{
}
},
"definitions": {
"coderd.cspViolation": {
"type": "object",
"properties": {
"csp-report": {
"type": "object",
"additionalProperties": true
}
}
},
"codersdk.AuthorizationCheck": {
"description": "AuthorizationCheck is used to check if the currently authenticated user (or the specified user) can do a given action to a given set of objects.",
"type": "object",
Expand Down Expand Up @@ -762,7 +867,7 @@ const docTemplate = `{
"type": "string"
},
"resource_id": {
"description": "ResourceID (optional) reduces the set to a singular resource. This assigns\na resource ID to the resource type, eg: a single workspace.\nThe rbac library will not fetch the resource from the database, so if you\nare using this option, you should also set the ` + "`" + `OwnerID` + "`" + ` and ` + "`" + `OrganizationID` + "`" + `\nif possible. Be as specific as possible using all the fields relevant.",
"description": "ResourceID (optional) reduces the set to a singular resource. This assigns\na resource ID to the resource type, eg: a single workspace.\nThe rbac library will not fetch the resource from the database, so if you\nare using this option, you should also set the owner ID and organization ID\nif possible. Be as specific as possible using all the fields relevant.",
"type": "string"
},
"resource_type": {
Expand All @@ -789,6 +894,19 @@ const docTemplate = `{
"type": "boolean"
}
},
"codersdk.BuildInfoResponse": {
"type": "object",
"properties": {
"external_url": {
"description": "ExternalURL references the current Coder version.\nFor production builds, this will link directly to a release. For development builds, this will link to a commit.",
"type": "string"
},
"version": {
"description": "Version returns the semantic version of the build.",
"type": "string"
}
}
},
"codersdk.CreateParameterRequest": {
"description": "CreateParameterRequest is a structure used to create a new parameter value for a scope.",
"type": "object",
Expand Down Expand Up @@ -899,7 +1017,7 @@ const docTemplate = `{
"type": "integer"
},
"url": {
"description": "URL specifies the url to check for the app health.",
"description": "URL specifies the endpoint to check for the app health.",
"type": "string"
}
}
Expand Down Expand Up @@ -1066,6 +1184,23 @@ const docTemplate = `{
}
}
},
"codersdk.UpdateCheckResponse": {
"type": "object",
"properties": {
"current": {
"description": "Current indicates whether the server version is the same as the latest.",
"type": "boolean"
},
"url": {
"description": "URL to download the latest release of Coder.",
"type": "string"
},
"version": {
"description": "Version is the semantic version for the latest release of Coder.",
"type": "string"
}
}
},
"codersdk.UpdateWorkspaceAutostartRequest": {
"type": "object",
"properties": {
Expand Down
121 changes: 119 additions & 2 deletions coderd/apidoc/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@
},
"basePath": "/api/v2",
"paths": {
"/": {
"get": {
"produces": ["application/json"],
"tags": ["General"],
"summary": "API root handler",
"operationId": "api-root-handler",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.Response"
}
}
}
}
},
"/applications/auth-redirect": {
"get": {
"security": [
Expand Down Expand Up @@ -96,6 +112,52 @@
}
}
},
"/buildinfo": {
"get": {
"produces": ["application/json"],
"tags": ["General"],
"summary": "Build info",
"operationId": "build-info",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.BuildInfoResponse"
}
}
}
}
},
"/csp/reports": {
"post": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": ["application/json"],
"produces": ["text/plain"],
"tags": ["General"],
"summary": "Report CSP violations",
"operationId": "report-csp-violations",
"parameters": [
{
"description": "Violation report",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/coderd.cspViolation"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/organizations/{organization-id}/templates/": {
"post": {
"security": [
Expand Down Expand Up @@ -306,6 +368,22 @@
}
}
},
"/updatecheck": {
"get": {
"produces": ["application/json"],
"tags": ["General"],
"summary": "Update check",
"operationId": "update-check",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.UpdateCheckResponse"
}
}
}
}
},
"/users/{user}/workspace/{workspacename}": {
"get": {
"security": [
Expand Down Expand Up @@ -639,6 +717,15 @@
}
},
"definitions": {
"coderd.cspViolation": {
"type": "object",
"properties": {
"csp-report": {
"type": "object",
"additionalProperties": true
}
}
},
"codersdk.AuthorizationCheck": {
"description": "AuthorizationCheck is used to check if the currently authenticated user (or the specified user) can do a given action to a given set of objects.",
"type": "object",
Expand Down Expand Up @@ -666,7 +753,7 @@
"type": "string"
},
"resource_id": {
"description": "ResourceID (optional) reduces the set to a singular resource. This assigns\na resource ID to the resource type, eg: a single workspace.\nThe rbac library will not fetch the resource from the database, so if you\nare using this option, you should also set the `OwnerID` and `OrganizationID`\nif possible. Be as specific as possible using all the fields relevant.",
"description": "ResourceID (optional) reduces the set to a singular resource. This assigns\na resource ID to the resource type, eg: a single workspace.\nThe rbac library will not fetch the resource from the database, so if you\nare using this option, you should also set the owner ID and organization ID\nif possible. Be as specific as possible using all the fields relevant.",
"type": "string"
},
"resource_type": {
Expand All @@ -693,6 +780,19 @@
"type": "boolean"
}
},
"codersdk.BuildInfoResponse": {
"type": "object",
"properties": {
"external_url": {
"description": "ExternalURL references the current Coder version.\nFor production builds, this will link directly to a release. For development builds, this will link to a commit.",
"type": "string"
},
"version": {
"description": "Version returns the semantic version of the build.",
"type": "string"
}
}
},
"codersdk.CreateParameterRequest": {
"description": "CreateParameterRequest is a structure used to create a new parameter value for a scope.",
"type": "object",
Expand Down Expand Up @@ -795,7 +895,7 @@
"type": "integer"
},
"url": {
"description": "URL specifies the url to check for the app health.",
"description": "URL specifies the endpoint to check for the app health.",
"type": "string"
}
}
Expand Down Expand Up @@ -960,6 +1060,23 @@
}
}
},
"codersdk.UpdateCheckResponse": {
"type": "object",
"properties": {
"current": {
"description": "Current indicates whether the server version is the same as the latest.",
"type": "boolean"
},
"url": {
"description": "URL to download the latest release of Coder.",
"type": "string"
},
"version": {
"description": "Version is the semantic version for the latest release of Coder.",
"type": "string"
}
}
},
"codersdk.UpdateWorkspaceAutostartRequest": {
"type": "object",
"properties": {
Expand Down
21 changes: 21 additions & 0 deletions coderd/apiroot.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package coderd

import (
"net/http"

"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/codersdk"
)

// @Summary API root handler
// @ID api-root-handler
// @Produce json
// @Tags General
// @Success 200 {object} codersdk.Response
// @Router / [get]
func apiRoot(w http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), w, http.StatusOK, codersdk.Response{
//nolint:gocritic
Message: "👋",
})
}
Loading