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

Skip to content

Commit 0dc1d2a

Browse files
committed
Users
1 parent 801cad1 commit 0dc1d2a

File tree

9 files changed

+501
-20
lines changed

9 files changed

+501
-20
lines changed

coderd/apidoc/docs.go

Lines changed: 149 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,25 @@ const docTemplate = `{
11951195
"name": "id",
11961196
"in": "path",
11971197
"required": true
1198+
},
1199+
{
1200+
"type": "string",
1201+
"format": "uuid",
1202+
"description": "After ID",
1203+
"name": "after_id",
1204+
"in": "query"
1205+
},
1206+
{
1207+
"type": "integer",
1208+
"description": "Page limit",
1209+
"name": "limit",
1210+
"in": "query"
1211+
},
1212+
{
1213+
"type": "integer",
1214+
"description": "Page offset",
1215+
"name": "offset",
1216+
"in": "query"
11981217
}
11991218
],
12001219
"responses": {
@@ -1798,6 +1817,95 @@ const docTemplate = `{
17981817
}
17991818
}
18001819
},
1820+
"/users": {
1821+
"get": {
1822+
"security": [
1823+
{
1824+
"CoderSessionToken": []
1825+
}
1826+
],
1827+
"produces": [
1828+
"application/json"
1829+
],
1830+
"tags": [
1831+
"Users"
1832+
],
1833+
"summary": "Get users",
1834+
"operationId": "get-users",
1835+
"parameters": [
1836+
{
1837+
"type": "string",
1838+
"description": "Search query",
1839+
"name": "q",
1840+
"in": "query"
1841+
},
1842+
{
1843+
"type": "string",
1844+
"format": "uuid",
1845+
"description": "After ID",
1846+
"name": "after_id",
1847+
"in": "query"
1848+
},
1849+
{
1850+
"type": "integer",
1851+
"description": "Page limit",
1852+
"name": "limit",
1853+
"in": "query"
1854+
},
1855+
{
1856+
"type": "integer",
1857+
"description": "Page offset",
1858+
"name": "offset",
1859+
"in": "query"
1860+
}
1861+
],
1862+
"responses": {
1863+
"200": {
1864+
"description": "OK",
1865+
"schema": {
1866+
"$ref": "#/definitions/codersdk.GetUsersResponse"
1867+
}
1868+
}
1869+
}
1870+
},
1871+
"post": {
1872+
"security": [
1873+
{
1874+
"CoderSessionToken": []
1875+
}
1876+
],
1877+
"consumes": [
1878+
"application/json"
1879+
],
1880+
"produces": [
1881+
"application/json"
1882+
],
1883+
"tags": [
1884+
"Users"
1885+
],
1886+
"summary": "Create new user",
1887+
"operationId": "create-new-user",
1888+
"parameters": [
1889+
{
1890+
"description": "Create user request",
1891+
"name": "request",
1892+
"in": "body",
1893+
"required": true,
1894+
"schema": {
1895+
"$ref": "#/definitions/codersdk.CreateUserRequest"
1896+
}
1897+
}
1898+
],
1899+
"responses": {
1900+
"201": {
1901+
"description": "Created",
1902+
"schema": {
1903+
"$ref": "#/definitions/codersdk.User"
1904+
}
1905+
}
1906+
}
1907+
}
1908+
},
18011909
"/users/authmethods": {
18021910
"get": {
18031911
"security": [
@@ -3439,6 +3547,31 @@ const docTemplate = `{
34393547
}
34403548
}
34413549
},
3550+
"codersdk.CreateUserRequest": {
3551+
"type": "object",
3552+
"required": [
3553+
"email",
3554+
"organization_id",
3555+
"password",
3556+
"username"
3557+
],
3558+
"properties": {
3559+
"email": {
3560+
"type": "string",
3561+
"format": "email"
3562+
},
3563+
"organization_id": {
3564+
"type": "string",
3565+
"format": "uuid"
3566+
},
3567+
"password": {
3568+
"type": "string"
3569+
},
3570+
"username": {
3571+
"type": "string"
3572+
}
3573+
}
3574+
},
34423575
"codersdk.CreateWorkspaceBuildRequest": {
34433576
"type": "object",
34443577
"required": [
@@ -3858,6 +3991,20 @@ const docTemplate = `{
38583991
}
38593992
}
38603993
},
3994+
"codersdk.GetUsersResponse": {
3995+
"type": "object",
3996+
"properties": {
3997+
"count": {
3998+
"type": "integer"
3999+
},
4000+
"users": {
4001+
"type": "array",
4002+
"items": {
4003+
"$ref": "#/definitions/codersdk.User"
4004+
}
4005+
}
4006+
}
4007+
},
38614008
"codersdk.GitAuthConfig": {
38624009
"type": "object",
38634010
"properties": {
@@ -4691,7 +4838,8 @@ const docTemplate = `{
46914838
"format": "date-time"
46924839
},
46934840
"email": {
4694-
"type": "string"
4841+
"type": "string",
4842+
"format": "email"
46954843
},
46964844
"id": {
46974845
"type": "string",

coderd/apidoc/swagger.json

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,25 @@
10411041
"name": "id",
10421042
"in": "path",
10431043
"required": true
1044+
},
1045+
{
1046+
"type": "string",
1047+
"format": "uuid",
1048+
"description": "After ID",
1049+
"name": "after_id",
1050+
"in": "query"
1051+
},
1052+
{
1053+
"type": "integer",
1054+
"description": "Page limit",
1055+
"name": "limit",
1056+
"in": "query"
1057+
},
1058+
{
1059+
"type": "integer",
1060+
"description": "Page offset",
1061+
"name": "offset",
1062+
"in": "query"
10441063
}
10451064
],
10461065
"responses": {
@@ -1582,6 +1601,85 @@
15821601
}
15831602
}
15841603
},
1604+
"/users": {
1605+
"get": {
1606+
"security": [
1607+
{
1608+
"CoderSessionToken": []
1609+
}
1610+
],
1611+
"produces": ["application/json"],
1612+
"tags": ["Users"],
1613+
"summary": "Get users",
1614+
"operationId": "get-users",
1615+
"parameters": [
1616+
{
1617+
"type": "string",
1618+
"description": "Search query",
1619+
"name": "q",
1620+
"in": "query"
1621+
},
1622+
{
1623+
"type": "string",
1624+
"format": "uuid",
1625+
"description": "After ID",
1626+
"name": "after_id",
1627+
"in": "query"
1628+
},
1629+
{
1630+
"type": "integer",
1631+
"description": "Page limit",
1632+
"name": "limit",
1633+
"in": "query"
1634+
},
1635+
{
1636+
"type": "integer",
1637+
"description": "Page offset",
1638+
"name": "offset",
1639+
"in": "query"
1640+
}
1641+
],
1642+
"responses": {
1643+
"200": {
1644+
"description": "OK",
1645+
"schema": {
1646+
"$ref": "#/definitions/codersdk.GetUsersResponse"
1647+
}
1648+
}
1649+
}
1650+
},
1651+
"post": {
1652+
"security": [
1653+
{
1654+
"CoderSessionToken": []
1655+
}
1656+
],
1657+
"consumes": ["application/json"],
1658+
"produces": ["application/json"],
1659+
"tags": ["Users"],
1660+
"summary": "Create new user",
1661+
"operationId": "create-new-user",
1662+
"parameters": [
1663+
{
1664+
"description": "Create user request",
1665+
"name": "request",
1666+
"in": "body",
1667+
"required": true,
1668+
"schema": {
1669+
"$ref": "#/definitions/codersdk.CreateUserRequest"
1670+
}
1671+
}
1672+
],
1673+
"responses": {
1674+
"201": {
1675+
"description": "Created",
1676+
"schema": {
1677+
"$ref": "#/definitions/codersdk.User"
1678+
}
1679+
}
1680+
}
1681+
}
1682+
},
15851683
"/users/authmethods": {
15861684
"get": {
15871685
"security": [
@@ -3045,6 +3143,26 @@
30453143
}
30463144
}
30473145
},
3146+
"codersdk.CreateUserRequest": {
3147+
"type": "object",
3148+
"required": ["email", "organization_id", "password", "username"],
3149+
"properties": {
3150+
"email": {
3151+
"type": "string",
3152+
"format": "email"
3153+
},
3154+
"organization_id": {
3155+
"type": "string",
3156+
"format": "uuid"
3157+
},
3158+
"password": {
3159+
"type": "string"
3160+
},
3161+
"username": {
3162+
"type": "string"
3163+
}
3164+
}
3165+
},
30483166
"codersdk.CreateWorkspaceBuildRequest": {
30493167
"type": "object",
30503168
"required": ["transition"],
@@ -3457,6 +3575,20 @@
34573575
}
34583576
}
34593577
},
3578+
"codersdk.GetUsersResponse": {
3579+
"type": "object",
3580+
"properties": {
3581+
"count": {
3582+
"type": "integer"
3583+
},
3584+
"users": {
3585+
"type": "array",
3586+
"items": {
3587+
"$ref": "#/definitions/codersdk.User"
3588+
}
3589+
}
3590+
}
3591+
},
34603592
"codersdk.GitAuthConfig": {
34613593
"type": "object",
34623594
"properties": {
@@ -4245,7 +4377,8 @@
42454377
"format": "date-time"
42464378
},
42474379
"email": {
4248-
"type": "string"
4380+
"type": "string",
4381+
"format": "email"
42494382
},
42504383
"id": {
42514384
"type": "string",

coderd/templateversions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ func (api *API) fetchTemplateVersionDryRunJob(rw http.ResponseWriter, r *http.Re
541541
// @Produce json
542542
// @Tags Templates
543543
// @Param id path string true "Template ID" format(uuid)
544+
// @Param after_id query string false "After ID" format(uuid)
545+
// @Param limit query int false "Page limit"
546+
// @Param offset query int false "Page offset"
544547
// @Success 200 {array} codersdk.TemplateVersion
545548
// @Router /templates/{id}/versions [get]
546549
func (api *API) templateVersionsByTemplate(rw http.ResponseWriter, r *http.Request) {

coderd/users.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ func (api *API) postFirstUser(rw http.ResponseWriter, r *http.Request) {
153153
})
154154
}
155155

156+
// @Summary Get users
157+
// @ID get-users
158+
// @Security CoderSessionToken
159+
// @Produce json
160+
// @Tags Users
161+
// @Param q query string false "Search query"
162+
// @Param after_id query string false "After ID" format(uuid)
163+
// @Param limit query int false "Page limit"
164+
// @Param offset query int false "Page offset"
165+
// @Success 200 {object} codersdk.GetUsersResponse
166+
// @Router /users [get]
156167
func (api *API) users(rw http.ResponseWriter, r *http.Request) {
157168
ctx := r.Context()
158169
query := r.URL.Query().Get("q")
@@ -232,6 +243,16 @@ func (api *API) users(rw http.ResponseWriter, r *http.Request) {
232243
}
233244

234245
// Creates a new user.
246+
//
247+
// @Summary Create new user
248+
// @ID create-new-user
249+
// @Security CoderSessionToken
250+
// @Accept json
251+
// @Produce json
252+
// @Tags Users
253+
// @Param request body codersdk.CreateUserRequest true "Create user request"
254+
// @Success 201 {object} codersdk.User
255+
// @Router /users [post]
235256
func (api *API) postUser(rw http.ResponseWriter, r *http.Request) {
236257
ctx := r.Context()
237258
auditor := *api.Auditor.Load()

0 commit comments

Comments
 (0)