openapi: 3.2.0 info: title: COS registration server Devices API version: '1' description: COS registration server API documentation tags: - name: Devices paths: /api/v1/devices/: get: operationId: devices_list description: List all registered devices and their attribute summary: List devices parameters: - in: query name: fields schema: type: string description: 'Filter the fields provided.Will only output the fields listed in the parameter.Example: ?fields=uid,create_date' tags: - Devices security: - {} responses: '200': content: application/json: schema: type: array items: $ref: '#/components/schemas/Device' description: '' post: operationId: devices_create description: Register a device by its ID summary: Register a device tags: - Devices requestBody: content: application/json: schema: $ref: '#/components/schemas/Device' application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/Device' required: true security: - {} responses: '201': content: application/json: schema: $ref: '#/components/schemas/Device' description: '' '400': content: application/json: schema: type: string examples: DateParseError: value: field_name: error details summary: Date parse error description: '' /api/v1/devices/{uid}/: get: operationId: devices_retrieve description: Retrieve all the fields of a device by its ID summary: Get a device parameters: - in: path name: uid schema: type: string required: true tags: - Devices security: - {} responses: '200': content: application/json: schema: $ref: '#/components/schemas/Device' description: '' '404': description: UID not found put: operationId: devices_update description: Update all the fields of a given device summary: Update a device completely parameters: - in: path name: uid schema: type: string required: true tags: - Devices requestBody: content: application/json: schema: $ref: '#/components/schemas/Device' application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/Device' required: true security: - {} responses: '201': content: application/json: schema: $ref: '#/components/schemas/Device' description: '' '400': content: application/json: schema: type: string examples: DateParseError: value: field_name: error details summary: Date parse error description: '' '404': description: UID not found patch: operationId: devices_partial_update description: Update the provided fields of a given device summary: Update a device partially parameters: - in: path name: uid schema: type: string required: true tags: - Devices requestBody: content: application/json: schema: $ref: '#/components/schemas/PatchedDevice' application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/PatchedDevice' security: - {} responses: '201': content: application/json: schema: $ref: '#/components/schemas/Device' description: '' '400': content: application/json: schema: type: string examples: DateParseError: value: field_name: error details summary: Date parse error description: '' '404': description: UID not found delete: operationId: devices_destroy description: Delete a registered device summary: Delete a device parameters: - in: path name: uid schema: type: string required: true tags: - Devices security: - {} responses: '204': content: application/json: schema: $ref: '#/components/schemas/Device' description: '' '404': description: UID not found /api/v1/devices/{uid}/certificate/: get: operationId: devices_certificate_retrieve description: Retrieve the status of the certificate request and the signed certificate if available. summary: Check certificate signing status parameters: - in: path name: uid schema: type: string required: true tags: - Devices security: - {} responses: '200': content: application/json: schema: $ref: '#/components/schemas/DeviceCertificate' description: Certificate status retrieved '404': description: UID not found post: operationId: devices_certificate_create description: Submit a CSR for the device. The server stores it and marks status as pending. summary: Submit a Certificate Signing Request (CSR) parameters: - in: path name: uid schema: type: string required: true tags: - Devices requestBody: content: application/json: schema: $ref: '#/components/schemas/DeviceCertificate' application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/DeviceCertificate' required: true security: - {} responses: '202': description: CSR accepted for processing '400': description: Invalid CSR format '404': description: UID not found patch: operationId: devices_certificate_partial_update description: Internal endpoint for the charm to update certificate status and provide signed certificate. summary: Update certificate status (internal use) parameters: - in: path name: uid schema: type: string required: true tags: - Devices requestBody: content: application/json: schema: $ref: '#/components/schemas/PatchedDeviceCertificate' application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/PatchedDeviceCertificate' security: - {} responses: '200': content: application/json: schema: $ref: '#/components/schemas/DeviceCertificate' description: Certificate updated successfully '400': description: Invalid request data '404': description: Device not found components: schemas: Device: type: object description: Device Serializer class. properties: uid: type: string maxLength: 200 creation_date: type: string format: date-time readOnly: true address: type: string title: Device IP public_ssh_key: type: string title: Device public SSH key grafana_dashboards: type: array items: type: string foxglove_dashboards: type: array items: type: string prometheus_alert_rule_files: type: array items: type: string loki_alert_rule_files: type: array items: type: string certificate: allOf: - $ref: '#/components/schemas/DeviceCertificate' readOnly: true required: - address - certificate - creation_date - uid PatchedDevice: type: object description: Device Serializer class. properties: uid: type: string maxLength: 200 creation_date: type: string format: date-time readOnly: true address: type: string title: Device IP public_ssh_key: type: string title: Device public SSH key grafana_dashboards: type: array items: type: string foxglove_dashboards: type: array items: type: string prometheus_alert_rule_files: type: array items: type: string loki_alert_rule_files: type: array items: type: string certificate: allOf: - $ref: '#/components/schemas/DeviceCertificate' readOnly: true StatusEnum: enum: - pending - signed - denied type: string description: '* `pending` - Pending * `signed` - Signed * `denied` - Denied' PatchedDeviceCertificate: type: object description: Device Certificate Serializer class. properties: csr: type: string title: Device Certificate Signing Request certificate: type: string title: Signed Device Certificate ca: type: string title: Device Certificate Authority chain: type: string title: Device Certificate Chain status: oneOf: - $ref: '#/components/schemas/StatusEnum' - $ref: '#/components/schemas/BlankEnum' created_at: type: string format: date-time readOnly: true title: Device Certificate request created updated_at: type: string format: date-time readOnly: true title: Device Certificate last updated BlankEnum: enum: - '' DeviceCertificate: type: object description: Device Certificate Serializer class. properties: csr: type: string title: Device Certificate Signing Request certificate: type: string title: Signed Device Certificate ca: type: string title: Device Certificate Authority chain: type: string title: Device Certificate Chain status: oneOf: - $ref: '#/components/schemas/StatusEnum' - $ref: '#/components/schemas/BlankEnum' created_at: type: string format: date-time readOnly: true title: Device Certificate request created updated_at: type: string format: date-time readOnly: true title: Device Certificate last updated required: - created_at - csr - updated_at