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

Commit

Permalink
endpoints for associating json_schemas with hardware_products
Browse files Browse the repository at this point in the history
POST /hardware_product/:hardware_product_id_or_other/json_schema/:json_schema_id
POST /hardware_product/:hardware_product_id_or_other/json_schema/:json_schema_type/:json_schema_name/:json_schema_version
GET /hardware_product/:hardware_product_id_or_other/json_schema
DELETE /hardware_product/:hardware_product_id_or_other/json_schema/:json_schema_id
DELETE /hardware_product/:hardware_product_id_or_other/json_schema/:json_schema_type/:json_schema_name/:json_schema_version
DELETE /hardware_product/:hardware_product_id_or_other/json_schema

also add ?with_hardware_products=1 option to GET /json_schema/:type/... endpoints
for listing the hardware_products that make use of that JSON Schema.
  • Loading branch information
karenetheridge committed Jan 14, 2021
1 parent 5886dd8 commit 2a782a7
Show file tree
Hide file tree
Showing 15 changed files with 745 additions and 20 deletions.
28 changes: 16 additions & 12 deletions docs/json-schema/query_params.json
@@ -1,18 +1,6 @@
{
"$comment" : "NOTE: This file is for human reference ONLY. For programmatic use, use the GET '/json_schema/query_params/$schema_name' endpoints, or within conch itself, json-schema/query_params.yaml.\nNote that all parameters are parsed internally from the request URI as strings, so all type checks here use strings. When a query parameter is used more than once, its values are parsed as an arrayref. See ../modules/Conch::Plugin::JSONValidator#validate_query_params.",
"$defs" : {
"ActiveOnly" : {
"additionalProperties" : false,
"default" : {
"active_only" : "0"
},
"properties" : {
"active_only" : {
"$ref" : "#/$defs/boolean_string"
}
},
"type" : "object"
},
"Anything" : {
"additionalProperties" : true,
"type" : "object"
Expand Down Expand Up @@ -249,6 +237,22 @@
],
"type" : "object"
},
"JSONSchemaDescriptions" : {
"additionalProperties" : false,
"default" : {
"active_only" : "0",
"with_hardware_products" : "0"
},
"properties" : {
"active_only" : {
"$ref" : "#/$defs/boolean_string"
},
"with_hardware_products" : {
"$ref" : "#/$defs/boolean_string"
}
},
"type" : "object"
},
"NotifyUsers" : {
"$comment" : "used for operations where email can optionally be sent",
"additionalProperties" : false,
Expand Down
106 changes: 106 additions & 0 deletions docs/json-schema/response.json
Expand Up @@ -1213,6 +1213,87 @@
],
"type" : "object"
},
"HardwareJSONSchemaDescriptions" : {
"items" : {
"additionalProperties" : false,
"properties" : {
"$id" : {
"format" : "uri-reference",
"pattern" : "^/json_schema/[A-Za-z0-9_-]+/[A-Za-z0-9_-]+/[0-9]+$",
"readOnly" : true,
"title" : "Canonical URI Identifier",
"type" : "string"
},
"added" : {
"format" : "date-time",
"readOnly" : true,
"title" : "Added",
"type" : "string"
},
"added_user" : {
"$ref" : "#/$defs/UserTerse",
"readOnly" : true,
"title" : "Added User"
},
"created" : {
"format" : "date-time",
"readOnly" : true,
"title" : "Created",
"type" : "string"
},
"created_user" : {
"$ref" : "#/$defs/UserTerse",
"readOnly" : true,
"title" : "Created User"
},
"description" : {
"title" : "Description",
"type" : "string"
},
"id" : {
"$ref" : "common.json#/$defs/uuid",
"readOnly" : true,
"title" : "ID"
},
"latest" : {
"description" : "true when it is the latest of its type-name series",
"title" : "Latest in Type-Name Series?",
"type" : "boolean"
},
"name" : {
"$ref" : "common.json#/$defs/json_pointer_token",
"readOnly" : true,
"title" : "Name"
},
"type" : {
"$ref" : "common.json#/$defs/json_pointer_token",
"readOnly" : true,
"title" : "Type"
},
"version" : {
"$ref" : "common.json#/$defs/positive_integer",
"readOnly" : true,
"title" : "Version"
}
},
"required" : [
"id",
"$id",
"description",
"type",
"name",
"version",
"latest",
"created",
"created_user",
"added",
"added_user"
],
"type" : "object"
},
"type" : "array",
"uniqueItems" : true
},
"HardwareProduct" : {
"additionalProperties" : false,
"properties" : {
Expand Down Expand Up @@ -1516,6 +1597,27 @@
],
"type" : "object"
},
"HardwareProductJSONSchemaDeleteError" : {
"additionalProperties" : false,
"properties" : {
"error" : {
"type" : "string"
},
"hardware_product_ids" : {
"items" : {
"$ref" : "common.json#/$defs/uuid"
},
"minItems" : 1,
"type" : "array",
"uniqueItems" : true
}
},
"required" : [
"error",
"hardware_product_ids"
],
"type" : "object"
},
"HardwareProducts" : {
"items" : {
"additionalProperties" : false,
Expand Down Expand Up @@ -1692,6 +1794,10 @@
"title" : "Description",
"type" : "string"
},
"hardware_products" : {
"$ref" : "#/$defs/HardwareProducts",
"title" : "Referenced by Hardware Products"
},
"id" : {
"$ref" : "common.json#/$defs/uuid",
"readOnly" : true,
Expand Down
8 changes: 8 additions & 0 deletions docs/modules/Conch::Controller::HardwareProduct.md
Expand Up @@ -53,6 +53,14 @@ Uses the URI query parameter `path` as a json pointer to determine the path with
After the delete operation, the `specification` property must validate against
the schema at `/json_schema/hardware_product/specification/latest`.

### add\_json\_schema

### get\_json\_schema\_metadata

### remove\_json\_schema

### remove\_all\_json\_schemas

## LICENSING

Copyright Joyent, Inc.
Expand Down
4 changes: 3 additions & 1 deletion docs/modules/Conch::DB::ResultSet::JSONSchema.md
Expand Up @@ -52,7 +52,9 @@ that row is the latest of its type-name series (that is, whether it can be refer

The query will be closed off as a subselect (that additional chaining will SELECT FROM),
so it makes a difference whether you add things to the resultset before or after calling this
method.
method. Note that if the initial resultset filters out some rows from the same type-name series,
the result will not be accurate, as the full series must be visible in order for the partition
query to work!

## LICENSING

Expand Down
38 changes: 38 additions & 0 deletions docs/modules/Conch::Route::HardwareProduct.md
Expand Up @@ -99,6 +99,44 @@ the schema available from `GET /json_schema/hardware_product/specification/lates
- Controller/Action: ["delete\_specification" in Conch::Controller::HardwareProduct](../modules/Conch%3A%3AController%3A%3AHardwareProduct#delete_specification)
- Response: `204 No Content`

### `GET /hardware/:hardware_product_id_or_other/json_schema`

Retrieves a summary of the JSON Schemas configured to be used as validations for the indicated
hardware. Note the timestamp and user information are for when the JSON Schema was added for
the hardware, not when the schema itself was created.

- Controller/Action: ["get\_json\_schema\_metadata" in Conch::Controller::HardwareProduct](../modules/Conch%3A%3AController%3A%3AHardwareProduct#get_json_schema_metadata)
- Response: [response.json#/$defs/HardwareJSONSchemaDescriptions](../json-schema/response.json#/$defs/HardwareJSONSchemaDescriptions)

### `POST /hardware/:hardware_product_id_or_other/json_schema/:json_schema_id`

### `POST /hardware/:hardware_product_id_or_other/json_schema/:json_schema_type/:json_schema_name/:json_schema_version`

Adds the indicated JSON Schema to the list of validations for the indicated hardware.

- Requires system admin authorization
- Controller/Action: ["add\_json\_schema" in Conch::Controller::HardwareProduct](../modules/Conch%3A%3AController%3A%3AHardwareProduct#add_json_schema)
- Request: [request.json#/$defs/Null](../json-schema/request.json#/$defs/Null)
- Response: `201 Created`

### `DELETE /hardware/:hardware_product_id_or_other/json_schema/:json_schema_id`

### `DELETE /hardware/:hardware_product_id_or_other/json_schema/:json_schema_type/:json_schema_name/:json_schema_version`

Removes the indicated JSON Schema from the list of validations for the indicated hardware.

- Requires system admin authorization
- Controller/Action: ["remove\_json\_schema" in Conch::Controller::HardwareProduct](../modules/Conch%3A%3AController%3A%3AHardwareProduct#remove_json_schema)
- Response: `204 No Content`

### `DELETE /hardware/:hardware_product_id_or_other/json_schema`

Removes **all** the JSON Schemas from the list of validations for the indicated hardware.

- Requires system admin authorization
- Controller/Action: ["remove\_all\_json\_schemas" in Conch::Controller::HardwareProduct](../modules/Conch%3A%3AController%3A%3AHardwareProduct#remove_all_json_schemas)
- Response: `204 No Content`

## LICENSING

Copyright Joyent, Inc.
Expand Down
2 changes: 2 additions & 0 deletions docs/modules/Conch::Route::JSONSchema.md
Expand Up @@ -80,6 +80,8 @@ Optionally accepts the following query parameter:

- `active_only` (default `0`): set to `1` to only query for JSON Schemas that have not been
deactivated.
- `with_hardware_products` (default `0`): set to `1` to include a list of hardware products
that reference each JSON Schema

- Controller/Action: ["get\_metadata" in Conch::Controller::JSONSchema](../modules/Conch%3A%3AController%3A%3AJSONSchema#get_metadata)
- Response: [response.json#/$defs/JSONSchemaDescriptions](../json-schema/response.json#/$defs/JSONSchemaDescriptions)
Expand Down
5 changes: 4 additions & 1 deletion json-schema/query_params.yaml
Expand Up @@ -224,13 +224,16 @@ $defs:
path:
type: string
format: json-pointer
ActiveOnly:
JSONSchemaDescriptions:
type: object
additionalProperties: false
properties:
active_only:
$ref: '#/$defs/boolean_string'
with_hardware_products:
$ref: '#/$defs/boolean_string'
default:
active_only: '0'
with_hardware_products: '0'

# vim: set sts=2 sw=2 et :
84 changes: 84 additions & 0 deletions json-schema/response.yaml
Expand Up @@ -1966,6 +1966,9 @@ $defs:
title: Deactivated
type: [ 'null', string ]
format: date-time
hardware_products:
title: Referenced by Hardware Products
$ref: '#/$defs/HardwareProducts'
if:
properties:
deactivated:
Expand All @@ -1974,5 +1977,86 @@ $defs:
properties:
latest:
const: false
HardwareJSONSchemaDescriptions:
type: array
uniqueItems: true
items:
type: object
additionalProperties: false
required:
- id
- $id
- description
- type
- name
- version
- latest
- created
- created_user
- added
- added_user
properties:
id:
title: ID
readOnly: true
$ref: common.yaml#/$defs/uuid
$id:
title: Canonical URI Identifier
readOnly: true
type: string
format: uri-reference
pattern: '^/json_schema/[A-Za-z0-9_-]+/[A-Za-z0-9_-]+/[0-9]+$'
description:
title: Description
type: string
type:
title: Type
readOnly: true
$ref: common.yaml#/$defs/json_pointer_token
name:
title: Name
readOnly: true
$ref: common.yaml#/$defs/json_pointer_token
version:
title: Version
readOnly: true
$ref: common.yaml#/$defs/positive_integer
latest:
title: Latest in Type-Name Series?
description: true when it is the latest of its type-name series
type: boolean
created:
title: Created
readOnly: true
type: string
format: date-time
created_user:
title: Created User
readOnly: true
$ref: '#/$defs/UserTerse'
added:
title: Added
readOnly: true
type: string
format: date-time
added_user:
title: Added User
readOnly: true
$ref: '#/$defs/UserTerse'
HardwareProductJSONSchemaDeleteError:
type: object
additionalProperties: false
required:
- error
- hardware_product_ids
properties:
error:
type: string
hardware_product_ids:
type: array
uniqueItems: true
minItems: 1
items:
$ref: common.yaml#/$defs/uuid

# vim: set sts=2 sw=2 et :

0 comments on commit 2a782a7

Please sign in to comment.