codetics-ocpp16 0.1.0

Codetics OCPP: OCPP 1.6 (OCPP-J) message types with validation and typed dispatch
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 Kevin Vavelin, Codetics (https://codetics.fr)

//! OCPP 1.6 request / response payloads.

use ocpp_core::DateTime;
use ocpp_core::validate::{self as v, Path, Validate, Violation};
use serde::{Deserialize, Serialize};

use crate::datatypes::*;
use crate::enums::*;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct AuthorizeRequest {
    #[serde(rename = "idTag")]
    pub id_tag: String,
}

impl Validate for AuthorizeRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        {
            let x = &self.id_tag;
            let p = path.field("idTag");
            v::max_length(x, 20, &p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct AuthorizeResponse {
    #[serde(rename = "idTagInfo")]
    pub id_tag_info: IdTagInfo,
}

impl Validate for AuthorizeResponse {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        {
            let x = &self.id_tag_info;
            let p = path.field("idTagInfo");
            x.validate(&p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct BootNotificationRequest {
    #[serde(rename = "chargePointVendor")]
    pub charge_point_vendor: String,
    #[serde(rename = "chargePointModel")]
    pub charge_point_model: String,
    #[serde(
        rename = "chargePointSerialNumber",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub charge_point_serial_number: Option<String>,
    #[serde(
        rename = "chargeBoxSerialNumber",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub charge_box_serial_number: Option<String>,
    #[serde(
        rename = "firmwareVersion",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub firmware_version: Option<String>,
    #[serde(rename = "iccid", default, skip_serializing_if = "Option::is_none")]
    pub iccid: Option<String>,
    #[serde(rename = "imsi", default, skip_serializing_if = "Option::is_none")]
    pub imsi: Option<String>,
    #[serde(rename = "meterType", default, skip_serializing_if = "Option::is_none")]
    pub meter_type: Option<String>,
    #[serde(
        rename = "meterSerialNumber",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub meter_serial_number: Option<String>,
}

impl Validate for BootNotificationRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        {
            let x = &self.charge_point_vendor;
            let p = path.field("chargePointVendor");
            v::max_length(x, 20, &p)?;
        }
        {
            let x = &self.charge_point_model;
            let p = path.field("chargePointModel");
            v::max_length(x, 20, &p)?;
        }
        if let Some(x) = &self.charge_point_serial_number {
            let p = path.field("chargePointSerialNumber");
            v::max_length(x, 25, &p)?;
        }
        if let Some(x) = &self.charge_box_serial_number {
            let p = path.field("chargeBoxSerialNumber");
            v::max_length(x, 25, &p)?;
        }
        if let Some(x) = &self.firmware_version {
            let p = path.field("firmwareVersion");
            v::max_length(x, 50, &p)?;
        }
        if let Some(x) = &self.iccid {
            let p = path.field("iccid");
            v::max_length(x, 20, &p)?;
        }
        if let Some(x) = &self.imsi {
            let p = path.field("imsi");
            v::max_length(x, 20, &p)?;
        }
        if let Some(x) = &self.meter_type {
            let p = path.field("meterType");
            v::max_length(x, 25, &p)?;
        }
        if let Some(x) = &self.meter_serial_number {
            let p = path.field("meterSerialNumber");
            v::max_length(x, 25, &p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct BootNotificationResponse {
    #[serde(rename = "status")]
    pub status: RegistrationStatus,
    #[serde(rename = "currentTime")]
    pub current_time: DateTime,
    #[serde(rename = "interval")]
    pub interval: i64,
}

impl Validate for BootNotificationResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct CancelReservationRequest {
    #[serde(rename = "reservationId")]
    pub reservation_id: i64,
}

impl Validate for CancelReservationRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct CancelReservationResponse {
    #[serde(rename = "status")]
    pub status: CancelReservationStatus,
}

impl Validate for CancelReservationResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ChangeAvailabilityRequest {
    #[serde(rename = "connectorId")]
    pub connector_id: i64,
    #[serde(rename = "type")]
    pub r#type: AvailabilityType,
}

impl Validate for ChangeAvailabilityRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ChangeAvailabilityResponse {
    #[serde(rename = "status")]
    pub status: AvailabilityStatus,
}

impl Validate for ChangeAvailabilityResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ChangeConfigurationRequest {
    #[serde(rename = "key")]
    pub key: String,
    #[serde(rename = "value")]
    pub value: String,
}

impl Validate for ChangeConfigurationRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        {
            let x = &self.key;
            let p = path.field("key");
            v::max_length(x, 50, &p)?;
        }
        {
            let x = &self.value;
            let p = path.field("value");
            v::max_length(x, 500, &p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ChangeConfigurationResponse {
    #[serde(rename = "status")]
    pub status: ConfigurationStatus,
}

impl Validate for ChangeConfigurationResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ClearCacheRequest {}

impl Validate for ClearCacheRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ClearCacheResponse {
    #[serde(rename = "status")]
    pub status: ClearCacheStatus,
}

impl Validate for ClearCacheResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ClearChargingProfileRequest {
    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
    pub id: Option<i64>,
    #[serde(
        rename = "connectorId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub connector_id: Option<i64>,
    #[serde(
        rename = "chargingProfilePurpose",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub charging_profile_purpose: Option<ChargingProfilePurposeType>,
    #[serde(
        rename = "stackLevel",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub stack_level: Option<i64>,
}

impl Validate for ClearChargingProfileRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ClearChargingProfileResponse {
    #[serde(rename = "status")]
    pub status: ClearChargingProfileStatus,
}

impl Validate for ClearChargingProfileResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct DataTransferRequest {
    #[serde(rename = "vendorId")]
    pub vendor_id: String,
    #[serde(rename = "messageId", default, skip_serializing_if = "Option::is_none")]
    pub message_id: Option<String>,
    #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
    pub data: Option<String>,
}

impl Validate for DataTransferRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        {
            let x = &self.vendor_id;
            let p = path.field("vendorId");
            v::max_length(x, 255, &p)?;
        }
        if let Some(x) = &self.message_id {
            let p = path.field("messageId");
            v::max_length(x, 50, &p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct DataTransferResponse {
    #[serde(rename = "status")]
    pub status: DataTransferStatus,
    #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
    pub data: Option<String>,
}

impl Validate for DataTransferResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct DiagnosticsStatusNotificationRequest {
    #[serde(rename = "status")]
    pub status: DiagnosticsStatus,
}

impl Validate for DiagnosticsStatusNotificationRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct DiagnosticsStatusNotificationResponse {}

impl Validate for DiagnosticsStatusNotificationResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct FirmwareStatusNotificationRequest {
    #[serde(rename = "status")]
    pub status: FirmwareStatus,
}

impl Validate for FirmwareStatusNotificationRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct FirmwareStatusNotificationResponse {}

impl Validate for FirmwareStatusNotificationResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct GetCompositeScheduleRequest {
    #[serde(rename = "connectorId")]
    pub connector_id: i64,
    #[serde(rename = "duration")]
    pub duration: i64,
    #[serde(
        rename = "chargingRateUnit",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub charging_rate_unit: Option<ChargingRateUnitType>,
}

impl Validate for GetCompositeScheduleRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct GetCompositeScheduleResponse {
    #[serde(rename = "status")]
    pub status: GetCompositeScheduleStatus,
    #[serde(
        rename = "connectorId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub connector_id: Option<i64>,
    #[serde(
        rename = "scheduleStart",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub schedule_start: Option<DateTime>,
    #[serde(
        rename = "chargingSchedule",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub charging_schedule: Option<ChargingSchedule>,
}

impl Validate for GetCompositeScheduleResponse {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        if let Some(x) = &self.charging_schedule {
            let p = path.field("chargingSchedule");
            x.validate(&p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct GetConfigurationRequest {
    #[serde(rename = "key", default, skip_serializing_if = "Option::is_none")]
    pub key: Option<Vec<String>>,
}

impl Validate for GetConfigurationRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        if let Some(x) = &self.key {
            let p = path.field("key");
            for (i0, it0) in x.iter().enumerate() {
                let p0 = p.index(i0);
                v::max_length(it0, 50, &p0)?;
            }
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct GetConfigurationResponse {
    #[serde(
        rename = "configurationKey",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub configuration_key: Option<Vec<KeyValue>>,
    #[serde(
        rename = "unknownKey",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub unknown_key: Option<Vec<String>>,
}

impl Validate for GetConfigurationResponse {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        if let Some(x) = &self.configuration_key {
            let p = path.field("configurationKey");
            for (i0, it0) in x.iter().enumerate() {
                let p0 = p.index(i0);
                it0.validate(&p0)?;
            }
        }
        if let Some(x) = &self.unknown_key {
            let p = path.field("unknownKey");
            for (i0, it0) in x.iter().enumerate() {
                let p0 = p.index(i0);
                v::max_length(it0, 50, &p0)?;
            }
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct GetDiagnosticsRequest {
    #[serde(rename = "location")]
    pub location: String,
    #[serde(rename = "retries", default, skip_serializing_if = "Option::is_none")]
    pub retries: Option<i64>,
    #[serde(
        rename = "retryInterval",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub retry_interval: Option<i64>,
    #[serde(rename = "startTime", default, skip_serializing_if = "Option::is_none")]
    pub start_time: Option<DateTime>,
    #[serde(rename = "stopTime", default, skip_serializing_if = "Option::is_none")]
    pub stop_time: Option<DateTime>,
}

impl Validate for GetDiagnosticsRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct GetDiagnosticsResponse {
    #[serde(rename = "fileName", default, skip_serializing_if = "Option::is_none")]
    pub file_name: Option<String>,
}

impl Validate for GetDiagnosticsResponse {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        if let Some(x) = &self.file_name {
            let p = path.field("fileName");
            v::max_length(x, 255, &p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct GetLocalListVersionRequest {}

impl Validate for GetLocalListVersionRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct GetLocalListVersionResponse {
    #[serde(rename = "listVersion")]
    pub list_version: i64,
}

impl Validate for GetLocalListVersionResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct HeartbeatRequest {}

impl Validate for HeartbeatRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct HeartbeatResponse {
    #[serde(rename = "currentTime")]
    pub current_time: DateTime,
}

impl Validate for HeartbeatResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct MeterValuesRequest {
    #[serde(rename = "connectorId")]
    pub connector_id: i64,
    #[serde(
        rename = "transactionId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub transaction_id: Option<i64>,
    #[serde(rename = "meterValue")]
    pub meter_value: Vec<MeterValue>,
}

impl Validate for MeterValuesRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct MeterValuesResponse {}

impl Validate for MeterValuesResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct RemoteStartTransactionRequest {
    #[serde(
        rename = "connectorId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub connector_id: Option<i64>,
    #[serde(rename = "idTag")]
    pub id_tag: String,
    #[serde(
        rename = "chargingProfile",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub charging_profile: Option<ChargingProfile>,
}

impl Validate for RemoteStartTransactionRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        {
            let x = &self.id_tag;
            let p = path.field("idTag");
            v::max_length(x, 20, &p)?;
        }
        if let Some(x) = &self.charging_profile {
            let p = path.field("chargingProfile");
            x.validate(&p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct RemoteStartTransactionResponse {
    #[serde(rename = "status")]
    pub status: RemoteStartStopStatus,
}

impl Validate for RemoteStartTransactionResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct RemoteStopTransactionRequest {
    #[serde(rename = "transactionId")]
    pub transaction_id: i64,
}

impl Validate for RemoteStopTransactionRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct RemoteStopTransactionResponse {
    #[serde(rename = "status")]
    pub status: RemoteStartStopStatus,
}

impl Validate for RemoteStopTransactionResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ReserveNowRequest {
    #[serde(rename = "connectorId")]
    pub connector_id: i64,
    #[serde(rename = "expiryDate")]
    pub expiry_date: DateTime,
    #[serde(rename = "idTag")]
    pub id_tag: String,
    #[serde(
        rename = "parentIdTag",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub parent_id_tag: Option<String>,
    #[serde(rename = "reservationId")]
    pub reservation_id: i64,
}

impl Validate for ReserveNowRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        {
            let x = &self.id_tag;
            let p = path.field("idTag");
            v::max_length(x, 20, &p)?;
        }
        if let Some(x) = &self.parent_id_tag {
            let p = path.field("parentIdTag");
            v::max_length(x, 20, &p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ReserveNowResponse {
    #[serde(rename = "status")]
    pub status: ReservationStatus,
}

impl Validate for ReserveNowResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ResetRequest {
    #[serde(rename = "type")]
    pub r#type: ResetType,
}

impl Validate for ResetRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ResetResponse {
    #[serde(rename = "status")]
    pub status: ResetStatus,
}

impl Validate for ResetResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct SendLocalListRequest {
    #[serde(rename = "listVersion")]
    pub list_version: i64,
    #[serde(
        rename = "localAuthorizationList",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub local_authorization_list: Option<Vec<AuthorizationData>>,
    #[serde(rename = "updateType")]
    pub update_type: UpdateType,
}

impl Validate for SendLocalListRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        if let Some(x) = &self.local_authorization_list {
            let p = path.field("localAuthorizationList");
            for (i0, it0) in x.iter().enumerate() {
                let p0 = p.index(i0);
                it0.validate(&p0)?;
            }
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct SendLocalListResponse {
    #[serde(rename = "status")]
    pub status: UpdateStatus,
}

impl Validate for SendLocalListResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct SetChargingProfileRequest {
    #[serde(rename = "connectorId")]
    pub connector_id: i64,
    #[serde(rename = "csChargingProfiles")]
    pub cs_charging_profiles: ChargingProfile,
}

impl Validate for SetChargingProfileRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        {
            let x = &self.cs_charging_profiles;
            let p = path.field("csChargingProfiles");
            x.validate(&p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct SetChargingProfileResponse {
    #[serde(rename = "status")]
    pub status: ChargingProfileStatus,
}

impl Validate for SetChargingProfileResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct StartTransactionRequest {
    #[serde(rename = "connectorId")]
    pub connector_id: i64,
    #[serde(rename = "idTag")]
    pub id_tag: String,
    #[serde(rename = "meterStart")]
    pub meter_start: i64,
    #[serde(
        rename = "reservationId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub reservation_id: Option<i64>,
    #[serde(rename = "timestamp")]
    pub timestamp: DateTime,
}

impl Validate for StartTransactionRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        {
            let x = &self.id_tag;
            let p = path.field("idTag");
            v::max_length(x, 20, &p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct StartTransactionResponse {
    #[serde(rename = "idTagInfo")]
    pub id_tag_info: IdTagInfo,
    #[serde(rename = "transactionId")]
    pub transaction_id: i64,
}

impl Validate for StartTransactionResponse {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        {
            let x = &self.id_tag_info;
            let p = path.field("idTagInfo");
            x.validate(&p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct StatusNotificationRequest {
    #[serde(rename = "connectorId")]
    pub connector_id: i64,
    #[serde(rename = "errorCode")]
    pub error_code: ChargePointErrorCode,
    #[serde(rename = "info", default, skip_serializing_if = "Option::is_none")]
    pub info: Option<String>,
    #[serde(rename = "status")]
    pub status: ChargePointStatus,
    #[serde(rename = "timestamp", default, skip_serializing_if = "Option::is_none")]
    pub timestamp: Option<DateTime>,
    #[serde(rename = "vendorId", default, skip_serializing_if = "Option::is_none")]
    pub vendor_id: Option<String>,
    #[serde(
        rename = "vendorErrorCode",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub vendor_error_code: Option<String>,
}

impl Validate for StatusNotificationRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        if let Some(x) = &self.info {
            let p = path.field("info");
            v::max_length(x, 50, &p)?;
        }
        if let Some(x) = &self.vendor_id {
            let p = path.field("vendorId");
            v::max_length(x, 255, &p)?;
        }
        if let Some(x) = &self.vendor_error_code {
            let p = path.field("vendorErrorCode");
            v::max_length(x, 50, &p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct StatusNotificationResponse {}

impl Validate for StatusNotificationResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct StopTransactionRequest {
    #[serde(rename = "idTag", default, skip_serializing_if = "Option::is_none")]
    pub id_tag: Option<String>,
    #[serde(rename = "meterStop")]
    pub meter_stop: i64,
    #[serde(rename = "timestamp")]
    pub timestamp: DateTime,
    #[serde(rename = "transactionId")]
    pub transaction_id: i64,
    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
    pub reason: Option<Reason>,
    #[serde(
        rename = "transactionData",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub transaction_data: Option<Vec<MeterValue>>,
}

impl Validate for StopTransactionRequest {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        if let Some(x) = &self.id_tag {
            let p = path.field("idTag");
            v::max_length(x, 20, &p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct StopTransactionResponse {
    #[serde(rename = "idTagInfo", default, skip_serializing_if = "Option::is_none")]
    pub id_tag_info: Option<IdTagInfo>,
}

impl Validate for StopTransactionResponse {
    fn validate(&self, path: &Path<'_>) -> Result<(), Violation> {
        if let Some(x) = &self.id_tag_info {
            let p = path.field("idTagInfo");
            x.validate(&p)?;
        }
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct TriggerMessageRequest {
    #[serde(rename = "requestedMessage")]
    pub requested_message: MessageTrigger,
    #[serde(
        rename = "connectorId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub connector_id: Option<i64>,
}

impl Validate for TriggerMessageRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct TriggerMessageResponse {
    #[serde(rename = "status")]
    pub status: TriggerMessageStatus,
}

impl Validate for TriggerMessageResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct UnlockConnectorRequest {
    #[serde(rename = "connectorId")]
    pub connector_id: i64,
}

impl Validate for UnlockConnectorRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct UnlockConnectorResponse {
    #[serde(rename = "status")]
    pub status: UnlockStatus,
}

impl Validate for UnlockConnectorResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct UpdateFirmwareRequest {
    #[serde(rename = "location")]
    pub location: String,
    #[serde(rename = "retries", default, skip_serializing_if = "Option::is_none")]
    pub retries: Option<i64>,
    #[serde(rename = "retrieveDate")]
    pub retrieve_date: DateTime,
    #[serde(
        rename = "retryInterval",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub retry_interval: Option<i64>,
}

impl Validate for UpdateFirmwareRequest {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct UpdateFirmwareResponse {}

impl Validate for UpdateFirmwareResponse {
    fn validate(&self, _path: &Path<'_>) -> Result<(), Violation> {
        Ok(())
    }
}