OAPI: extract worker status request fields into their own struct

Instead of always passing `status_requested` and `lazy_status_request`
in tandem, and requiring one when the other is present, they are now
always passed as a struct `WorkerStatusChangeRequest`. This struct has
both fields required.

`WorkerStatusChangeRequest` already existed, and is now altered by changing
its field `status_requested` to simply `status` -- the fact that it's
requested is already clear from the context.
This commit is contained in:
Sybren A. Stüvel 2022-06-02 12:16:03 +02:00
parent ae6831ce6e
commit 169aa3ddc3

View File

@ -1392,12 +1392,8 @@ components:
description: Timestamp of last update description: Timestamp of last update
"status": { $ref: "#/components/schemas/WorkerStatus" } "status": { $ref: "#/components/schemas/WorkerStatus" }
"previous_status": { $ref: "#/components/schemas/WorkerStatus" } "previous_status": { $ref: "#/components/schemas/WorkerStatus" }
"status_requested": { $ref: "#/components/schemas/WorkerStatus" } "status_change":
"lazy_status_request": $ref: "#/components/schemas/WorkerStatusChangeRequest"
type: boolean
description: >
Whether the worker is allowed to finish its current task before the
status change is enforced. Mandatory when `status_requested` is set.
"version": { type: string } "version": { type: string }
required: [id, nickname, updated, status, version] required: [id, nickname, updated, status, version]
@ -1445,8 +1441,8 @@ components:
"id": { type: string, format: uuid } "id": { type: string, format: uuid }
"nickname": { type: string } "nickname": { type: string }
"status": { $ref: "#/components/schemas/WorkerStatus" } "status": { $ref: "#/components/schemas/WorkerStatus" }
"status_requested": { $ref: "#/components/schemas/WorkerStatus" } "status_change":
"lazy_status_request": { type: boolean } $ref: "#/components/schemas/WorkerStatusChangeRequest"
# These will be implemented soon: # These will be implemented soon:
# "task_id": # "task_id":
# type: string # type: string
@ -1486,15 +1482,15 @@ components:
WorkerStatusChangeRequest: WorkerStatusChangeRequest:
type: object type: object
description: Request for a Worker to change its status. description: Request for a Worker to change its status to `status`.
properties: properties:
"status_requested": { $ref: "#/components/schemas/WorkerStatus" } "status": { $ref: "#/components/schemas/WorkerStatus" }
"is_lazy": "is_lazy":
type: boolean type: boolean
description: > description: >
Whether the status change should happen immediately, or after the Whether the status change should happen immediately, or after the
worker's current task is finished. worker's current task is finished.
required: [status_requested, is_lazy] required: [status, is_lazy]
securitySchemes: securitySchemes:
worker_auth: worker_auth: