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

Skip to content

Commit 77be926

Browse files
committed
Entitlements
1 parent 8f22f8d commit 77be926

File tree

8 files changed

+267
-2
lines changed

8 files changed

+267
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/me
483483
cd site
484484
yarn run format:write:only ../docs/admin/prometheus.md
485485

486-
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen -not \( -path './scripts/apidocgen/node_modules' -prune \) -type f) $(wildcard coderd/*.go) $(wildcard codersdk/*.go) .swaggo
486+
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen -not \( -path './scripts/apidocgen/node_modules' -prune \) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) .swaggo
487487
./scripts/apidocgen/generate.sh
488488
cd site
489489
yarn run format:write:only ../docs/api ../docs/manifest.json ../coderd/apidoc/swagger.json

coderd/apidoc/docs.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,31 @@ const docTemplate = `{
303303
}
304304
}
305305
},
306+
"/entitlements": {
307+
"get": {
308+
"security": [
309+
{
310+
"CoderSessionToken": []
311+
}
312+
],
313+
"produces": [
314+
"application/json"
315+
],
316+
"tags": [
317+
"Enterprise"
318+
],
319+
"summary": "Get entitlements",
320+
"operationId": "get-entitlements",
321+
"responses": {
322+
"200": {
323+
"description": "OK",
324+
"schema": {
325+
"$ref": "#/definitions/codersdk.Entitlements"
326+
}
327+
}
328+
}
329+
}
330+
},
306331
"/files": {
307332
"post": {
308333
"security": [
@@ -4788,6 +4813,55 @@ const docTemplate = `{
47884813
}
47894814
}
47904815
},
4816+
"codersdk.Entitlements": {
4817+
"type": "object",
4818+
"properties": {
4819+
"errors": {
4820+
"type": "array",
4821+
"items": {
4822+
"type": "string"
4823+
}
4824+
},
4825+
"experimental": {
4826+
"type": "boolean"
4827+
},
4828+
"features": {
4829+
"type": "object",
4830+
"additionalProperties": {
4831+
"$ref": "#/definitions/codersdk.Feature"
4832+
}
4833+
},
4834+
"has_license": {
4835+
"type": "boolean"
4836+
},
4837+
"trial": {
4838+
"type": "boolean"
4839+
},
4840+
"warnings": {
4841+
"type": "array",
4842+
"items": {
4843+
"type": "string"
4844+
}
4845+
}
4846+
}
4847+
},
4848+
"codersdk.Feature": {
4849+
"type": "object",
4850+
"properties": {
4851+
"actual": {
4852+
"type": "integer"
4853+
},
4854+
"enabled": {
4855+
"type": "boolean"
4856+
},
4857+
"entitlement": {
4858+
"type": "string"
4859+
},
4860+
"limit": {
4861+
"type": "integer"
4862+
}
4863+
}
4864+
},
47914865
"codersdk.GenerateAPIKeyResponse": {
47924866
"type": "object",
47934867
"properties": {

coderd/apidoc/swagger.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,27 @@
257257
}
258258
}
259259
},
260+
"/entitlements": {
261+
"get": {
262+
"security": [
263+
{
264+
"CoderSessionToken": []
265+
}
266+
],
267+
"produces": ["application/json"],
268+
"tags": ["Enterprise"],
269+
"summary": "Get entitlements",
270+
"operationId": "get-entitlements",
271+
"responses": {
272+
"200": {
273+
"description": "OK",
274+
"schema": {
275+
"$ref": "#/definitions/codersdk.Entitlements"
276+
}
277+
}
278+
}
279+
}
280+
},
260281
"/files": {
261282
"post": {
262283
"security": [
@@ -4279,6 +4300,55 @@
42794300
}
42804301
}
42814302
},
4303+
"codersdk.Entitlements": {
4304+
"type": "object",
4305+
"properties": {
4306+
"errors": {
4307+
"type": "array",
4308+
"items": {
4309+
"type": "string"
4310+
}
4311+
},
4312+
"experimental": {
4313+
"type": "boolean"
4314+
},
4315+
"features": {
4316+
"type": "object",
4317+
"additionalProperties": {
4318+
"$ref": "#/definitions/codersdk.Feature"
4319+
}
4320+
},
4321+
"has_license": {
4322+
"type": "boolean"
4323+
},
4324+
"trial": {
4325+
"type": "boolean"
4326+
},
4327+
"warnings": {
4328+
"type": "array",
4329+
"items": {
4330+
"type": "string"
4331+
}
4332+
}
4333+
}
4334+
},
4335+
"codersdk.Feature": {
4336+
"type": "object",
4337+
"properties": {
4338+
"actual": {
4339+
"type": "integer"
4340+
},
4341+
"enabled": {
4342+
"type": "boolean"
4343+
},
4344+
"entitlement": {
4345+
"type": "string"
4346+
},
4347+
"limit": {
4348+
"type": "integer"
4349+
}
4350+
}
4351+
},
42824352
"codersdk.GenerateAPIKeyResponse": {
42834353
"type": "object",
42844354
"properties": {

docs/api/enterprise.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Enterprise
2+
3+
> This page is incomplete, stay tuned.
4+
5+
## Get entitlements
6+
7+
### Code samples
8+
9+
```shell
10+
# Example request using curl
11+
curl -X GET http://coder-server:8080/api/v2/entitlements \
12+
-H 'Accept: application/json' \
13+
-H 'Coder-Session-Token: API_KEY'
14+
```
15+
16+
`GET /entitlements`
17+
18+
### Example responses
19+
20+
> 200 Response
21+
22+
```json
23+
{
24+
"errors": ["string"],
25+
"experimental": true,
26+
"features": {
27+
"property1": {
28+
"actual": 0,
29+
"enabled": true,
30+
"entitlement": "string",
31+
"limit": 0
32+
},
33+
"property2": {
34+
"actual": 0,
35+
"enabled": true,
36+
"entitlement": "string",
37+
"limit": 0
38+
}
39+
},
40+
"has_license": true,
41+
"trial": true,
42+
"warnings": ["string"]
43+
}
44+
```
45+
46+
### Responses
47+
48+
| Status | Meaning | Description | Schema |
49+
| ------ | ------------------------------------------------------- | ----------- | -------------------------------------------------------- |
50+
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.Entitlements](schemas.md#codersdkentitlements) |
51+
52+
To perform this operation, you must be authenticated. [Learn more](authentication.md).

docs/api/schemas.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,64 @@ CreateParameterRequest is a structure used to create a new parameter value for a
20822082
| `usage` | string | false | | |
20832083
| `value` | integer | false | | |
20842084

2085+
## codersdk.Entitlements
2086+
2087+
```json
2088+
{
2089+
"errors": ["string"],
2090+
"experimental": true,
2091+
"features": {
2092+
"property1": {
2093+
"actual": 0,
2094+
"enabled": true,
2095+
"entitlement": "string",
2096+
"limit": 0
2097+
},
2098+
"property2": {
2099+
"actual": 0,
2100+
"enabled": true,
2101+
"entitlement": "string",
2102+
"limit": 0
2103+
}
2104+
},
2105+
"has_license": true,
2106+
"trial": true,
2107+
"warnings": ["string"]
2108+
}
2109+
```
2110+
2111+
### Properties
2112+
2113+
| Name | Type | Required | Restrictions | Description |
2114+
| ------------------ | ------------------------------------ | -------- | ------------ | ----------- |
2115+
| `errors` | array of string | false | | |
2116+
| `experimental` | boolean | false | | |
2117+
| `features` | object | false | | |
2118+
| » `[any property]` | [codersdk.Feature](#codersdkfeature) | false | | |
2119+
| `has_license` | boolean | false | | |
2120+
| `trial` | boolean | false | | |
2121+
| `warnings` | array of string | false | | |
2122+
2123+
## codersdk.Feature
2124+
2125+
```json
2126+
{
2127+
"actual": 0,
2128+
"enabled": true,
2129+
"entitlement": "string",
2130+
"limit": 0
2131+
}
2132+
```
2133+
2134+
### Properties
2135+
2136+
| Name | Type | Required | Restrictions | Description |
2137+
| ------------- | ------- | -------- | ------------ | ----------- |
2138+
| `actual` | integer | false | | |
2139+
| `enabled` | boolean | false | | |
2140+
| `entitlement` | string | false | | |
2141+
| `limit` | integer | false | | |
2142+
20852143
## codersdk.GenerateAPIKeyResponse
20862144

20872145
```json

docs/manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@
345345
"title": "Authorization",
346346
"path": "./api/authorization.md"
347347
},
348+
{
349+
"title": "Enterprise",
350+
"path": "./api/enterprise.md"
351+
},
348352
{
349353
"title": "Files",
350354
"path": "./api/files.md"

enterprise/coderd/coderd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ func (api *API) updateEntitlements(ctx context.Context) error {
331331
return nil
332332
}
333333

334+
// @Summary Get entitlements
335+
// @ID get-entitlements
336+
// @Security CoderSessionToken
337+
// @Produce json
338+
// @Tags Enterprise
339+
// @Success 200 {object} codersdk.Entitlements
340+
// @Router /entitlements [get]
334341
func (api *API) serveEntitlements(rw http.ResponseWriter, r *http.Request) {
335342
ctx := r.Context()
336343
api.entitlementsMu.RLock()

scripts/apidocgen/generate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ log "Use temporary file: ${API_MD_TMP_FILE}"
2020
pushd "${PROJECT_ROOT}"
2121
go run github.com/swaggo/swag/cmd/[email protected] init \
2222
--generalInfo="coderd.go" \
23-
--dir="./coderd,./codersdk" \
23+
--dir="./coderd,./codersdk,./enterprise/coderd" \
2424
--output="./coderd/apidoc" \
2525
--outputTypes="go,json" \
2626
--parseDependency=true

0 commit comments

Comments
 (0)