Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1058 from joyent/ether/simplified-users
Browse files Browse the repository at this point in the history
endpoint improvements
  • Loading branch information
karenetheridge authored Nov 12, 2020
2 parents f1aa60d + 3508bff commit 7661949
Show file tree
Hide file tree
Showing 14 changed files with 308 additions and 54 deletions.
74 changes: 67 additions & 7 deletions docs/json-schema/query_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,34 @@
"definitions" : {
"BuildDevices" : {
"additionalProperties" : false,
"not" : {
"required" : [
"ids_only",
"serials_only"
],
"type" : "object"
},
"allOf" : [
{
"not" : {
"properties" : {
"ids_only" : {
"const" : 1
},
"serials_only" : {
"const" : 1
}
},
"required" : [
"ids_only",
"serials_only"
],
"type" : "object"
}
},
{
"not" : {
"required" : [
"phase_earlier_than",
"phase"
],
"type" : "object"
}
}
],
"properties" : {
"active_minutes" : {
"$ref" : "common.json#/definitions/non_negative_integer"
Expand All @@ -33,6 +54,21 @@
"ids_only" : {
"$ref" : "#/definitions/boolean_integer_default_false"
},
"phase" : {
"oneOf" : [
{
"$ref" : "common.json#/definitions/device_phase"
},
{
"items" : {
"$ref" : "common.json#/definitions/device_phase"
},
"minItems" : 2,
"type" : "array",
"uniqueItems" : true
}
]
},
"phase_earlier_than" : {
"oneOf" : [
{
Expand All @@ -49,6 +85,30 @@
},
"type" : "object"
},
"BuildRacks" : {
"additionalProperties" : false,
"properties" : {
"ids_only" : {
"$ref" : "#/definitions/boolean_integer_default_false"
},
"phase" : {
"oneOf" : [
{
"$ref" : "common.json#/definitions/device_phase"
},
{
"items" : {
"$ref" : "common.json#/definitions/device_phase"
},
"minItems" : 2,
"type" : "array",
"uniqueItems" : true
}
]
}
},
"type" : "object"
},
"ChangePassword" : {
"additionalProperties" : false,
"properties" : {
Expand Down
61 changes: 59 additions & 2 deletions docs/json-schema/response.json
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,13 @@
"type" : "array",
"uniqueItems" : true
},
"RackIds" : {
"items" : {
"$ref" : "common.json#/definitions/uuid"
},
"type" : "array",
"uniqueItems" : true
},
"RackLayout" : {
"additionalProperties" : false,
"properties" : {
Expand Down Expand Up @@ -3018,9 +3025,59 @@
"type" : "array",
"uniqueItems" : true
},
"UsersDetailed" : {
"Users" : {
"items" : {
"$ref" : "#/definitions/UserDetailed"
"additionalProperties" : false,
"properties" : {
"created" : {
"format" : "date-time",
"type" : "string"
},
"email" : {
"$ref" : "common.json#/definitions/email_address"
},
"force_password_change" : {
"type" : "boolean"
},
"id" : {
"$ref" : "common.json#/definitions/uuid"
},
"is_admin" : {
"type" : "boolean"
},
"last_login" : {
"format" : "date-time",
"type" : [
"null",
"string"
]
},
"last_seen" : {
"format" : "date-time",
"type" : [
"null",
"string"
]
},
"name" : {
"type" : "string"
},
"refuse_session_auth" : {
"type" : "boolean"
}
},
"required" : [
"id",
"name",
"email",
"created",
"last_login",
"last_seen",
"refuse_session_auth",
"force_password_change",
"is_admin"
],
"type" : "object"
},
"type" : "array",
"uniqueItems" : true
Expand Down
13 changes: 12 additions & 1 deletion docs/modules/Conch::Controller::Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ not ORed):
```
health=<value> only devices with health matching the provided value
(can be used more than once to search for ANY of the specified health values)
phase=<value> only devices with phase matching the provided value
(can be used more than once to search for ANY of the specified phase values)
active_minutes=X only devices last seen (via a report relay) within X minutes
ids_only=1 only return device ids, not full data
serials_only=1 only return device serial numbers, not full data
Expand Down Expand Up @@ -163,7 +165,16 @@ Requires the 'read/write' role on the build.
Get the racks in this build.
Requires the 'read-only' role on the build.

Response uses the Racks json schema.
Supports these query parameters to constrain results (which are ANDed together for the search,
not ORed):

```
phase=<value> only racks with phase matching the provided value
(can be used more than once to search for ANY of the specified phase values)
ids_only=1 only return rack ids, not full data
```

Response uses the Racks json schema, or RackIds iff `ids_only=1`.

### add\_rack

Expand Down
4 changes: 2 additions & 2 deletions docs/modules/Conch::Controller::User.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ The response uses the UserError json schema for some error conditions; on succes

### get\_all

List all active users and their workspaces, builds and organizations. System admin only.
Response uses the UsersDetailed json schema.
List all active users. System admin only.
Response uses the Users json schema.

### create

Expand Down
10 changes: 9 additions & 1 deletion docs/modules/Conch::Route::Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ Accepts the following optional query parameters:

- `health=:value` show only devices with the health matching the provided value
(can be used more than once)
- `phase=:value` show only devices with the phase matching the provided value
(can be used more than once)
- `active_minutes=:X` show only devices which have reported within the last X minutes
- `ids_only=1` only return device IDs, not full device details

Expand Down Expand Up @@ -156,9 +158,15 @@ read-write role on the device (via a workspace or build; see ["routes" in Conch:

### `GET /build/:build_id_or_name/rack`

Accepts the following optional query parameters:

- `phase=:value` show only racks with the phase matching the provided value
(can be used more than once)
- `ids_only=1` only return rack IDs, not full rack details

- Requires system admin authorization or the read-only role on the build
- Controller/Action: ["get\_racks" in Conch::Controller::Build](../modules/Conch%3A%3AController%3A%3ABuild#get_racks)
- Response: [response.json#/definitions/Racks](../json-schema/response.json#/definitions/Racks)
- Response: one of [response.json#/definitions/Racks](../json-schema/response.json#/definitions/Racks) or [response.json#/definitions/RackIds](../json-schema/response.json#/definitions/RackIds)

### `POST /build/:build_id_or_name/rack/:rack_id_or_name`

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/Conch::Route::User.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Optionally accepts the following query parameters:

- Requires system admin authorization
- Controller/Action: ["get\_all" in Conch::Controller::User](../modules/Conch%3A%3AController%3A%3AUser#get_all)
- Response: [response.json#/definitions/UsersDetailed](../json-schema/response.json#/definitions/UsersDetailed)
- Response: [response.json#/definitions/Users](../json-schema/response.json#/definitions/Users)

### `POST /user?send_mail=<1|0>`

Expand Down
39 changes: 34 additions & 5 deletions json-schema/query_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,46 @@ definitions:
minItems: 2
items:
$ref: common.yaml#/definitions/device_health
phase:
oneOf:
- $ref: common.yaml#/definitions/device_phase
- type: array
uniqueItems: true
minItems: 2
items:
$ref: common.yaml#/definitions/device_phase
active_minutes:
$ref: common.yaml#/definitions/non_negative_integer
ids_only:
$ref: '#/definitions/boolean_integer_default_false'
serials_only:
$ref: '#/definitions/boolean_integer_default_false'
not:
type: object
required:
- ids_only
- serials_only
allOf:
- not:
type: object
required: [ ids_only, serials_only ]
properties:
ids_only:
const: 1
serials_only:
const: 1
- not:
type: object
required: [ phase_earlier_than, phase ]
BuildRacks:
type: object
additionalProperties: false
properties:
phase:
oneOf:
- $ref: common.yaml#/definitions/device_phase
- type: array
uniqueItems: true
minItems: 2
items:
$ref: common.yaml#/definitions/device_phase
ids_only:
$ref: '#/definitions/boolean_integer_default_false'
ProcessDeviceReport:
type: object
additionalProperties: false
Expand Down
42 changes: 40 additions & 2 deletions json-schema/response.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,11 @@ definitions:
- $ref: common.yaml#/definitions/mojo_standard_placeholder
links:
$ref: common.yaml#/definitions/links
RackIds:
type: array
uniqueItems: true
items:
$ref: common.yaml#/definitions/uuid
RackRole:
type: object
additionalProperties: false
Expand Down Expand Up @@ -1674,11 +1679,44 @@ definitions:
$ref: common.yaml#/definitions/role
role_via_organization_id:
$ref: common.yaml#/definitions/uuid
UsersDetailed:
Users:
type: array
uniqueItems: true
items:
$ref: '#/definitions/UserDetailed'
type: object
additionalProperties: false
required:
- id
- name
- email
- created
- last_login
- last_seen
- refuse_session_auth
- force_password_change
- is_admin
properties:
id:
$ref: common.yaml#/definitions/uuid
name:
type: string
email:
$ref: common.yaml#/definitions/email_address
created:
type: string
format: date-time
last_login:
type: [ 'null', string ]
format: date-time
last_seen:
type: [ 'null', string ]
format: date-time
refuse_session_auth:
type: boolean
force_password_change:
type: boolean
is_admin:
type: boolean
UserSettings:
type: object
propertyNames:
Expand Down
Loading

0 comments on commit 7661949

Please sign in to comment.