-
Notifications
You must be signed in to change notification settings - Fork 22
/
api.gen.go
998 lines (814 loc) · 36.1 KB
/
api.gen.go
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
// Package api provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.13.0 DO NOT EDIT.
package api
import (
"bytes"
"compress/gzip"
"encoding/base64"
"fmt"
"net/http"
"net/url"
"path"
"strings"
"time"
"github.com/deepmap/oapi-codegen/pkg/runtime"
"github.com/getkin/kin-openapi/openapi3"
"github.com/go-chi/chi/v5"
)
// Defines values for ChargeStationInstallCertificatesCertificatesStatus.
const (
Accepted ChargeStationInstallCertificatesCertificatesStatus = "Accepted"
Pending ChargeStationInstallCertificatesCertificatesStatus = "Pending"
Rejected ChargeStationInstallCertificatesCertificatesStatus = "Rejected"
)
// Defines values for ChargeStationInstallCertificatesCertificatesType.
const (
CSMS ChargeStationInstallCertificatesCertificatesType = "CSMS"
MF ChargeStationInstallCertificatesCertificatesType = "MF"
MO ChargeStationInstallCertificatesCertificatesType = "MO"
V2G ChargeStationInstallCertificatesCertificatesType = "V2G"
)
// Defines values for ChargeStationTriggerTrigger.
const (
BootNotification ChargeStationTriggerTrigger = "BootNotification"
SignChargingStationCertificate ChargeStationTriggerTrigger = "SignChargingStationCertificate"
SignCombinedCertificate ChargeStationTriggerTrigger = "SignCombinedCertificate"
SignV2GCertificate ChargeStationTriggerTrigger = "SignV2GCertificate"
StatusNotification ChargeStationTriggerTrigger = "StatusNotification"
)
// Defines values for ConnectorFormat.
const (
CABLE ConnectorFormat = "CABLE"
SOCKET ConnectorFormat = "SOCKET"
)
// Defines values for ConnectorPowerType.
const (
AC1PHASE ConnectorPowerType = "AC_1_PHASE"
AC3PHASE ConnectorPowerType = "AC_3_PHASE"
DC ConnectorPowerType = "DC"
)
// Defines values for ConnectorStandard.
const (
CHADEMO ConnectorStandard = "CHADEMO"
CHAOJI ConnectorStandard = "CHAOJI"
DOMESTICA ConnectorStandard = "DOMESTIC_A"
DOMESTICB ConnectorStandard = "DOMESTIC_B"
DOMESTICC ConnectorStandard = "DOMESTIC_C"
DOMESTICD ConnectorStandard = "DOMESTIC_D"
DOMESTICE ConnectorStandard = "DOMESTIC_E"
DOMESTICF ConnectorStandard = "DOMESTIC_F"
DOMESTICG ConnectorStandard = "DOMESTIC_G"
DOMESTICH ConnectorStandard = "DOMESTIC_H"
DOMESTICI ConnectorStandard = "DOMESTIC_I"
DOMESTICJ ConnectorStandard = "DOMESTIC_J"
DOMESTICK ConnectorStandard = "DOMESTIC_K"
DOMESTICL ConnectorStandard = "DOMESTIC_L"
GBTAC ConnectorStandard = "GBT_AC"
GBTDC ConnectorStandard = "GBT_DC"
IEC603092Single16 ConnectorStandard = "IEC_60309_2_single_16"
IEC603092Three16 ConnectorStandard = "IEC_60309_2_three_16"
IEC603092Three32 ConnectorStandard = "IEC_60309_2_three_32"
IEC603092Three64 ConnectorStandard = "IEC_60309_2_three_64"
IEC62196T1 ConnectorStandard = "IEC_62196_T1"
IEC62196T1COMBO ConnectorStandard = "IEC_62196_T1_COMBO"
IEC62196T2 ConnectorStandard = "IEC_62196_T2"
IEC62196T2COMBO ConnectorStandard = "IEC_62196_T2_COMBO"
IEC62196T3A ConnectorStandard = "IEC_62196_T3A"
IEC62196T3C ConnectorStandard = "IEC_62196_T3C"
NEMA1030 ConnectorStandard = "NEMA_10_30"
NEMA1050 ConnectorStandard = "NEMA_10_50"
NEMA1430 ConnectorStandard = "NEMA_14_30"
NEMA1450 ConnectorStandard = "NEMA_14_50"
NEMA520 ConnectorStandard = "NEMA_5_20"
NEMA630 ConnectorStandard = "NEMA_6_30"
NEMA650 ConnectorStandard = "NEMA_6_50"
PANTOGRAPHBOTTOMUP ConnectorStandard = "PANTOGRAPH_BOTTOM_UP"
PANTOGRAPHTOPDOWN ConnectorStandard = "PANTOGRAPH_TOP_DOWN"
TESLAR ConnectorStandard = "TESLA_R"
TESLAS ConnectorStandard = "TESLA_S"
UNKNOWN ConnectorStandard = "UNKNOWN"
)
// Defines values for LocationParkingType.
const (
ALONGMOTORWAY LocationParkingType = "ALONG_MOTORWAY"
ONDRIVEWAY LocationParkingType = "ON_DRIVEWAY"
ONSTREET LocationParkingType = "ON_STREET"
PARKINGGARAGE LocationParkingType = "PARKING_GARAGE"
PARKINGLOT LocationParkingType = "PARKING_LOT"
UNDERGROUNDGARAGE LocationParkingType = "UNDERGROUND_GARAGE"
)
// Defines values for RegistrationStatus.
const (
PENDING RegistrationStatus = "PENDING"
REGISTERED RegistrationStatus = "REGISTERED"
)
// Defines values for TokenCacheMode.
const (
ALLOWED TokenCacheMode = "ALLOWED"
ALLOWEDOFFLINE TokenCacheMode = "ALLOWED_OFFLINE"
ALWAYS TokenCacheMode = "ALWAYS"
NEVER TokenCacheMode = "NEVER"
)
// Defines values for TokenType.
const (
ADHOCUSER TokenType = "AD_HOC_USER"
APPUSER TokenType = "APP_USER"
OTHER TokenType = "OTHER"
RFID TokenType = "RFID"
)
// Certificate A client certificate
type Certificate struct {
// Certificate The PEM encoded certificate with newlines replaced by `\n`
Certificate string `json:"certificate"`
}
// ChargeStationAuth Connection details for a charge station
type ChargeStationAuth struct {
// Base64SHA256Password The base64 encoded, SHA-256 hash of the charge station password
Base64SHA256Password *string `json:"base64SHA256Password,omitempty"`
// InvalidUsernameAllowed If set to true then an invalid username will not prevent the charge station connecting
InvalidUsernameAllowed *bool `json:"invalidUsernameAllowed,omitempty"`
// SecurityProfile The security profile to use for the charge station: * `0` - unsecured transport with basic auth * `1` - TLS with basic auth * `2` - TLS with client certificate
SecurityProfile int `json:"securityProfile"`
}
// ChargeStationInstallCertificates The set of certificates to install on the charge station. The certificates will be sent
// to the charge station asynchronously.
type ChargeStationInstallCertificates struct {
Certificates []struct {
// Certificate The PEM encoded certificate with newlines replaced by `\n`
Certificate string `json:"certificate"`
// Status The status, defaults to Pending
Status *ChargeStationInstallCertificatesCertificatesStatus `json:"status,omitempty"`
Type ChargeStationInstallCertificatesCertificatesType `json:"type"`
} `json:"certificates"`
}
// ChargeStationInstallCertificatesCertificatesStatus The status, defaults to Pending
type ChargeStationInstallCertificatesCertificatesStatus string
// ChargeStationInstallCertificatesCertificatesType defines model for ChargeStationInstallCertificates.Certificates.Type.
type ChargeStationInstallCertificatesCertificatesType string
// ChargeStationSettings Settings for a charge station
type ChargeStationSettings map[string]string
// ChargeStationTrigger Trigger a charge station action
type ChargeStationTrigger struct {
Trigger ChargeStationTriggerTrigger `json:"trigger"`
}
// ChargeStationTriggerTrigger defines model for ChargeStationTrigger.Trigger.
type ChargeStationTriggerTrigger string
// Connector defines model for Connector.
type Connector struct {
Format ConnectorFormat `json:"format"`
Id string `json:"id"`
MaxAmperage int32 `json:"max_amperage"`
MaxVoltage int32 `json:"max_voltage"`
PowerType ConnectorPowerType `json:"power_type"`
Standard ConnectorStandard `json:"standard"`
}
// ConnectorFormat defines model for Connector.Format.
type ConnectorFormat string
// ConnectorPowerType defines model for Connector.PowerType.
type ConnectorPowerType string
// ConnectorStandard defines model for Connector.Standard.
type ConnectorStandard string
// Evse defines model for Evse.
type Evse struct {
Connectors []Connector `json:"connectors"`
EvseId *string `json:"evse_id"`
// Uid Uniquely identifies the EVSE within the CPOs platform (and
// suboperator platforms).
Uid string `json:"uid"`
}
// GeoLocation defines model for GeoLocation.
type GeoLocation struct {
Latitude string `json:"latitude"`
Longitude string `json:"longitude"`
}
// Location A charge station location
type Location struct {
Address string `json:"address"`
City string `json:"city"`
Coordinates GeoLocation `json:"coordinates"`
Country string `json:"country"`
CountryCode string `json:"country_code"`
Evses *[]Evse `json:"evses"`
Name *string `json:"name"`
ParkingType *LocationParkingType `json:"parking_type"`
PartyId string `json:"party_id"`
PostalCode *string `json:"postal_code"`
}
// LocationParkingType defines model for Location.ParkingType.
type LocationParkingType string
// Registration Defines the initial connection details for the OCPI registration process
type Registration struct {
// Status The status of the registration request. If the request is marked as `REGISTERED` then the token will be allowed to
// be used to access all endpoints avoiding the need for the OCPI registration process. If the request is marked as
// `PENDING` then the token will only be allowed to access the `/ocpi/versions`, `/ocpi/2.2` and `/ocpi/2.2/credentials`
// endpoints.
Status *RegistrationStatus `json:"status,omitempty"`
// Token The token to use for communicating with the eMSP (CREDENTIALS_TOKEN_A).
Token string `json:"token"`
// Url The URL of the eMSP versions endpoint. If provided the CSMS will act as the sender of the versions request.
Url *string `json:"url,omitempty"`
}
// RegistrationStatus The status of the registration request. If the request is marked as `REGISTERED` then the token will be allowed to
// be used to access all endpoints avoiding the need for the OCPI registration process. If the request is marked as
// `PENDING` then the token will only be allowed to access the `/ocpi/versions`, `/ocpi/2.2` and `/ocpi/2.2/credentials`
// endpoints.
type RegistrationStatus string
// Status HTTP status
type Status struct {
// Error The error details
Error *string `json:"error,omitempty"`
// Status The status description
Status string `json:"status"`
}
// Token An authorization token
type Token struct {
// CacheMode Indicates what type of token caching is allowed
CacheMode TokenCacheMode `json:"cacheMode"`
// ContractId The contract ID (eMAID) associated with the token (with optional component separators)
ContractId string `json:"contractId"`
// CountryCode The country code of the issuing eMSP
CountryCode string `json:"countryCode"`
// GroupId This id groups a couple of tokens to make two or more tokens work as one
GroupId *string `json:"groupId,omitempty"`
// Issuer Issuing company, most of the times the name of the company printed on the RFID card, not necessarily the eMSP
Issuer string `json:"issuer"`
// LanguageCode The preferred language to use encoded as ISO 639-1 language code
LanguageCode *string `json:"languageCode,omitempty"`
// LastUpdated The date the record was last updated (ignored on create/update)
LastUpdated *time.Time `json:"lastUpdated,omitempty"`
// PartyId The party id of the issuing eMSP
PartyId string `json:"partyId"`
// Type The type of token
Type TokenType `json:"type"`
// Uid The unique token id
Uid string `json:"uid"`
// Valid Is this token valid
Valid bool `json:"valid"`
// VisualNumber The visual/readable number/identification printed on an RFID card
VisualNumber *string `json:"visualNumber,omitempty"`
}
// TokenCacheMode Indicates what type of token caching is allowed
type TokenCacheMode string
// TokenType The type of token
type TokenType string
// ListTokensParams defines parameters for ListTokens.
type ListTokensParams struct {
Offset *int `form:"offset,omitempty" json:"offset,omitempty"`
Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
}
// UploadCertificateJSONRequestBody defines body for UploadCertificate for application/json ContentType.
type UploadCertificateJSONRequestBody = Certificate
// RegisterChargeStationJSONRequestBody defines body for RegisterChargeStation for application/json ContentType.
type RegisterChargeStationJSONRequestBody = ChargeStationAuth
// InstallChargeStationCertificatesJSONRequestBody defines body for InstallChargeStationCertificates for application/json ContentType.
type InstallChargeStationCertificatesJSONRequestBody = ChargeStationInstallCertificates
// ReconfigureChargeStationJSONRequestBody defines body for ReconfigureChargeStation for application/json ContentType.
type ReconfigureChargeStationJSONRequestBody = ChargeStationSettings
// TriggerChargeStationJSONRequestBody defines body for TriggerChargeStation for application/json ContentType.
type TriggerChargeStationJSONRequestBody = ChargeStationTrigger
// RegisterLocationJSONRequestBody defines body for RegisterLocation for application/json ContentType.
type RegisterLocationJSONRequestBody = Location
// RegisterPartyJSONRequestBody defines body for RegisterParty for application/json ContentType.
type RegisterPartyJSONRequestBody = Registration
// SetTokenJSONRequestBody defines body for SetToken for application/json ContentType.
type SetTokenJSONRequestBody = Token
// ServerInterface represents all server handlers.
type ServerInterface interface {
// Upload a certificate
// (POST /certificate)
UploadCertificate(w http.ResponseWriter, r *http.Request)
// Delete a certificate
// (DELETE /certificate/{certificateHash})
DeleteCertificate(w http.ResponseWriter, r *http.Request, certificateHash string)
// Lookup a certificate
// (GET /certificate/{certificateHash})
LookupCertificate(w http.ResponseWriter, r *http.Request, certificateHash string)
// Register a new charge station
// (POST /cs/{csId})
RegisterChargeStation(w http.ResponseWriter, r *http.Request, csId string)
// Returns the authentication details
// (GET /cs/{csId}/auth)
LookupChargeStationAuth(w http.ResponseWriter, r *http.Request, csId string)
// Install certificates on the charge station
// (POST /cs/{csId}/certificates)
InstallChargeStationCertificates(w http.ResponseWriter, r *http.Request, csId string)
// Reconfigure the charge station
// (POST /cs/{csId}/reconfigure)
ReconfigureChargeStation(w http.ResponseWriter, r *http.Request, csId string)
// (POST /cs/{csId}/trigger)
TriggerChargeStation(w http.ResponseWriter, r *http.Request, csId string)
// Registers a location with the CSMS
// (POST /location/{locationId})
RegisterLocation(w http.ResponseWriter, r *http.Request, locationId string)
// Registers an OCPI party with the CSMS
// (POST /register)
RegisterParty(w http.ResponseWriter, r *http.Request)
// List authorization tokens
// (GET /token)
ListTokens(w http.ResponseWriter, r *http.Request, params ListTokensParams)
// Create/update an authorization token
// (POST /token)
SetToken(w http.ResponseWriter, r *http.Request)
// Lookup an authorization token
// (GET /token/{tokenUid})
LookupToken(w http.ResponseWriter, r *http.Request, tokenUid string)
}
// ServerInterfaceWrapper converts contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
HandlerMiddlewares []MiddlewareFunc
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}
type MiddlewareFunc func(http.Handler) http.Handler
// UploadCertificate operation middleware
func (siw *ServerInterfaceWrapper) UploadCertificate(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.UploadCertificate(w, r)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// DeleteCertificate operation middleware
func (siw *ServerInterfaceWrapper) DeleteCertificate(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "certificateHash" -------------
var certificateHash string
err = runtime.BindStyledParameterWithLocation("simple", false, "certificateHash", runtime.ParamLocationPath, chi.URLParam(r, "certificateHash"), &certificateHash)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "certificateHash", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.DeleteCertificate(w, r, certificateHash)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// LookupCertificate operation middleware
func (siw *ServerInterfaceWrapper) LookupCertificate(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "certificateHash" -------------
var certificateHash string
err = runtime.BindStyledParameterWithLocation("simple", false, "certificateHash", runtime.ParamLocationPath, chi.URLParam(r, "certificateHash"), &certificateHash)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "certificateHash", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.LookupCertificate(w, r, certificateHash)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// RegisterChargeStation operation middleware
func (siw *ServerInterfaceWrapper) RegisterChargeStation(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "csId" -------------
var csId string
err = runtime.BindStyledParameterWithLocation("simple", false, "csId", runtime.ParamLocationPath, chi.URLParam(r, "csId"), &csId)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "csId", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.RegisterChargeStation(w, r, csId)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// LookupChargeStationAuth operation middleware
func (siw *ServerInterfaceWrapper) LookupChargeStationAuth(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "csId" -------------
var csId string
err = runtime.BindStyledParameterWithLocation("simple", false, "csId", runtime.ParamLocationPath, chi.URLParam(r, "csId"), &csId)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "csId", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.LookupChargeStationAuth(w, r, csId)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// InstallChargeStationCertificates operation middleware
func (siw *ServerInterfaceWrapper) InstallChargeStationCertificates(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "csId" -------------
var csId string
err = runtime.BindStyledParameterWithLocation("simple", false, "csId", runtime.ParamLocationPath, chi.URLParam(r, "csId"), &csId)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "csId", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.InstallChargeStationCertificates(w, r, csId)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// ReconfigureChargeStation operation middleware
func (siw *ServerInterfaceWrapper) ReconfigureChargeStation(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "csId" -------------
var csId string
err = runtime.BindStyledParameterWithLocation("simple", false, "csId", runtime.ParamLocationPath, chi.URLParam(r, "csId"), &csId)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "csId", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.ReconfigureChargeStation(w, r, csId)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// TriggerChargeStation operation middleware
func (siw *ServerInterfaceWrapper) TriggerChargeStation(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "csId" -------------
var csId string
err = runtime.BindStyledParameterWithLocation("simple", false, "csId", runtime.ParamLocationPath, chi.URLParam(r, "csId"), &csId)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "csId", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.TriggerChargeStation(w, r, csId)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// RegisterLocation operation middleware
func (siw *ServerInterfaceWrapper) RegisterLocation(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "locationId" -------------
var locationId string
err = runtime.BindStyledParameterWithLocation("simple", false, "locationId", runtime.ParamLocationPath, chi.URLParam(r, "locationId"), &locationId)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "locationId", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.RegisterLocation(w, r, locationId)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// RegisterParty operation middleware
func (siw *ServerInterfaceWrapper) RegisterParty(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.RegisterParty(w, r)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// ListTokens operation middleware
func (siw *ServerInterfaceWrapper) ListTokens(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// Parameter object where we will unmarshal all parameters from the context
var params ListTokensParams
// ------------- Optional query parameter "offset" -------------
err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err})
return
}
// ------------- Optional query parameter "limit" -------------
err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.ListTokens(w, r, params)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// SetToken operation middleware
func (siw *ServerInterfaceWrapper) SetToken(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.SetToken(w, r)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// LookupToken operation middleware
func (siw *ServerInterfaceWrapper) LookupToken(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "tokenUid" -------------
var tokenUid string
err = runtime.BindStyledParameterWithLocation("simple", false, "tokenUid", runtime.ParamLocationPath, chi.URLParam(r, "tokenUid"), &tokenUid)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "tokenUid", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.LookupToken(w, r, tokenUid)
})
for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- {
handler = siw.HandlerMiddlewares[i](handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
type UnescapedCookieParamError struct {
ParamName string
Err error
}
func (e *UnescapedCookieParamError) Error() string {
return fmt.Sprintf("error unescaping cookie parameter '%s'", e.ParamName)
}
func (e *UnescapedCookieParamError) Unwrap() error {
return e.Err
}
type UnmarshallingParamError struct {
ParamName string
Err error
}
func (e *UnmarshallingParamError) Error() string {
return fmt.Sprintf("Error unmarshalling parameter %s as JSON: %s", e.ParamName, e.Err.Error())
}
func (e *UnmarshallingParamError) Unwrap() error {
return e.Err
}
type RequiredParamError struct {
ParamName string
}
func (e *RequiredParamError) Error() string {
return fmt.Sprintf("Query argument %s is required, but not found", e.ParamName)
}
type RequiredHeaderError struct {
ParamName string
Err error
}
func (e *RequiredHeaderError) Error() string {
return fmt.Sprintf("Header parameter %s is required, but not found", e.ParamName)
}
func (e *RequiredHeaderError) Unwrap() error {
return e.Err
}
type InvalidParamFormatError struct {
ParamName string
Err error
}
func (e *InvalidParamFormatError) Error() string {
return fmt.Sprintf("Invalid format for parameter %s: %s", e.ParamName, e.Err.Error())
}
func (e *InvalidParamFormatError) Unwrap() error {
return e.Err
}
type TooManyValuesForParamError struct {
ParamName string
Count int
}
func (e *TooManyValuesForParamError) Error() string {
return fmt.Sprintf("Expected one value for %s, got %d", e.ParamName, e.Count)
}
// Handler creates http.Handler with routing matching OpenAPI spec.
func Handler(si ServerInterface) http.Handler {
return HandlerWithOptions(si, ChiServerOptions{})
}
type ChiServerOptions struct {
BaseURL string
BaseRouter chi.Router
Middlewares []MiddlewareFunc
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}
// HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler {
return HandlerWithOptions(si, ChiServerOptions{
BaseRouter: r,
})
}
func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler {
return HandlerWithOptions(si, ChiServerOptions{
BaseURL: baseURL,
BaseRouter: r,
})
}
// HandlerWithOptions creates http.Handler with additional options
func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler {
r := options.BaseRouter
if r == nil {
r = chi.NewRouter()
}
if options.ErrorHandlerFunc == nil {
options.ErrorHandlerFunc = func(w http.ResponseWriter, r *http.Request, err error) {
http.Error(w, err.Error(), http.StatusBadRequest)
}
}
wrapper := ServerInterfaceWrapper{
Handler: si,
HandlerMiddlewares: options.Middlewares,
ErrorHandlerFunc: options.ErrorHandlerFunc,
}
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/certificate", wrapper.UploadCertificate)
})
r.Group(func(r chi.Router) {
r.Delete(options.BaseURL+"/certificate/{certificateHash}", wrapper.DeleteCertificate)
})
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/certificate/{certificateHash}", wrapper.LookupCertificate)
})
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/cs/{csId}", wrapper.RegisterChargeStation)
})
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/cs/{csId}/auth", wrapper.LookupChargeStationAuth)
})
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/cs/{csId}/certificates", wrapper.InstallChargeStationCertificates)
})
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/cs/{csId}/reconfigure", wrapper.ReconfigureChargeStation)
})
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/cs/{csId}/trigger", wrapper.TriggerChargeStation)
})
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/location/{locationId}", wrapper.RegisterLocation)
})
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/register", wrapper.RegisterParty)
})
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/token", wrapper.ListTokens)
})
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/token", wrapper.SetToken)
})
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/token/{tokenUid}", wrapper.LookupToken)
})
return r
}
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
"H4sIAAAAAAAC/+xbX3MaO5b/KqrefUi22gbbiWvjl1kCxGZiAwU4t2YvKSy6D6Bxt9RXUtthXP7uW0dq",
"QTctjOfOZCebuy926/+R9Dt/dXgKIpFmggPXKrh4ClS0gpSazzZIzRYsohqwGIOKJMs0Ezy4CFokShhw",
"TaJSrzDIpMiwAswM0UszTFZAht0bAjwSMcTlicgj0yvC4TFhHBSRkCU0gpjM1+RuO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GOa2XZZP",
"48l9vdqpcwO2oWQTbX3BLboupRQdwshm9kPo2NId/L2Bhn8+RraJSz+hI7T/0q3kkEW/V8GH27wU+0BW",
"RRDpgHPTnblQUWT+BIkpB6ZXIIsUIBN7q2S9bBaxaxbZMY6AJCGPlOlN1oytNy8mxXRTvm/CQ7gf4lzf",
"KZZfSY36SVG3HysWeJuMH39wlSlts6XcMz2ahzbms82pKrI+YJOr7/OnmdImcUTtiYv+loPJdCtEk1gs",
"FOiqWGKcpXkaXDR9P7XyT5OwlOld4WZnOWk2w+2cJ545/1FP+1WJkzabpv6DnNqd4wluEyZ+rGAnkuZJ",
"/lEuJXIf2ygUJTZrACVkkWP2ezE2Bgux7yQuipv6ieREu5y2gbLCl8C1FRONJ/Pvllkz5+XnmH/wLu08",
"7joPP6Q4yl77guLJt/iukbUSeHbS5upH/v9vKNU3lH24NL8blg8vG8IJieEBEpGlNgUP+wdFommw0jq7",
"aBhLPlkJpS8+vDtpNmjGGg/N4Pnr8/8EAAD//5Lxm9kDPwAA",
}
// GetSwagger returns the content of the embedded swagger specification file
// or error if failed to decode
func decodeSpec() ([]byte, error) {
zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
if err != nil {
return nil, fmt.Errorf("error base64 decoding spec: %s", err)
}
zr, err := gzip.NewReader(bytes.NewReader(zipped))
if err != nil {
return nil, fmt.Errorf("error decompressing spec: %s", err)
}
var buf bytes.Buffer
_, err = buf.ReadFrom(zr)
if err != nil {
return nil, fmt.Errorf("error decompressing spec: %s", err)
}
return buf.Bytes(), nil
}
var rawSpec = decodeSpecCached()
// a naive cached of a decoded swagger spec
func decodeSpecCached() func() ([]byte, error) {
data, err := decodeSpec()
return func() ([]byte, error) {
return data, err
}
}
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
var res = make(map[string]func() ([]byte, error))
if len(pathToFile) > 0 {
res[pathToFile] = rawSpec
}
return res
}
// GetSwagger returns the Swagger specification corresponding to the generated code
// in this file. The external references of Swagger specification are resolved.
// The logic of resolving external references is tightly connected to "import-mapping" feature.
// Externally referenced files must be embedded in the corresponding golang packages.
// Urls can be supported but this task was out of the scope.
func GetSwagger() (swagger *openapi3.T, err error) {
var resolvePath = PathToRawSpec("")
loader := openapi3.NewLoader()
loader.IsExternalRefsAllowed = true
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
var pathToFile = url.String()
pathToFile = path.Clean(pathToFile)
getSpec, ok := resolvePath[pathToFile]
if !ok {
err1 := fmt.Errorf("path not found: %s", pathToFile)
return nil, err1
}
return getSpec()
}
var specData []byte
specData, err = rawSpec()
if err != nil {
return
}
swagger, err = loader.LoadFromData(specData)
if err != nil {
return
}
return
}