chore: move agent functions from codersdk into agentsdk (#5903)

* chore: rename `AgentConn` to `WorkspaceAgentConn`

The codersdk was becoming bloated with consts for the workspace
agent that made no sense to a reader. `Tailnet*` is an example
of these consts.

* chore: remove `Get` prefix from *Client functions

* chore: remove `BypassRatelimits` option in `codersdk.Client`

It feels wrong to have this as a direct option because it's so infrequently
needed by API callers. It's better to directly modify headers in the two
places that we actually use it.

* Merge `appearance.go` and `buildinfo.go` into `deployment.go`

* Merge `experiments.go` and `features.go` into `deployment.go`

* Fix `make gen` referencing old type names

* Merge `error.go` into `client.go`

`codersdk.Response` lived in `error.go`, which is wrong.

* chore: refactor workspace agent functions into agentsdk

It was odd conflating the codersdk that clients should use
with functions that only the agent should use. This separates
them into two SDKs that are closely coupled, but separate.

* Merge `insights.go` into `deployment.go`

* Merge `organizationmember.go` into `organizations.go`

* Merge `quota.go` into `workspaces.go`

* Rename `sse.go` to `serversentevents.go`

* Rename `codersdk.WorkspaceAppHostResponse` to `codersdk.AppHostResponse`

* Format `.vscode/settings.json`

* Fix outdated naming in `api.ts`

* Fix app host response

* Fix unsupported type

* Fix imported type
This commit is contained in:
Kyle Carberry
2023-01-29 15:47:24 -06:00
committed by GitHub
parent e49f41652f
commit 7ad87505c8
115 changed files with 2491 additions and 2567 deletions

456
coderd/apidoc/docs.go generated
View File

@ -153,7 +153,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.GetAppHostResponse"
"$ref": "#/definitions/codersdk.AppHostResponse"
}
}
}
@ -3781,7 +3781,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.AWSInstanceIdentityToken"
"$ref": "#/definitions/agentsdk.AWSInstanceIdentityToken"
}
}
],
@ -3789,7 +3789,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.WorkspaceAgentAuthenticateResponse"
"$ref": "#/definitions/agentsdk.AuthenticateResponse"
}
}
}
@ -3820,7 +3820,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.AzureInstanceIdentityToken"
"$ref": "#/definitions/agentsdk.AzureInstanceIdentityToken"
}
}
],
@ -3828,7 +3828,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.WorkspaceAgentAuthenticateResponse"
"$ref": "#/definitions/agentsdk.AuthenticateResponse"
}
}
}
@ -3859,7 +3859,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.GoogleInstanceIdentityToken"
"$ref": "#/definitions/agentsdk.GoogleInstanceIdentityToken"
}
}
],
@ -3867,7 +3867,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.WorkspaceAgentAuthenticateResponse"
"$ref": "#/definitions/agentsdk.AuthenticateResponse"
}
}
}
@ -3898,7 +3898,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.PostWorkspaceAppHealthsRequest"
"$ref": "#/definitions/agentsdk.PostAppHealthsRequest"
}
}
],
@ -3964,7 +3964,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.WorkspaceAgentGitAuthResponse"
"$ref": "#/definitions/agentsdk.GitAuthResponse"
}
}
}
@ -3989,7 +3989,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.AgentGitSSHKey"
"$ref": "#/definitions/agentsdk.GitSSHKey"
}
}
}
@ -4014,7 +4014,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.WorkspaceAgentMetadata"
"$ref": "#/definitions/agentsdk.Metadata"
}
}
}
@ -4042,7 +4042,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.PostWorkspaceAgentLifecycleRequest"
"$ref": "#/definitions/agentsdk.PostLifecycleRequest"
}
}
],
@ -4081,7 +4081,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.AgentStats"
"$ref": "#/definitions/agentsdk.Stats"
}
}
],
@ -4089,7 +4089,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.AgentStatsResponse"
"$ref": "#/definitions/agentsdk.StatsResponse"
}
}
}
@ -4120,7 +4120,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.PostWorkspaceAgentVersionRequest"
"$ref": "#/definitions/agentsdk.PostVersionRequest"
}
}
],
@ -4262,7 +4262,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.ListeningPortsResponse"
"$ref": "#/definitions/codersdk.WorkspaceAgentListeningPortsResponse"
}
}
}
@ -4957,6 +4957,188 @@ const docTemplate = `{
}
},
"definitions": {
"agentsdk.AWSInstanceIdentityToken": {
"type": "object",
"required": [
"document",
"signature"
],
"properties": {
"document": {
"type": "string"
},
"signature": {
"type": "string"
}
}
},
"agentsdk.AuthenticateResponse": {
"type": "object",
"properties": {
"session_token": {
"type": "string"
}
}
},
"agentsdk.AzureInstanceIdentityToken": {
"type": "object",
"required": [
"encoding",
"signature"
],
"properties": {
"encoding": {
"type": "string"
},
"signature": {
"type": "string"
}
}
},
"agentsdk.GitAuthResponse": {
"type": "object",
"properties": {
"password": {
"type": "string"
},
"url": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"agentsdk.GitSSHKey": {
"type": "object",
"properties": {
"private_key": {
"type": "string"
},
"public_key": {
"type": "string"
}
}
},
"agentsdk.GoogleInstanceIdentityToken": {
"type": "object",
"required": [
"json_web_token"
],
"properties": {
"json_web_token": {
"type": "string"
}
}
},
"agentsdk.Metadata": {
"type": "object",
"properties": {
"apps": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.WorkspaceApp"
}
},
"derpmap": {
"$ref": "#/definitions/tailcfg.DERPMap"
},
"directory": {
"type": "string"
},
"environment_variables": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"git_auth_configs": {
"description": "GitAuthConfigs stores the number of Git configurations\nthe Coder deployment has. If this number is \u003e0, we\nset up special configuration in the workspace.",
"type": "integer"
},
"motd_file": {
"type": "string"
},
"startup_script": {
"type": "string"
},
"startup_script_timeout": {
"type": "integer"
},
"vscode_port_proxy_uri": {
"type": "string"
}
}
},
"agentsdk.PostAppHealthsRequest": {
"type": "object",
"properties": {
"healths": {
"description": "Healths is a map of the workspace app name and the health of the app.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/codersdk.WorkspaceAppHealth"
}
}
}
},
"agentsdk.PostLifecycleRequest": {
"type": "object",
"properties": {
"state": {
"$ref": "#/definitions/codersdk.WorkspaceAgentLifecycle"
}
}
},
"agentsdk.PostVersionRequest": {
"type": "object",
"properties": {
"version": {
"type": "string"
}
}
},
"agentsdk.Stats": {
"type": "object",
"properties": {
"conns_by_proto": {
"description": "ConnsByProto is a count of connections by protocol.",
"type": "object",
"additionalProperties": {
"type": "integer"
}
},
"num_comms": {
"description": "NumConns is the number of connections received by an agent.",
"type": "integer"
},
"rx_bytes": {
"description": "RxBytes is the number of received bytes.",
"type": "integer"
},
"rx_packets": {
"description": "RxPackets is the number of received packets.",
"type": "integer"
},
"tx_bytes": {
"description": "TxBytes is the number of transmitted bytes.",
"type": "integer"
},
"tx_packets": {
"description": "TxPackets is the number of transmitted bytes.",
"type": "integer"
}
}
},
"agentsdk.StatsResponse": {
"type": "object",
"properties": {
"report_interval": {
"description": "ReportInterval is the duration after which the agent should send stats\nagain.",
"type": "integer"
}
}
},
"coderd.SCIMUser": {
"type": "object",
"properties": {
@ -5107,21 +5289,6 @@ const docTemplate = `{
"APIKeyScopeApplicationConnect"
]
},
"codersdk.AWSInstanceIdentityToken": {
"type": "object",
"required": [
"document",
"signature"
],
"properties": {
"document": {
"type": "string"
},
"signature": {
"type": "string"
}
}
},
"codersdk.AddLicenseRequest": {
"type": "object",
"required": [
@ -5133,55 +5300,12 @@ const docTemplate = `{
}
}
},
"codersdk.AgentGitSSHKey": {
"codersdk.AppHostResponse": {
"type": "object",
"properties": {
"private_key": {
"host": {
"description": "Host is the externally accessible URL for the Coder instance.",
"type": "string"
},
"public_key": {
"type": "string"
}
}
},
"codersdk.AgentStats": {
"type": "object",
"properties": {
"conns_by_proto": {
"description": "ConnsByProto is a count of connections by protocol.",
"type": "object",
"additionalProperties": {
"type": "integer"
}
},
"num_comms": {
"description": "NumConns is the number of connections received by an agent.",
"type": "integer"
},
"rx_bytes": {
"description": "RxBytes is the number of received bytes.",
"type": "integer"
},
"rx_packets": {
"description": "RxPackets is the number of received packets.",
"type": "integer"
},
"tx_bytes": {
"description": "TxBytes is the number of transmitted bytes.",
"type": "integer"
},
"tx_packets": {
"description": "TxPackets is the number of transmitted bytes.",
"type": "integer"
}
}
},
"codersdk.AgentStatsResponse": {
"type": "object",
"properties": {
"report_interval": {
"description": "ReportInterval is the duration after which the agent should send stats\nagain.",
"type": "integer"
}
}
},
@ -5402,21 +5526,6 @@ const docTemplate = `{
"type": "boolean"
}
},
"codersdk.AzureInstanceIdentityToken": {
"type": "object",
"required": [
"encoding",
"signature"
],
"properties": {
"encoding": {
"type": "string"
},
"signature": {
"type": "string"
}
}
},
"codersdk.BuildInfoResponse": {
"type": "object",
"properties": {
@ -6263,15 +6372,6 @@ const docTemplate = `{
}
}
},
"codersdk.GetAppHostResponse": {
"type": "object",
"properties": {
"host": {
"description": "Host is the externally accessible URL for the Coder instance.",
"type": "string"
}
}
},
"codersdk.GetUsersResponse": {
"type": "object",
"properties": {
@ -6341,17 +6441,6 @@ const docTemplate = `{
}
}
},
"codersdk.GoogleInstanceIdentityToken": {
"type": "object",
"required": [
"json_web_token"
],
"properties": {
"json_web_token": {
"type": "string"
}
}
},
"codersdk.Group": {
"type": "object",
"properties": {
@ -6418,47 +6507,6 @@ const docTemplate = `{
}
}
},
"codersdk.ListeningPort": {
"type": "object",
"properties": {
"network": {
"description": "only \"tcp\" at the moment",
"allOf": [
{
"$ref": "#/definitions/codersdk.ListeningPortNetwork"
}
]
},
"port": {
"type": "integer"
},
"process_name": {
"description": "may be empty",
"type": "string"
}
}
},
"codersdk.ListeningPortNetwork": {
"type": "string",
"enum": [
"tcp"
],
"x-enum-varnames": [
"ListeningPortNetworkTCP"
]
},
"codersdk.ListeningPortsResponse": {
"type": "object",
"properties": {
"ports": {
"description": "If there are no ports in the list, nothing should be displayed in the UI.\nThere must not be a \"no ports available\" message or anything similar, as\nthere will always be no ports displayed on platforms where our port\ndetection logic is unsupported.",
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.ListeningPort"
}
}
}
},
"codersdk.LogLevel": {
"type": "string",
"enum": [
@ -6836,35 +6884,6 @@ const docTemplate = `{
"ParameterSourceSchemeData"
]
},
"codersdk.PostWorkspaceAgentLifecycleRequest": {
"type": "object",
"properties": {
"state": {
"$ref": "#/definitions/codersdk.WorkspaceAgentLifecycle"
}
}
},
"codersdk.PostWorkspaceAgentVersionRequest": {
"description": "x-apidocgen:skip",
"type": "object",
"properties": {
"version": {
"type": "string"
}
}
},
"codersdk.PostWorkspaceAppHealthsRequest": {
"type": "object",
"properties": {
"healths": {
"description": "Healths is a map of the workspace app name and the health of the app.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/codersdk.WorkspaceAppHealth"
}
}
}
},
"codersdk.PprofConfig": {
"type": "object",
"properties": {
@ -7844,14 +7863,6 @@ const docTemplate = `{
}
}
},
"codersdk.WorkspaceAgentAuthenticateResponse": {
"type": "object",
"properties": {
"session_token": {
"type": "string"
}
}
},
"codersdk.WorkspaceAgentConnectionInfo": {
"type": "object",
"properties": {
@ -7860,20 +7871,6 @@ const docTemplate = `{
}
}
},
"codersdk.WorkspaceAgentGitAuthResponse": {
"type": "object",
"properties": {
"password": {
"type": "string"
},
"url": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"codersdk.WorkspaceAgentLifecycle": {
"type": "string",
"enum": [
@ -7891,42 +7888,31 @@ const docTemplate = `{
"WorkspaceAgentLifecycleReady"
]
},
"codersdk.WorkspaceAgentMetadata": {
"codersdk.WorkspaceAgentListeningPort": {
"type": "object",
"properties": {
"apps": {
"network": {
"description": "only \"tcp\" at the moment",
"type": "string"
},
"port": {
"type": "integer"
},
"process_name": {
"description": "may be empty",
"type": "string"
}
}
},
"codersdk.WorkspaceAgentListeningPortsResponse": {
"type": "object",
"properties": {
"ports": {
"description": "If there are no ports in the list, nothing should be displayed in the UI.\nThere must not be a \"no ports available\" message or anything similar, as\nthere will always be no ports displayed on platforms where our port\ndetection logic is unsupported.",
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.WorkspaceApp"
"$ref": "#/definitions/codersdk.WorkspaceAgentListeningPort"
}
},
"derpmap": {
"$ref": "#/definitions/tailcfg.DERPMap"
},
"directory": {
"type": "string"
},
"environment_variables": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"git_auth_configs": {
"description": "GitAuthConfigs stores the number of Git configurations\nthe Coder deployment has. If this number is \u003e0, we\nset up special configuration in the workspace.",
"type": "integer"
},
"motd_file": {
"type": "string"
},
"startup_script": {
"type": "string"
},
"startup_script_timeout": {
"type": "integer"
},
"vscode_port_proxy_uri": {
"type": "string"
}
}
},