Skip to content

Commit

Permalink
editoast: work-schedules: add endpoints for easier edition and viewing
Browse files Browse the repository at this point in the history
Signed-off-by: Eloi Charpentier <eloi.charpentier.42@gmail.com>
  • Loading branch information
eckter committed Nov 20, 2024
1 parent 535d81d commit 8f1bb19
Show file tree
Hide file tree
Showing 4 changed files with 501 additions and 37 deletions.
183 changes: 183 additions & 0 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3059,6 +3059,105 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/WorkScheduleCreateResponse'
/work_schedules/group:
get:
tags:
- work_schedules
responses:
'201':
description: The existing work schedule group ids
content:
application/json:
schema:
type: array
items:
type: integer
format: int64
post:
tags:
- work_schedules
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/WorkScheduleGroupCreateForm'
required: true
responses:
'200':
description: The id of the created work schedule group
content:
application/json:
schema:
$ref: '#/components/schemas/WorkScheduleGroupCreateResponse'
/work_schedules/group/{id}:
get:
tags:
- work_schedules
parameters:
- name: id
in: path
description: A work schedule group ID
required: true
schema:
type: integer
format: int64
responses:
'200':
description: The work schedules in the group
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/WorkSchedule'
'404':
description: Work schedule group not found
put:
tags:
- work_schedules
parameters:
- name: id
in: path
description: A work schedule group ID
required: true
schema:
type: integer
format: int64
requestBody:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/WorkScheduleItemForm'
required: true
responses:
'200':
description: The work schedules have been created
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/WorkSchedule'
'404':
description: Work schedule group not found
delete:
tags:
- work_schedules
parameters:
- name: id
in: path
description: A work schedule group ID
required: true
schema:
type: integer
format: int64
responses:
'204':
description: The work schedule group has been deleted
'404':
description: The work schedule group does not exist
/work_schedules/project_path:
post:
tags:
Expand Down Expand Up @@ -4280,6 +4379,7 @@ components:
- $ref: '#/components/schemas/EditoastTrainScheduleErrorInfraNotFound'
- $ref: '#/components/schemas/EditoastTrainScheduleErrorNotFound'
- $ref: '#/components/schemas/EditoastWorkScheduleErrorNameAlreadyUsed'
- $ref: '#/components/schemas/EditoastWorkScheduleErrorWorkScheduleGroupNotFound'
description: Generated error type for Editoast
discriminator:
propertyName: type
Expand Down Expand Up @@ -5698,6 +5798,30 @@ components:
type: string
enum:
- editoast:work_schedule:NameAlreadyUsed
EditoastWorkScheduleErrorWorkScheduleGroupNotFound:
type: object
required:
- type
- status
- message
properties:
context:
type: object
required:
- id
properties:
id:
type: integer
message:
type: string
status:
type: integer
enum:
- 404
type:
type: string
enum:
- editoast:work_schedule:WorkScheduleGroupNotFound
EffortCurve:
type: object
required:
Expand Down Expand Up @@ -10744,6 +10868,37 @@ components:
type: string
enum:
- Detector
WorkSchedule:
type: object
required:
- id
- start_date_time
- end_date_time
- track_ranges
- obj_id
- work_schedule_type
- work_schedule_group_id
properties:
end_date_time:
type: string
format: date-time
id:
type: integer
format: int64
obj_id:
type: string
start_date_time:
type: string
format: date-time
track_ranges:
type: array
items:
$ref: '#/components/schemas/TrackRange'
work_schedule_group_id:
type: integer
format: int64
work_schedule_type:
$ref: '#/components/schemas/WorkScheduleType'
WorkScheduleCreateForm:
type: object
description: This structure is used by the post endpoint to create a work schedule
Expand All @@ -10765,6 +10920,29 @@ components:
work_schedule_group_id:
type: integer
format: int64
WorkScheduleGroupCreateForm:
type: object
properties:
work_schedule_group_name:
type: string
nullable: true
WorkScheduleGroupCreateResponse:
type: object
required:
- work_schedule_group_id
properties:
work_schedule_group_id:
type: integer
format: int64
WorkScheduleInGroupCreateForm:
type: object
required:
- work_schedules
properties:
work_schedules:
type: array
items:
$ref: '#/components/schemas/WorkScheduleItemForm'
WorkScheduleItemForm:
type: object
required:
Expand All @@ -10791,6 +10969,11 @@ components:
enum:
- CATENARY
- TRACK
WorkScheduleType:
type: string
enum:
- CATENARY
- TRACK
ZoneUpdate:
type: object
required:
Expand Down
4 changes: 2 additions & 2 deletions editoast/src/models/work_schedules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ pub enum WorkScheduleType {
Track,
}

#[derive(Debug, Default, Clone, Model)]
#[derive(Debug, Default, Clone, Model, Serialize, Deserialize, ToSchema)]
#[model(table = editoast_models::tables::work_schedule)]
#[model(gen(batch_ops = c, list))]
#[model(gen(batch_ops = cd, list))]
pub struct WorkSchedule {
pub id: i64,
pub start_date_time: DateTime<Utc>,
Expand Down
Loading

0 comments on commit 8f1bb19

Please sign in to comment.