Skip to content

Commit

Permalink
Remove MainDevicesValidator and use separated keys instead
Browse files Browse the repository at this point in the history
  • Loading branch information
nadzyah committed Jan 26, 2024
1 parent dc25bcd commit 247c19b
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 135 deletions.
4 changes: 4 additions & 0 deletions server/hwapi/endpoints/certification/certification.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@
),
)
def check_certification(system_info: CertificationStatusRequest):
"""
Endpoint for checking certification status (whether a system is certified, not seen
or some of its components have been seen on other systems)
"""
raise NotImplementedError("The endpoint is not implemented yet")
44 changes: 14 additions & 30 deletions server/hwapi/endpoints/certification/rbody_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,42 +39,21 @@
)


class MainDevicesRequest(BaseModel):
"""
Validator for the following devices that can be included into the request body
"""

processor: ProcessorValidator
gpu: GPUValidator | None
network: list[NetworkAdapterValidator] | None
wireless: list[WirelessAdapterValidator] | None
audio: list[AudioValidator] | None
video: list[VideoCaptureValidator] | None


class CertificationStatusRequest(BaseModel):
"""Request body validator for status check endpoint"""

os: OSValidator | None
bios: BiosValidator | None
board: BoardValidator | None
chassis: ChassisValidator | None
main_devices: MainDevicesRequest | None
pci_peripherals: list[PCIPeripheralValidator]
usb_peripherals: list[USBPeripheralValidator]


class MainDevicesResponse(BaseModel):
"""
Validator for the "main" devices that can be included into the response body.
All of them are marked optional since some of them may not be presented
in the list of seen/tested/certified devices
"""

processor: ProcessorValidator | None
gpu: GPUValidator | None
network: list[NetworkAdapterValidator] | None
wireless: list[WirelessAdapterValidator] | None
processor: list[ProcessorValidator]
gpu: list[GPUValidator] | None
audio: list[AudioValidator] | None
video: list[VideoCaptureValidator] | None
network: list[NetworkAdapterValidator] | None
wireless: list[WirelessAdapterValidator] | None
pci_peripherals: list[PCIPeripheralValidator]
usb_peripherals: list[USBPeripheralValidator]


class CertifiedResponse(BaseModel):
Expand All @@ -101,6 +80,11 @@ class RelatedCertifiedSystemExistsResponse(BaseModel):
status: Literal[CertificationStatus.PARTIALLY_CERTIFIED]
board: BoardValidator
chassis: ChassisValidator | None = None
main_devices: MainDevicesResponse | None = None
processor: list[ProcessorValidator] | None = None
gpu: list[GPUValidator] | None = None
audio: list[AudioValidator] | None = None
video: list[VideoCaptureValidator] | None = None
network: list[NetworkAdapterValidator] | None = None
wireless: list[WirelessAdapterValidator] | None = None
pci_peripherals: list[PCIPeripheralValidator] | None = None
usb_peripherals: list[USBPeripheralValidator] | None = None
194 changes: 89 additions & 105 deletions server/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ components:
title: BoardValidator
type: object
CertificationStatusRequest:
description: Request body validator for status check endpoint
properties:
audio:
anyOf:
- items:
$ref: '#/components/schemas/AudioValidator'
type: array
- type: 'null'
title: Audio
bios:
anyOf:
- $ref: '#/components/schemas/BiosValidator'
Expand All @@ -71,10 +79,20 @@ components:
anyOf:
- $ref: '#/components/schemas/ChassisValidator'
- type: 'null'
main_devices:
gpu:
anyOf:
- $ref: '#/components/schemas/MainDevicesRequest'
- items:
$ref: '#/components/schemas/GPUValidator'
type: array
- type: 'null'
title: Gpu
network:
anyOf:
- items:
$ref: '#/components/schemas/NetworkAdapterValidator'
type: array
- type: 'null'
title: Network
os:
anyOf:
- $ref: '#/components/schemas/OSValidator'
Expand All @@ -84,17 +102,41 @@ components:
$ref: '#/components/schemas/PCIPeripheralValidator'
title: Pci Peripherals
type: array
processor:
items:
$ref: '#/components/schemas/ProcessorValidator'
title: Processor
type: array
usb_peripherals:
items:
$ref: '#/components/schemas/USBPeripheralValidator'
title: Usb Peripherals
type: array
video:
anyOf:
- items:
$ref: '#/components/schemas/VideoCaptureValidator'
type: array
- type: 'null'
title: Video
wireless:
anyOf:
- items:
$ref: '#/components/schemas/WirelessAdapterValidator'
type: array
- type: 'null'
title: Wireless
required:
- os
- bios
- board
- chassis
- main_devices
- processor
- gpu
- audio
- video
- network
- wireless
- pci_peripherals
- usb_peripherals
title: CertificationStatusRequest
Expand Down Expand Up @@ -182,106 +224,6 @@ components:
- signature
title: KernelPackageValidator
type: object
MainDevicesRequest:
description: Validator for the following devices that can be included into the
request body
properties:
audio:
anyOf:
- items:
$ref: '#/components/schemas/AudioValidator'
type: array
- type: 'null'
title: Audio
gpu:
anyOf:
- $ref: '#/components/schemas/GPUValidator'
- type: 'null'
network:
anyOf:
- items:
$ref: '#/components/schemas/NetworkAdapterValidator'
type: array
- type: 'null'
title: Network
processor:
$ref: '#/components/schemas/ProcessorValidator'
video:
anyOf:
- items:
$ref: '#/components/schemas/VideoCaptureValidator'
type: array
- type: 'null'
title: Video
wireless:
anyOf:
- items:
$ref: '#/components/schemas/WirelessAdapterValidator'
type: array
- type: 'null'
title: Wireless
required:
- processor
- gpu
- network
- wireless
- audio
- video
title: MainDevicesRequest
type: object
MainDevicesResponse:
description: 'Validator for the "main" devices that can be included into the
response body.
All of them are marked optional since some of them may not be presented
in the list of seen/tested/certified devices'
properties:
audio:
anyOf:
- items:
$ref: '#/components/schemas/AudioValidator'
type: array
- type: 'null'
title: Audio
gpu:
anyOf:
- $ref: '#/components/schemas/GPUValidator'
- type: 'null'
network:
anyOf:
- items:
$ref: '#/components/schemas/NetworkAdapterValidator'
type: array
- type: 'null'
title: Network
processor:
anyOf:
- $ref: '#/components/schemas/ProcessorValidator'
- type: 'null'
video:
anyOf:
- items:
$ref: '#/components/schemas/VideoCaptureValidator'
type: array
- type: 'null'
title: Video
wireless:
anyOf:
- items:
$ref: '#/components/schemas/WirelessAdapterValidator'
type: array
- type: 'null'
title: Wireless
required:
- processor
- gpu
- network
- wireless
- audio
- video
title: MainDevicesResponse
type: object
NetworkAdapterValidator:
description: Validator for ethernet network adapters
properties:
Expand Down Expand Up @@ -391,23 +333,47 @@ components:
were tested on other systems that the machine has'
properties:
audio:
anyOf:
- items:
$ref: '#/components/schemas/AudioValidator'
type: array
- type: 'null'
title: Audio
board:
$ref: '#/components/schemas/BoardValidator'
chassis:
anyOf:
- $ref: '#/components/schemas/ChassisValidator'
- type: 'null'
main_devices:
gpu:
anyOf:
- items:
$ref: '#/components/schemas/GPUValidator'
type: array
- type: 'null'
title: Gpu
network:
anyOf:
- $ref: '#/components/schemas/MainDevicesResponse'
- items:
$ref: '#/components/schemas/NetworkAdapterValidator'
type: array
- type: 'null'
title: Network
pci_peripherals:
anyOf:
- items:
$ref: '#/components/schemas/PCIPeripheralValidator'
type: array
- type: 'null'
title: Pci Peripherals
processor:
anyOf:
- items:
$ref: '#/components/schemas/ProcessorValidator'
type: array
- type: 'null'
title: Processor
status:
const: Partially Certified
title: Status
Expand All @@ -418,6 +384,20 @@ components:
type: array
- type: 'null'
title: Usb Peripherals
video:
anyOf:
- items:
$ref: '#/components/schemas/VideoCaptureValidator'
type: array
- type: 'null'
title: Video
wireless:
anyOf:
- items:
$ref: '#/components/schemas/WirelessAdapterValidator'
type: array
- type: 'null'
title: Wireless
required:
- status
- board
Expand Down Expand Up @@ -507,6 +487,10 @@ paths:
summary: Root
/v1/certification/status:
post:
description: 'Endpoint for checking certification status (whether a system is
certified, not seen
or some of its components have been seen on other systems)'
operationId: check_certification_v1_certification_status_post
requestBody:
content:
Expand Down

0 comments on commit 247c19b

Please sign in to comment.