From 773147206b21fd334805d2589d893ff51ed9457a Mon Sep 17 00:00:00 2001 From: Dale Peakall Date: Fri, 11 Aug 2023 15:23:45 +0100 Subject: [PATCH 01/15] feat: add ocpi credential and version support Initial work towards implementing OCPI. Use the /register method on the manager API to setup OCPI registration. If the manager is to be the sender pass both the token and url parameters to the /register endpoint; otherwise pass the token parameter and the manager will act as the receiver. Error handling is unlikely to be compliant with the OCPI spec. --- .pre-commit-config.yaml | 2 +- .talismanrc | 16 +- config/envoy/envoy.yaml | 27 +- config/manager/config.toml | 6 + docker-compose.yml | 2 + manager/api/api-spec.yaml | 42 + manager/api/api.gen.go | 105 +- manager/api/render.go | 4 + manager/api/server.go | 40 +- manager/api/server_test.go | 2 +- manager/api/validation_test.go | 6 +- manager/cmd/auth_generate_credential.go | 41 + manager/cmd/serve.go | 8 +- manager/config/README.md | 1 - manager/config/base_config.go | 1 + manager/config/config.go | 28 + manager/config/ocpi_config.go | 8 + manager/go.mod | 1 + manager/ocpi/auth.go | 53 + manager/ocpi/auth_test.go | 130 + manager/ocpi/cfg.yaml | 8 + manager/ocpi/error.go | 45 + manager/ocpi/ocpi.gen.go | 12347 ++++++++++++++++++++++ manager/ocpi/ocpi.go | 105 + manager/ocpi/ocpi22-spec.yaml | 4807 +++++++++ manager/ocpi/register.go | 207 + manager/ocpi/register_test.go | 62 + manager/ocpi/render.go | 15 + manager/ocpi/server.go | 276 + manager/ocpi/status.go | 43 + manager/server/api.go | 43 +- manager/server/api_test.go | 58 +- manager/server/log.go | 33 + manager/server/ocpi.go | 67 + manager/server/ocpi_test.go | 105 + manager/store/engine.go | 1 + manager/store/firestore/cs.go | 2 + manager/store/firestore/ocpi.go | 72 + manager/store/firestore/ocpi_test.go | 79 + manager/store/firestore/store.go | 2 + manager/store/firestore/token.go | 2 + manager/store/inmemory/store.go | 48 + manager/store/ocpi.go | 35 + 43 files changed, 18900 insertions(+), 85 deletions(-) create mode 100644 manager/cmd/auth_generate_credential.go create mode 100644 manager/config/ocpi_config.go create mode 100644 manager/ocpi/auth.go create mode 100644 manager/ocpi/auth_test.go create mode 100644 manager/ocpi/cfg.yaml create mode 100644 manager/ocpi/error.go create mode 100644 manager/ocpi/ocpi.gen.go create mode 100644 manager/ocpi/ocpi.go create mode 100644 manager/ocpi/ocpi22-spec.yaml create mode 100644 manager/ocpi/register.go create mode 100644 manager/ocpi/register_test.go create mode 100644 manager/ocpi/render.go create mode 100644 manager/ocpi/server.go create mode 100644 manager/ocpi/status.go create mode 100644 manager/server/log.go create mode 100644 manager/server/ocpi.go create mode 100644 manager/server/ocpi_test.go create mode 100644 manager/store/firestore/ocpi.go create mode 100644 manager/store/firestore/ocpi_test.go create mode 100644 manager/store/ocpi.go diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f3381b..7534e5a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,6 +30,6 @@ repos: - id: go-fmt - id: go-staticcheck-mod - id: go-sec-mod + args: ["-exclude-generated", "--"] - id: go-build-mod - id: go-test-mod - - id: go-sec-mod diff --git a/.talismanrc b/.talismanrc index c6f3b35..d091999 100644 --- a/.talismanrc +++ b/.talismanrc @@ -6,7 +6,7 @@ fileignoreconfig: - filename: README.md checksum: 31e36953a79714f038a16dc3c36365434aea5237bbb5b7b3fdc4276e92edc82e - filename: config/envoy/envoy.yaml - checksum: 90b8cf1a728636d65356a9d0041cc853024f5847e903ad093a0e032279b29429 + checksum: ecc0939110080350677a0b99d71d47f4cfb341cbcc2dedd212a52b8e350311d4 - filename: config/manager/config.toml checksum: 103e08cb1d9507cbeb377f4212606e52375d2f77c079aaad7465873ebb5fdd98 - filename: docker-compose.yml @@ -26,11 +26,13 @@ fileignoreconfig: - filename: manager/api/API.md checksum: c111751da44c7310d6b77b76e1a5826c44cce62e47a32eaec564e86064bb1de2 - filename: manager/api/api.gen.go - checksum: d32fa0bfcbaaf4e6db10c012d3de521922e83418a2121d1fa84cb81cd2277edc + checksum: 5b1dc3f6049e2267fef0f73cabb9dd1f3df82da4dcb4ad55eaa76c9b89f58cde - filename: manager/api/server.go - checksum: 22cd986022106ada9fbc8c88d41a96dbedce68e4442fe32f1ae3ac081a2bde0d + checksum: 98cbd1df522ea428f7e669c01721f3070133062378a4f2e4b167d55eaa8d079b - filename: manager/api/server_test.go checksum: 297c27a0f612af86cfdce543d5e4a21e60e70f4eb48b57d3c833257bb1b05647 + - filename: manager/cmd/auth_generate_credential.go + checksum: 7503d0819ff60f03c7b6d82f7acc3be1b95579763f1e3d52775a539fca75d785 - filename: manager/cmd/serve.go checksum: 7b5688335f7ad1b5339fc7cc8deaf08e10f42e03cbe086810d2bd70567f923c5 - filename: manager/config/base_config_test.go @@ -63,6 +65,12 @@ fileignoreconfig: checksum: 9660c626538042009cebcba874730e4222c115fdf24c9dba12c5d4601c69b613 - filename: manager/mqtt/router.go checksum: 880513a5d3f0070619c4890b5aab9fcf10650afc79550a83c1ad9a986c7e7367 + - filename: manager/ocpi/ocpi.gen.go + checksum: 6ca663b1e4f6ecaef87f6fadaacdebcc905ac236adf704ac9278d25e605d940d + - filename: manager/ocpi/register.go + checksum: 50b33545ae6af5356024ac1e454d20f4550a61c23ffd380c7e8b10dbe403812d + - filename: manager/ocpi/server.go + checksum: 67cefb85bb20fd6ebbc1587c2726472ead79d4277404f65b4ef7c218d3f9eb13 - filename: manager/ocpp/emaid_test.go checksum: 9a7e7aa8c3e8c2ea5ea2ad070d4fc734c086fc796bc06148d6db891a413ed4af - filename: manager/ocpp/has2be/authorize_request.go @@ -101,6 +109,8 @@ fileignoreconfig: checksum: bc9281581eab4a81329e8c5426a4768361f0aa8022c865b5cfca4b4b85bbaee6 - filename: manager/schemas/ocpp201/TransactionEventResponse.json checksum: 30e812e60ae4c19b31bc91b1214057cb2dca6e346967250d912cd108a44322d2 + - filename: manager/server/ocpi.go + checksum: 3678a916dbab5a3bc0384c088cafbf9720081df0d8bd7478d17ae3098c6b9af8 - filename: manager/services/certificate_validation.go checksum: c56dba57d1502acbecb680f97f6efbbd42fda3fde3ca5f54e63da883684db610 - filename: manager/services/certificate_validation_hubject_test.go diff --git a/config/envoy/envoy.yaml b/config/envoy/envoy.yaml index 7030f80..0994241 100644 --- a/config/envoy/envoy.yaml +++ b/config/envoy/envoy.yaml @@ -36,6 +36,18 @@ static_resources: "@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy stat_prefix: destination cluster: manager_api + - name: listener_ocpi_api + address: + socket_address: + address: 0.0.0.0 + port_value: 9411 + filter_chains: + - filters: + - name: envoy.filters.network.tcp_proxy + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy + stat_prefix: destination + cluster: ocpi_api clusters: - name: gateway_ws connect_timeout: 30s @@ -75,4 +87,17 @@ static_resources: address: socket_address: address: manager - port_value: 9410 \ No newline at end of file + port_value: 9410 + - name: ocpi_api + connect_timeout: 30s + type: LOGICAL_DNS + dns_lookup_family: V4_ONLY + load_assignment: + cluster_name: manager + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: manager + port_value: 9411 \ No newline at end of file diff --git a/config/manager/config.toml b/config/manager/config.toml index 7e10a40..8914e96 100644 --- a/config/manager/config.toml +++ b/config/manager/config.toml @@ -4,6 +4,12 @@ addr = ":9410" [mqtt] urls = ["mqtt://mqtt:1883"] +[ocpi] +addr = ":9411" +external_url = "http://localhost:9411" +country_code = "GB" +party_id = "TWK" + [storage] type = "firestore" firestore.project_id = "*detect-project-id*" diff --git a/docker-compose.yml b/docker-compose.yml index 5f4ffdd..236a60d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,6 +37,7 @@ services: - "80:80" - "443:443" - "9410:9410" + - "9411:9411" gateway: build: @@ -104,6 +105,7 @@ services: read_only: true expose: - "9410" + - "9411" healthcheck: test: ["CMD", "/usr/bin/curl", "-s", "--fail", "http://localhost:9410/health"] interval: 10s diff --git a/manager/api/api-spec.yaml b/manager/api/api-spec.yaml index 3b2af1a..b8d2922 100644 --- a/manager/api/api-spec.yaml +++ b/manager/api/api-spec.yaml @@ -245,6 +245,29 @@ paths: "application/json": schema: $ref: "#/components/schemas/Status" + /register: + post: + summary: "Registers an OCPI party with the CSMS" + description: | + Registers an OCPI party with the CSMS. Depending on the configuration provided the CSMS will + either initiate a registration with the party or the party will wait for the party to initiate + a registration with the CSMS. + operationId: "registerParty" + requestBody: + required: true + content: + "application/json": + schema: + $ref: "#/components/schemas/Registration" + responses: + "201": + description: "Created" + default: + description: "Unexpected error" + content: + application/json: + schema: + $ref: "#/components/schemas/Status" components: schemas: ChargeStationAuth: @@ -354,3 +377,22 @@ components: certificate: type: "string" description: "The PEM encoded certificate with newlines replaced by `\\n`" + Registration: + type: "object" + description: "Defines the initial connection details for the OCPI registration process" + properties: + token: + type: "string" + maxLength: 64 + description: "The token to use for communicating with the eMSP (CREDENTIALS_TOKEN_A)." + url: + type: "string" + format: "uri" + description: "The URL of the eMSP versions endpoint. If provided the CSMS will act as the sender of the versions request." + required: + - token + + + + + diff --git a/manager/api/api.gen.go b/manager/api/api.gen.go index feec753..9d50f78 100644 --- a/manager/api/api.gen.go +++ b/manager/api/api.gen.go @@ -50,6 +50,15 @@ type ChargeStationAuth struct { SecurityProfile int `json:"securityProfile"` } +// Registration Defines the initial connection details for the OCPI registration process +type Registration struct { + // 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"` +} + // Status HTTP status type Status struct { // Error The error details @@ -116,6 +125,9 @@ type UploadCertificateJSONRequestBody = Certificate // RegisterChargeStationJSONRequestBody defines body for RegisterChargeStation for application/json ContentType. type RegisterChargeStationJSONRequestBody = ChargeStationAuth +// RegisterPartyJSONRequestBody defines body for RegisterParty for application/json ContentType. +type RegisterPartyJSONRequestBody = Registration + // SetTokenJSONRequestBody defines body for SetToken for application/json ContentType. type SetTokenJSONRequestBody = Token @@ -136,6 +148,9 @@ type ServerInterface interface { // Returns the authentication details // (GET /cs/{csId}/auth) LookupChargeStationAuth(w http.ResponseWriter, r *http.Request, csId 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) @@ -275,6 +290,21 @@ func (siw *ServerInterfaceWrapper) LookupChargeStationAuth(w http.ResponseWriter 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() @@ -480,6 +510,9 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl 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+"/register", wrapper.RegisterParty) + }) r.Group(func(r chi.Router) { r.Get(options.BaseURL+"/token", wrapper.ListTokens) }) @@ -496,40 +529,44 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xZ62/juBH/VwZsP2wKOXYeF2D95eomOcRAXoiTO7SbYJeWxhYvEqklqXi9gf/3YkjJ", - "si16s9dr2uDaT5bEITmP3zz9zGKVF0qitIb1n5mJU8y5ezxGbcVExNwivSZoYi0KK5RkfTaAOBMoLcQr", - "VBErtCroA7oT4m+dcJsiXJ9eAMpYJZisHgQzYVOQOMuERAMai4zHmMB4Dp/u7+UnFjE7L5D1mbFayClb", - "LCKm8XMpNCas/2Ht4oclsRr/irFli4gdp1xPcWQ58TIobdpm71hJiTG9QIKWi8zARGngELu9YPzmlsxj", - "bvDocHQ22P/h6JobM1M6CQvvKWv5IxidDTr7PxxByk0KagI2xY3LoKgPjFjOv5yjnBLrR4ctfUTMYFxq", - "YefXWk1EtkX/NREUngqsgtKgk7R9fR/+Ap96n6ADpXQ7MQGruTSF0tbbbMyNiIGXNiXaPaK9PR+F1vbX", - "1tpgupeNlYW0OEXdMvOmjCFTk5FL0xb/7Pb22glWmpYNUWulwxpzSzUiWEjvW+5z6nZrsLrwEpKr40KS", - "3apHlAHPlE7HSouvHjTW0bV8k8cpXqgkgIyhTJwJDMxSboEudnikc4D2CTkFYYBnmZohgRFlmRO3g/Nf", - "Bn8fsYgNzs+vfjk9aZ4+Xv300/nw8pRF7PL059ObFYka3cVKWs1jO9ziMfU6DE/gHV4Mhic7wI1RseAW", - "E48kgq3n9J17V+4AnsEyzoHBgmtulTY7pBZuLWq64t2HQecfvPP14Xl/sfOu8+NO8+Fg/UOv8/7h+X37", - "286PLChWKa2eHweV7eVyBECBoPZ8YUxJesaL0fW6u+9HLBdy5a114VSrsggrURgQCTgCQ8FMlUXWWNdQ", - "AMj5I4KdKVAacqWxXpop/QjcgJK4ztDBUYAH4h8DTjSs5CJzcDmPIFfG1kJbkaNxT5LnS1VUpFBoCgQJ", - "EKZThJufhicQc51EIJUFiTEaw7XI5m65UlyLsYzLacmnuN0chcYJaopuNW0dF+tcxQ0MR1dwdPC+s9cQ", - "0dpvNVXGjb0rEsJvmBlacvJojJVOYMYN0CYo/S54J6ZSaa+WWCO32PVLBO6J0jm3rM/oQ4fUG1JJwbWd", - "b3M6t0igeRGYB2vSHgQu8h9Ct6wFmdWIcvLx7Or4493o9IaCyfV1/Xh1e+Z+CQXBYFKKLQKVUnwu6yAh", - "ku/A8hPPQocNCarCVCd5ouXusVIZcum2C1Py7LLMx7glq3iKrkae8HGGIB1tVyQoq3zosn+Dfy4b+L9c", - "Da3En8bY1S6vqLXYu3TeWvJoJVu0MxFdJ+REuayipOWxdUk05yJjfZZzfMKORZ7/1aaqnKaWAonZjVXO", - "IkZ+zvrsgp/+jEBEpLDNdETxmWcwuB6SI5ISXBZYxnu/+3h0MYoAv1TUvqQwYFJVZolz36vj6+Eui1gm", - "YpTGIbG6f1CQgLC/23MwFTZruKJzSRWojWeot9vzdKpAyQvB+uzAfXLJJHXptbtR+xbK2Lbt74pM8cQF", - "4lYBRKKScHT9LtxWTxBz6WRxgXGdmtI+AcaXT4HysTTkuHlpS5752itFH0vphaoDR2eAa4QxErGaTIhF", - "qvQUcKDnzphnXMaod12NttxGAaSS6HitKSAsorF/U8m8xghKpw1eFFmF7u6vRsmmA6GnP2ucsD77U7dp", - "UbpVf9JdvWGxDnirS3QfTKGk8dXOfm8vUOK7aJl4xE14mdl/G3tV1ek42zC5xC8FxuTHvswkElPmOdfz", - "pf4IEGsCRmuA6j6vvJxxky68cBmGGq0T930byKjCS7mBMaKEsmiMXWOvQg3f6FfW2pV7WSWHk9MbGM8t", - "mhA2PCPr2KBKLEeL2rD+h2cmiGFyoiY0bIjKNk0drZjk203R4qGFisO2ui4V1BBYROzQk7wyKC6VhYkq", - "5dvCorfXJhYjNsVAKDtX6rEs/vsg83y8KZD1Xi/qbQS0FZ3XLer/OIYbWLbiqek+x2aYLLan5xucCkOw", - "AQ4SZxvp1CdlMzcWc5iJLKNetMwruLfT770kF6BWZY7Wu0Kh1ZOgqoJ6Cpn4U9ywKzT9EdLl4AJlQs5C", - "n/FeGgXCurLAHRkrORFTN5tx2V1QvytdjTFW1CappqIM+U8t89qIrO1DgSZ2g9mqdnVlZMjjjKs0f5tb", - "vUId0ZoE/pGqidqYQfxuuEGXV3PQYHi/QVtq6Xvzeh5aKwnG8yaQT7nFGZ9TcE8ILrmQCKmafU+Buj2c", - "t6z0RgD5WnE+jMoNwK3L5warNUf/ubB/Jx+lmskWtt6UFzTYXYHgymjfu4KtB6rhAkcY62aey1EZhXkf", - "d6kjS2qEKy2+4vKPghCmhbFueGu21CafS9TzBplqMjFo17EppMjLnPV7oSF5+JhM5MJuItyfstfrRc2Z", - "e4Ezfy/ahcXcvGRhP9FezokY15rPQwYnDTZDy7dVcBBrgQG84zJcZvjMYUDpaqhHydoPlf5ljI3QQ+yV", - "2u/KUn+gVHm8OjoFHv4TpQkT3Wf3cyd8/fjtluh32tKfU5vz5Wam5ux7u5jAzPNVs9sKeDb+umqr/P99", - "zHofsw2X7h9f/bS9GspUzDNI8AkzVeT+bzCiZxErdcb6LLW26He7ji5VxvbfH+71urwQ3aceWzws/hkA", - "AP//uA8rKyogAAA=", + "H4sIAAAAAAAC/+xaX3PbuBH/KjtoH+yObMl2zjPRy1W1lbGm/qOx7Ltp40wCkSsRFxJgANCKzqPv3lmA", + "FEURinO9us2k92SRWALY3d/+sLvwE4tUliuJ0hrWf2ImSjDj7ucZaitmIuIW6TFGE2mRW6Ek67MBRKlA", + "aSHakOqwXKucXqCbIfrSDHcJwnh4BSgjFWO8OREshE1A4iIVEg1ozFMeYQzTJXx4eJAfWIfZZY6sz4zV", + "Qs7ZatVhGj8VQmPM+m8bC79bC6vpLxhZtuqws4TrOU4sp70MCpu0t3empMSIHiBGy0VqYKY0cIjct2D8", + "xy2dp9zg6avJxeD4h9MxN2ahdBxW3ktW+ndgcjE4OP7hFBJuElAzsAluLQZ5NWGHZfzzJco5bf30Vcse", + "HWYwKrSwy7FWM5HusH8lBLmXAqugMOg0bS/fh7/Ah94HOIBCui8xBqu5NLnS1vtsyo2IgBc2Idkjkr27", + "nITGjhtjbTA9yNrLQlqco265eVvHkKtvcS6M1d5ZLSOc48xBjJQVUljBU4jCnieRm7PxCPTGjGS4CI1p", + "wcCqjyjDRndDm5aOVJYVkrQWcu7tQYvh1WQMe2e3w/Ph9d1ocDl5f3fz9+H1+8H+4Vf4v9BpePn728sK", + "XW6FR9RGKGkAZZwrIe0hjGak16OgsCS5s8kV+SlNgUcWuDeXQRmjrqZaz0L+QWNpizOlM25ZnxVaPBuy", + "3mAhD1KYFqatzMXd3dhBs2ibH7VWOqy/G6o8y0KRs2M9FzBuDDYHnlOsnC6k2V0YJAPpokRp8asHmbdN", + "i115lOCVigOxPZKxCyIDi4RboIWdoxzy6DsCmjDA01QtkOgEZZHRbgeXPw/+MWEdNri8vPl5eF7/en/z", + "5s3l6HrIOux6+NPwdkOj2naRklbzyI52cF41DqNz2MOrweh8H7gxKhLcYlxj3+90zz0rN4ELzPKkAoM5", + "19wqbfbJLNxa1LTE3tvBwT/5wa/vno5X+3sHP+7XL06aL3oHr989vW6/2/+RBdUqpNXLs6CxvV5OAIjK", + "q5AQxhRkZ4qyZsAed1gm5MZTa8G5VkUeNqIwIGJwAoaOI1Xkae1dQ8SS8Y8IdqFAaciUxmpoofRHCl8l", + "sbmhk9PAHmj/GAiiUakXuYPLZQcyZWyltBVZSaeSZ2tTlKKQa6LyGAjTCcLtm9E5RFzHHZDKgkSiUq5F", + "ulzTU8gbKZfzgs9xtztyjTPUdD5VshXfVtkGNzCa3MDpyeuDo1qIxn6rq1Ju7H0eE37Dm6Ehp4/GSOkY", + "FtwAfQSF/wr2xFwq7c0SaeQWu35of5NE6cUBmTdkkpxru9wVdG6QQPMsME8a2p4EFvIvgsfaJslsMsr5", + "+4ubs/f3k+Etkcl4XP28ubtwfwkFQTIpxA6FCik+FRVJiPgrsPzI09BkI4KqMOVMXmj99VSpFLl0nwtT", + "8PS6yKa441TxEl2NPObTFEE62a6IUZYZjc8W1vjnsob/8/nsBv/Uzi6/8oZqcO86eCvNOxunRfskouWE", + "nCl3qihpeWTdIZpxkbI+yzg+4oFFnv3VJqqYJ5aIxBxGKmMdRnHO+uyKD39CICEy2PZxRPzMUxiMRxSI", + "ZAR3Cqz53n9NeUYH8HMp7ZNCAyZRRRq78KUEjFKLVEQojUNiuf4gJwXh+LDnYCpsWu+K5iVT+ByF9Vnv", + "sOflVI6S54L12Yl75Q6TxB2v3a3qJVfGtn1/n6eKx46IWyksqVqlT4dwVyVSEZdOF0eMTWk69gkwPgEO", + "FACFocDNClvw1GfPCXoupQfKDpycAa4RpkjCajajLVIqp4AD/T6Y8pTLCPWhy7LXnxGBlBqdNcq6Mqn7", + "m4qXFUZQOmvwPE9LdHd/MT7F9jUk/fqzxhnrsz916yKzW1aY3c0VVk3AW12ge2FyJY3Pdo57R4EizbFl", + "7BE340Vq/2PbK7NOt7Mtl0v8nGNEcezTTBIxRZZxvVzbjwDRULDTAFT3aePhgptk5ZVLMVQqn7v3u0BG", + "GV7CDUwRJRR57ex16u5Rw7cqzkbB+SDLw+F8eAvTpUUTwobfSBMblIllaFEb1n/7xARtmIKopoYtVdm2", + "qzsbLvlyWbN610LFq7a5rhVUEFh12Csv8sKguFYWZqqQ3xYWvb+2sdhhcwxQ2aVSH4v8fw8yv49vCmS9", + "l2O9LULbsHlVov6fY7iGZYtPTfcpMqN4tft49t0f1MSdEhdbx6k/lM3SWMzK/oYxRVbCvX38PkgKASpV", + "lmh9KLg+CWUVVFPI2M/i2pWh/p2Q7gzOUcYULPQaH6RRIKxLC9yUkZIzMXfdNXe6C+t6LaTCVFGZpOqM", + "MhQ/lc6NJmc7hgJF7NZmy9zVpZGhiDMu0/xtYfUCeUSrl/s9ZROVM4P43QqDLi872UF6v0VbaOlr86qv", + "WRkJpsuayOfc4oIvidxjgksmJEKiFl+ToO6m85aXvhFAvhTPh1G5Bbimfq41Xu3ov0f79/KjVAvZwtY3", + "FQU1djcguNGi96Ggy2j5qgNB+na+746sK1FfrJ1jxdFlq6oi5XXXP9Adf5AobIK6vElwiVfjsmC9iF+z", + "vFSoNpCmsODCri8b/HtXLpfTPchdE7pdf+EsGNNcL1TINW5Yvkfu/SJWPPDW1z3hzFoY65rt6x4t5Rf+", + "wIfClKV52fLH9R1jiEyFse7WwOxIij8VqJc1JarZzKBtkqKQIisy1u+F7tfC06QiE3abWv0sR71ep57z", + "KDDn76VZYTEzzznZX6WsG5SMa82XIZ+TBetu+beV6dLWAjc/bpdhOvNhY4hKfMuYssTygvHfxdgEPcRe", + "iC5KT31HPHG22bMnrgjd3tU00X1yf+6FL1y+XIv/Tl/6eSp3Pl9FVzv72vI50Gx/0bRqAzxbd6Ztk/9R", + "QDcL6F24dP8soh93p+GpingKMT5iqvLM37+SPCv/y4Al1ub9btfJJcrY/utXR70uz0X3scdW71b/CgAA", + "//+e5cY/ZSQAAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/manager/api/render.go b/manager/api/render.go index 9ebc082..8fd9bc5 100644 --- a/manager/api/render.go +++ b/manager/api/render.go @@ -27,3 +27,7 @@ func (t Certificate) Bind(r *http.Request) error { func (t Certificate) Render(w http.ResponseWriter, r *http.Request) error { return nil } + +func (r Registration) Bind(req *http.Request) error { + return nil +} diff --git a/manager/api/server.go b/manager/api/server.go index 15f0e51..64d1566 100644 --- a/manager/api/server.go +++ b/manager/api/server.go @@ -3,6 +3,7 @@ package api import ( + "github.com/thoughtworks/maeve-csms/manager/ocpi" "net/http" "time" @@ -10,7 +11,6 @@ import ( "github.com/go-chi/render" "github.com/thoughtworks/maeve-csms/manager/ocpp" "github.com/thoughtworks/maeve-csms/manager/store" - "golang.org/x/exp/slog" "k8s.io/utils/clock" ) @@ -18,9 +18,10 @@ type Server struct { store store.Engine clock clock.PassiveClock swagger *openapi3.T + ocpi ocpi.Api } -func NewServer(engine store.Engine, clock clock.PassiveClock) (*Server, error) { +func NewServer(engine store.Engine, clock clock.PassiveClock, ocpi ocpi.Api) (*Server, error) { swagger, err := GetSwagger() if err != nil { return nil, err @@ -28,6 +29,7 @@ func NewServer(engine store.Engine, clock clock.PassiveClock) (*Server, error) { return &Server{ store: engine, clock: clock, + ocpi: ocpi, swagger: swagger, }, nil } @@ -211,8 +213,6 @@ func (s *Server) DeleteCertificate(w http.ResponseWriter, r *http.Request, certi } func (s *Server) LookupCertificate(w http.ResponseWriter, r *http.Request, certificateHash string) { - slog.Info("LookupCertificate", slog.String("certificateHash", certificateHash)) - cert, err := s.store.LookupCertificate(r.Context(), certificateHash) if err != nil { _ = render.Render(w, r, ErrInternalError(err)) @@ -228,3 +228,35 @@ func (s *Server) LookupCertificate(w http.ResponseWriter, r *http.Request, certi } _ = render.Render(w, r, resp) } + +func (s *Server) RegisterParty(w http.ResponseWriter, r *http.Request) { + if s.ocpi == nil { + _ = render.Render(w, r, ErrNotFound) + return + } + + req := new(Registration) + if err := render.Bind(r, req); err != nil { + _ = render.Render(w, r, ErrInvalidRequest(err)) + return + } + + if req.Url != nil { + err := s.ocpi.RegisterNewParty(r.Context(), *req.Url, req.Token) + if err != nil { + _ = render.Render(w, r, ErrInternalError(err)) + return + } + } else { + // store credentials in database + err := s.store.SetRegistrationDetails(r.Context(), req.Token, &store.OcpiRegistration{ + Status: store.OcpiRegistrationStatusPending, + }) + if err != nil { + _ = render.Render(w, r, ErrInternalError(err)) + return + } + } + + w.WriteHeader(http.StatusCreated) +} diff --git a/manager/api/server_test.go b/manager/api/server_test.go index 184bc41..b4af588 100644 --- a/manager/api/server_test.go +++ b/manager/api/server_test.go @@ -309,7 +309,7 @@ func setupServer(t *testing.T) (*httptest.Server, *chi.Mux, store.Engine, clock. now := time.Now().UTC() c := clockTest.NewFakePassiveClock(now) - srv, err := api.NewServer(engine, c) + srv, err := api.NewServer(engine, c, nil) require.NoError(t, err) r := chi.NewRouter() diff --git a/manager/api/validation_test.go b/manager/api/validation_test.go index 063b7c0..3cabd1a 100644 --- a/manager/api/validation_test.go +++ b/manager/api/validation_test.go @@ -21,7 +21,7 @@ func TestValidationMiddlewareWithInvalidRequest(t *testing.T) { engine := inmemory.NewStore() now := time.Now() - srv, err := api.NewServer(engine, clockTest.NewFakePassiveClock(now)) + srv, err := api.NewServer(engine, clockTest.NewFakePassiveClock(now), nil) require.NoError(t, err) r := chi.NewRouter() @@ -45,7 +45,7 @@ func TestValidationMiddlewareWithValidRequest(t *testing.T) { engine := inmemory.NewStore() now := time.Now() - srv, err := api.NewServer(engine, clockTest.NewFakePassiveClock(now)) + srv, err := api.NewServer(engine, clockTest.NewFakePassiveClock(now), nil) require.NoError(t, err) r := chi.NewRouter() @@ -86,7 +86,7 @@ func TestValidationMiddlewareWithUnknownMethod(t *testing.T) { engine := inmemory.NewStore() now := time.Now() - srv, err := api.NewServer(engine, clockTest.NewFakePassiveClock(now)) + srv, err := api.NewServer(engine, clockTest.NewFakePassiveClock(now), nil) require.NoError(t, err) r := chi.NewRouter() diff --git a/manager/cmd/auth_generate_credential.go b/manager/cmd/auth_generate_credential.go new file mode 100644 index 0000000..1b9d5dd --- /dev/null +++ b/manager/cmd/auth_generate_credential.go @@ -0,0 +1,41 @@ +package cmd + +import ( + "crypto/rand" + "fmt" + "github.com/spf13/cobra" + "math/big" +) + +// generateCredentialCmd represents the generateCredentialCmd command +var generateCredentialCmd = &cobra.Command{ + Use: "generate-credential", + Short: "Generates a credential for use as initial token in OCPI registration process", + RunE: func(cmd *cobra.Command, args []string) error { + result, err := generateRandomString() + if err != nil { + return err + } + fmt.Println(result) + + return nil + }, +} + +func generateRandomString() (string, error) { + const letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-" + ret := make([]byte, 64) + for i := 0; i < 64; i++ { + num, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters)))) + if err != nil { + return "", err + } + ret[i] = letters[num.Int64()] + } + + return string(ret), nil +} + +func init() { + authCmd.AddCommand(generateCredentialCmd) +} diff --git a/manager/cmd/serve.go b/manager/cmd/serve.go index 506c2fd..52d4960 100644 --- a/manager/cmd/serve.go +++ b/manager/cmd/serve.go @@ -10,6 +10,7 @@ import ( "github.com/thoughtworks/maeve-csms/manager/server" "go.opentelemetry.io/otel" "golang.org/x/exp/slog" + "k8s.io/utils/clock" ) var ( @@ -44,7 +45,7 @@ the gateway and send appropriate responses.`, tracer := otel.Tracer("manager") - apiServer := server.New("api", cfg.Api.Addr, nil, server.NewApiHandler(settings.Storage)) + apiServer := server.New("api", cfg.Api.Addr, nil, server.NewApiHandler(settings.Storage, settings.OcpiApi)) mqttHandler := mqtt.NewHandler( mqtt.WithMqttBrokerUrls(settings.Mqtt.Urls), @@ -62,6 +63,11 @@ the gateway and send appropriate responses.`, apiServer.Start(errCh) mqttHandler.Connect(errCh) + if settings.OcpiApi != nil { + ocpiServer := server.New("ocpi", cfg.Ocpi.Addr, nil, server.NewOcpiHandler(settings.Storage, clock.RealClock{}, settings.OcpiApi)) + ocpiServer.Start(errCh) + } + err = <-errCh return err }, diff --git a/manager/config/README.md b/manager/config/README.md index a8eb164..2ca90d3 100644 --- a/manager/config/README.md +++ b/manager/config/README.md @@ -152,7 +152,6 @@ There are several implementation of HttpAuthService: | Key | Type | Description | |----------|--------|------------------------------------------------------| | variable | string | Name of the environment variable | -| ttl | string | The duration for which the token is valid, e.g. "1h" | #### Fixed token auth service diff --git a/manager/config/base_config.go b/manager/config/base_config.go index be96cef..8528265 100644 --- a/manager/config/base_config.go +++ b/manager/config/base_config.go @@ -18,6 +18,7 @@ type BaseConfig struct { ContractCertProvider ContractCertProviderConfig `mapstructure:"contract_cert_provider" toml:"contract_cert_provider"` ChargeStationCertProvider ChargeStationCertProviderConfig `mapstructure:"charge_station_cert_provider" toml:"charge_station_cert_provider"` TariffService TariffServiceConfig `mapstructure:"tariff_service" toml:"tariff_service"` + Ocpi *OcpiConfig `mapstructure:"ocpi,omitempty" toml:"ocpi,omitempty"` } var DefaultConfig = BaseConfig{ diff --git a/manager/config/config.go b/manager/config/config.go index 83a2deb..fdd6519 100644 --- a/manager/config/config.go +++ b/manager/config/config.go @@ -7,6 +7,7 @@ import ( "crypto/tls" "fmt" "github.com/subnova/slog-exporter/slogtrace" + "github.com/thoughtworks/maeve-csms/manager/ocpi" "github.com/thoughtworks/maeve-csms/manager/services" "github.com/thoughtworks/maeve-csms/manager/store" "github.com/thoughtworks/maeve-csms/manager/store/firestore" @@ -51,6 +52,7 @@ type Config struct { ContractCertProviderService services.ContractCertificateProvider ChargeStationCertProviderService services.ChargeStationCertificateProvider TariffService services.TariffService + OcpiApi ocpi.Api } func Configure(ctx context.Context, cfg *BaseConfig) (c *Config, err error) { @@ -136,9 +138,35 @@ func Configure(ctx context.Context, cfg *BaseConfig) (c *Config, err error) { return nil, err } + if cfg.Ocpi != nil { + c.OcpiApi, err = getOcpiApi(cfg.Ocpi, c.Storage, httpClient) + if err != nil { + return nil, err + } + } + return } +func getOcpiApi(o *OcpiConfig, engine store.Engine, httpClient *http.Client) (ocpi.Api, error) { + if o.Addr == "" { + return nil, fmt.Errorf("ocpi addr is required") + } + if o.ExternalURL == "" { + return nil, fmt.Errorf("ocpi external url is required") + } + if o.PartyId == "" { + return nil, fmt.Errorf("ocpi party id is required") + } + if o.CountryCode == "" { + return nil, fmt.Errorf("ocpi country code is required") + } + + api := ocpi.NewOCPI(engine, httpClient, o.CountryCode, o.PartyId) + api.SetExternalUrl(o.ExternalURL) + return api, nil +} + func getHttpClient(keylogFile string) (*http.Client, error) { var transport http.RoundTripper diff --git a/manager/config/ocpi_config.go b/manager/config/ocpi_config.go new file mode 100644 index 0000000..7793175 --- /dev/null +++ b/manager/config/ocpi_config.go @@ -0,0 +1,8 @@ +package config + +type OcpiConfig struct { + Addr string `mapstructure:"addr" toml:"addr"` + ExternalURL string `mapstructure:"external_url" toml:"external_url"` + CountryCode string `mapstructure:"country_code" toml:"country_code"` + PartyId string `mapstructure:"party_id" toml:"party_id"` +} diff --git a/manager/go.mod b/manager/go.mod index 8dcfe6b..fbc2eee 100644 --- a/manager/go.mod +++ b/manager/go.mod @@ -78,6 +78,7 @@ require ( github.com/google/s2a-go v0.1.4 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.11.0 // indirect + github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect github.com/imdario/mergo v0.3.15 // indirect diff --git a/manager/ocpi/auth.go b/manager/ocpi/auth.go new file mode 100644 index 0000000..0045687 --- /dev/null +++ b/manager/ocpi/auth.go @@ -0,0 +1,53 @@ +package ocpi + +import ( + "context" + "fmt" + "github.com/getkin/kin-openapi/openapi3filter" + "github.com/thoughtworks/maeve-csms/manager/store" + "net/http" + "regexp" +) + +var authzHeaderRegexp = regexp.MustCompile(`^Token (.*)$`) + +func NewTokenAuthenticationFunc(engine store.Engine) openapi3filter.AuthenticationFunc { + return func(ctx context.Context, input *openapi3filter.AuthenticationInput) error { + authzHeader := input.RequestValidationInput.Request.Header.Get("Authorization") + matches := authzHeaderRegexp.FindStringSubmatch(authzHeader) + if len(matches) != 2 { + return input.NewError(nil) + } + + reg, err := engine.GetRegistrationDetails(ctx, matches[1]) + if err != nil { + return input.NewError(err) + } + if reg == nil { + return input.NewError(fmt.Errorf("unknown token")) + } + if reg.Status != store.OcpiRegistrationStatusRegistered { + allowed := false + switch input.RequestValidationInput.Request.Method { + case http.MethodGet: + switch input.RequestValidationInput.Request.URL.Path { + case "/ocpi/versions": + allowed = true + case "/ocpi/2.2": + allowed = true + } + case http.MethodPost: + switch input.RequestValidationInput.Request.URL.Path { + case "/ocpi/2.2/credentials": + allowed = true + } + } + + if !allowed { + return input.NewError(fmt.Errorf("unregistered token")) + } + } + + return nil + } +} diff --git a/manager/ocpi/auth_test.go b/manager/ocpi/auth_test.go new file mode 100644 index 0000000..bc3f76f --- /dev/null +++ b/manager/ocpi/auth_test.go @@ -0,0 +1,130 @@ +package ocpi_test + +import ( + "context" + "fmt" + "github.com/getkin/kin-openapi/openapi3" + "github.com/getkin/kin-openapi/openapi3filter" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/thoughtworks/maeve-csms/manager/ocpi" + "github.com/thoughtworks/maeve-csms/manager/store" + "github.com/thoughtworks/maeve-csms/manager/store/inmemory" + "net/http" + "net/http/httptest" + "testing" +) + +func TestAuthenticationWithPendingToken(t *testing.T) { + token := "abcdef123456" + + engine := inmemory.NewStore() + err := engine.SetRegistrationDetails(context.Background(), token, &store.OcpiRegistration{Status: store.OcpiRegistrationStatusPending}) + require.NoError(t, err) + + authFn := ocpi.NewTokenAuthenticationFunc(engine) + + endpoints := []struct { + Path string + Method string + Success bool + }{ + {Path: "/ocpi/versions", Method: http.MethodGet, Success: true}, + {Path: "/ocpi/2.2", Method: http.MethodGet, Success: true}, + {Path: "/ocpi/2.2/credentials", Method: http.MethodPost, Success: true}, + {Path: "/ocpi/2.2/credentials", Method: http.MethodGet, Success: false}, + {Path: "/ocpi/2.2/credentials", Method: http.MethodPut, Success: false}, + {Path: "/ocpi/2.2/credentials", Method: http.MethodDelete, Success: false}, + } + + for _, endpoint := range endpoints { + t.Run(fmt.Sprintf("%s %s", endpoint.Method, endpoint.Path), func(t *testing.T) { + req := httptest.NewRequest(endpoint.Method, endpoint.Path, nil) + req.Header.Add("Authorization", fmt.Sprintf("Token %s", token)) + err = authFn(context.Background(), &openapi3filter.AuthenticationInput{ + RequestValidationInput: &openapi3filter.RequestValidationInput{ + Request: req, + }, + SecuritySchemeName: "token", + SecurityScheme: &openapi3.SecurityScheme{ + Type: "http", + Scheme: "bearer", + }, + }) + if endpoint.Success { + assert.NoError(t, err) + } else { + assert.ErrorContains(t, err, "authorization failed: unregistered token") + } + }) + } +} + +func TestAuthenticationWithRegisteredToken(t *testing.T) { + token := "abcdef123456" + + engine := inmemory.NewStore() + err := engine.SetRegistrationDetails(context.Background(), token, &store.OcpiRegistration{Status: store.OcpiRegistrationStatusRegistered}) + require.NoError(t, err) + + authFn := ocpi.NewTokenAuthenticationFunc(engine) + + endpoints := []struct { + Path string + Method string + Success bool + }{ + {Path: "/ocpi/versions", Method: http.MethodGet, Success: true}, + {Path: "/ocpi/2.2", Method: http.MethodGet, Success: true}, + {Path: "/ocpi/2.2/credentials", Method: http.MethodPost, Success: true}, + {Path: "/ocpi/2.2/credentials", Method: http.MethodGet, Success: true}, + {Path: "/ocpi/2.2/credentials", Method: http.MethodPut, Success: true}, + {Path: "/ocpi/2.2/credentials", Method: http.MethodDelete, Success: true}, + } + + for _, endpoint := range endpoints { + t.Run(fmt.Sprintf("%s %s", endpoint.Method, endpoint.Path), func(t *testing.T) { + req := httptest.NewRequest(endpoint.Method, endpoint.Path, nil) + req.Header.Add("Authorization", fmt.Sprintf("Token %s", token)) + err = authFn(context.Background(), &openapi3filter.AuthenticationInput{ + RequestValidationInput: &openapi3filter.RequestValidationInput{ + Request: req, + }, + SecuritySchemeName: "token", + SecurityScheme: &openapi3.SecurityScheme{ + Type: "http", + Scheme: "bearer", + }, + }) + if endpoint.Success { + assert.NoError(t, err) + } else { + assert.ErrorContains(t, err, "authorization failed: unregistered token") + } + }) + } +} + +func TestAuthenticationWithUnknownToken(t *testing.T) { + token := "abcdef123456" + + engine := inmemory.NewStore() + + authFn := ocpi.NewTokenAuthenticationFunc(engine) + + req := httptest.NewRequest(http.MethodGet, "/ocpi/versions", nil) + req.Header.Add("Authorization", fmt.Sprintf("Token %s", token)) + + err := authFn(context.Background(), &openapi3filter.AuthenticationInput{ + RequestValidationInput: &openapi3filter.RequestValidationInput{ + Request: req, + }, + SecuritySchemeName: "token", + SecurityScheme: &openapi3.SecurityScheme{ + Type: "http", + Scheme: "bearer", + }, + }) + + assert.ErrorContains(t, err, "authorization failed: unknown token") +} diff --git a/manager/ocpi/cfg.yaml b/manager/ocpi/cfg.yaml new file mode 100644 index 0000000..dd896cb --- /dev/null +++ b/manager/ocpi/cfg.yaml @@ -0,0 +1,8 @@ +package: ocpi +generate: + chi-server: true + models: true + embedded-spec: true +compatibility: + apply-chi-middleware-first-to-last: true +output: ocpi.gen.go \ No newline at end of file diff --git a/manager/ocpi/error.go b/manager/ocpi/error.go new file mode 100644 index 0000000..a9b93ae --- /dev/null +++ b/manager/ocpi/error.go @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: Apache-2.0 + +package ocpi + +import ( + "github.com/go-chi/render" + "net/http" +) + +type ErrResponse struct { + Err error `json:"-"` // low-level runtime error + HTTPStatusCode int `json:"-"` // http response status code + + StatusText string `json:"status"` // user-level status message + AppCode int64 `json:"code,omitempty"` // application-specific error code + ErrorText string `json:"error,omitempty"` // application-level error message, for debugging +} + +func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error { + render.Status(r, e.HTTPStatusCode) + return nil +} + +func ErrInvalidRequest(err error) render.Renderer { + return &ErrResponse{ + Err: err, + HTTPStatusCode: http.StatusBadRequest, + StatusText: http.StatusText(http.StatusBadRequest), + ErrorText: err.Error(), + } +} + +func ErrInternalError(err error) render.Renderer { + return &ErrResponse{ + Err: err, + HTTPStatusCode: http.StatusInternalServerError, + StatusText: http.StatusText(http.StatusInternalServerError), + ErrorText: err.Error(), + } +} + +var ErrNotFound = &ErrResponse{ + HTTPStatusCode: http.StatusNotFound, + StatusText: http.StatusText(http.StatusNotFound), +} diff --git a/manager/ocpi/ocpi.gen.go b/manager/ocpi/ocpi.gen.go new file mode 100644 index 0000000..15a55f5 --- /dev/null +++ b/manager/ocpi/ocpi.gen.go @@ -0,0 +1,12347 @@ +// Package ocpi provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen version v1.13.0 DO NOT EDIT. + +//lint:file-ignore * Ignore as this is generated + +package ocpi + +import ( + "bytes" + "compress/gzip" + "context" + "encoding/base64" + "fmt" + "net/http" + "net/url" + "path" + "strings" + + "github.com/deepmap/oapi-codegen/pkg/runtime" + "github.com/getkin/kin-openapi/openapi3" + "github.com/go-chi/chi/v5" +) + +const ( + TokenScopes = "token.Scopes" +) + +// Defines values for AuthorizationInfoAllowed. +const ( + AuthorizationInfoAllowedALLOWED AuthorizationInfoAllowed = "ALLOWED" + AuthorizationInfoAllowedBLOCKED AuthorizationInfoAllowed = "BLOCKED" + AuthorizationInfoAllowedEXPIRED AuthorizationInfoAllowed = "EXPIRED" + AuthorizationInfoAllowedNOCREDIT AuthorizationInfoAllowed = "NO_CREDIT" + AuthorizationInfoAllowedNOTALLOWED AuthorizationInfoAllowed = "NOT_ALLOWED" +) + +// Defines values for CDRAuthMethod. +const ( + CDRAuthMethodAUTHREQUEST CDRAuthMethod = "AUTH_REQUEST" + CDRAuthMethodCOMMAND CDRAuthMethod = "COMMAND" + CDRAuthMethodWHITELIST CDRAuthMethod = "WHITELIST" +) + +// Defines values for CdrDimensionType. +const ( + CdrDimensionTypeCURRENT CdrDimensionType = "CURRENT" + CdrDimensionTypeENERGY CdrDimensionType = "ENERGY" + CdrDimensionTypeENERGYEXPORT CdrDimensionType = "ENERGY_EXPORT" + CdrDimensionTypeENERGYIMPORT CdrDimensionType = "ENERGY_IMPORT" + CdrDimensionTypeMAXCURRENT CdrDimensionType = "MAX_CURRENT" + CdrDimensionTypeMAXPOWER CdrDimensionType = "MAX_POWER" + CdrDimensionTypeMINCURRENT CdrDimensionType = "MIN_CURRENT" + CdrDimensionTypeMINPOWER CdrDimensionType = "MIN_POWER" + CdrDimensionTypePARKINGTIME CdrDimensionType = "PARKING_TIME" + CdrDimensionTypePOWER CdrDimensionType = "POWER" + CdrDimensionTypeRESERVATIONTIME CdrDimensionType = "RESERVATION_TIME" + CdrDimensionTypeSTATEOFCHARGE CdrDimensionType = "STATE_OF_CHARGE" + CdrDimensionTypeTIME CdrDimensionType = "TIME" +) + +// Defines values for CdrLocationConnectorFormat. +const ( + CdrLocationConnectorFormatCABLE CdrLocationConnectorFormat = "CABLE" + CdrLocationConnectorFormatSOCKET CdrLocationConnectorFormat = "SOCKET" +) + +// Defines values for CdrLocationConnectorPowerType. +const ( + CdrLocationConnectorPowerTypeAC1PHASE CdrLocationConnectorPowerType = "AC_1_PHASE" + CdrLocationConnectorPowerTypeAC3PHASE CdrLocationConnectorPowerType = "AC_3_PHASE" + CdrLocationConnectorPowerTypeDC CdrLocationConnectorPowerType = "DC" +) + +// Defines values for CdrLocationConnectorStandard. +const ( + CdrLocationConnectorStandardCHADEMO CdrLocationConnectorStandard = "CHADEMO" + CdrLocationConnectorStandardDOMESTICA CdrLocationConnectorStandard = "DOMESTIC_A" + CdrLocationConnectorStandardDOMESTICB CdrLocationConnectorStandard = "DOMESTIC_B" + CdrLocationConnectorStandardDOMESTICC CdrLocationConnectorStandard = "DOMESTIC_C" + CdrLocationConnectorStandardDOMESTICD CdrLocationConnectorStandard = "DOMESTIC_D" + CdrLocationConnectorStandardDOMESTICE CdrLocationConnectorStandard = "DOMESTIC_E" + CdrLocationConnectorStandardDOMESTICF CdrLocationConnectorStandard = "DOMESTIC_F" + CdrLocationConnectorStandardDOMESTICG CdrLocationConnectorStandard = "DOMESTIC_G" + CdrLocationConnectorStandardDOMESTICH CdrLocationConnectorStandard = "DOMESTIC_H" + CdrLocationConnectorStandardDOMESTICI CdrLocationConnectorStandard = "DOMESTIC_I" + CdrLocationConnectorStandardDOMESTICJ CdrLocationConnectorStandard = "DOMESTIC_J" + CdrLocationConnectorStandardDOMESTICK CdrLocationConnectorStandard = "DOMESTIC_K" + CdrLocationConnectorStandardDOMESTICL CdrLocationConnectorStandard = "DOMESTIC_L" + CdrLocationConnectorStandardIEC603092Single16 CdrLocationConnectorStandard = "IEC_60309_2_single_16" + CdrLocationConnectorStandardIEC603092Three16 CdrLocationConnectorStandard = "IEC_60309_2_three_16" + CdrLocationConnectorStandardIEC603092Three32 CdrLocationConnectorStandard = "IEC_60309_2_three_32" + CdrLocationConnectorStandardIEC603092Three64 CdrLocationConnectorStandard = "IEC_60309_2_three_64" + CdrLocationConnectorStandardIEC62196T1 CdrLocationConnectorStandard = "IEC_62196_T1" + CdrLocationConnectorStandardIEC62196T1COMBO CdrLocationConnectorStandard = "IEC_62196_T1_COMBO" + CdrLocationConnectorStandardIEC62196T2 CdrLocationConnectorStandard = "IEC_62196_T2" + CdrLocationConnectorStandardIEC62196T2COMBO CdrLocationConnectorStandard = "IEC_62196_T2_COMBO" + CdrLocationConnectorStandardIEC62196T3A CdrLocationConnectorStandard = "IEC_62196_T3A" + CdrLocationConnectorStandardIEC62196T3C CdrLocationConnectorStandard = "IEC_62196_T3C" + CdrLocationConnectorStandardPANTOGRAPHBOTTOMUP CdrLocationConnectorStandard = "PANTOGRAPH_BOTTOM_UP" + CdrLocationConnectorStandardPANTOGRAPHTOPDOWN CdrLocationConnectorStandard = "PANTOGRAPH_TOP_DOWN" + CdrLocationConnectorStandardTESLAR CdrLocationConnectorStandard = "TESLA_R" + CdrLocationConnectorStandardTESLAS CdrLocationConnectorStandard = "TESLA_S" +) + +// Defines values for CdrTokenType. +const ( + CdrTokenTypeADHOCUSER CdrTokenType = "AD_HOC_USER" + CdrTokenTypeAPPUSER CdrTokenType = "APP_USER" + CdrTokenTypeOTHER CdrTokenType = "OTHER" + CdrTokenTypeRFID CdrTokenType = "RFID" +) + +// Defines values for ChargingPreferencesProfileType. +const ( + ChargingPreferencesProfileTypeCHEAP ChargingPreferencesProfileType = "CHEAP" + ChargingPreferencesProfileTypeFAST ChargingPreferencesProfileType = "FAST" + ChargingPreferencesProfileTypeGREEN ChargingPreferencesProfileType = "GREEN" + ChargingPreferencesProfileTypeREGULAR ChargingPreferencesProfileType = "REGULAR" +) + +// Defines values for ChargingProfileChargingRateUnit. +const ( + A ChargingProfileChargingRateUnit = "A" + W ChargingProfileChargingRateUnit = "W" +) + +// Defines values for ChargingProfileResponseResult. +const ( + ChargingProfileResponseResultACCEPTED ChargingProfileResponseResult = "ACCEPTED" + ChargingProfileResponseResultNOTSUPPORTED ChargingProfileResponseResult = "NOT_SUPPORTED" + ChargingProfileResponseResultREJECTED ChargingProfileResponseResult = "REJECTED" + ChargingProfileResponseResultTOOOFTEN ChargingProfileResponseResult = "TOO_OFTEN" + ChargingProfileResponseResultUNKNOWNSESSION ChargingProfileResponseResult = "UNKNOWN_SESSION" +) + +// Defines values for CommandResponseResult. +const ( + CommandResponseResultACCEPTED CommandResponseResult = "ACCEPTED" + CommandResponseResultNOTSUPPORTED CommandResponseResult = "NOT_SUPPORTED" + CommandResponseResultREJECTED CommandResponseResult = "REJECTED" + CommandResponseResultUNKNOWNSESSION CommandResponseResult = "UNKNOWN_SESSION" +) + +// Defines values for CommandResultResult. +const ( + CommandResultResultACCEPTED CommandResultResult = "ACCEPTED" + CommandResultResultCANCELEDRESERVATION CommandResultResult = "CANCELED_RESERVATION" + CommandResultResultEVSEINOPERATIVE CommandResultResult = "EVSE_INOPERATIVE" + CommandResultResultEVSEOCCUPIED CommandResultResult = "EVSE_OCCUPIED" + CommandResultResultFAILED CommandResultResult = "FAILED" + CommandResultResultNOTSUPPORTED CommandResultResult = "NOT_SUPPORTED" + CommandResultResultREJECTED CommandResultResult = "REJECTED" + CommandResultResultTIMEOUT CommandResultResult = "TIMEOUT" + CommandResultResultUNKNOWNRESERVATION CommandResultResult = "UNKNOWN_RESERVATION" +) + +// Defines values for ConnectorFormat. +const ( + ConnectorFormatCABLE ConnectorFormat = "CABLE" + ConnectorFormatSOCKET ConnectorFormat = "SOCKET" +) + +// Defines values for ConnectorPowerType. +const ( + ConnectorPowerTypeAC1PHASE ConnectorPowerType = "AC_1_PHASE" + ConnectorPowerTypeAC3PHASE ConnectorPowerType = "AC_3_PHASE" + ConnectorPowerTypeDC ConnectorPowerType = "DC" +) + +// Defines values for ConnectorStandard. +const ( + ConnectorStandardCHADEMO ConnectorStandard = "CHADEMO" + ConnectorStandardCHAOJI ConnectorStandard = "CHAOJI" + ConnectorStandardDOMESTICA ConnectorStandard = "DOMESTIC_A" + ConnectorStandardDOMESTICB ConnectorStandard = "DOMESTIC_B" + ConnectorStandardDOMESTICC ConnectorStandard = "DOMESTIC_C" + ConnectorStandardDOMESTICD ConnectorStandard = "DOMESTIC_D" + ConnectorStandardDOMESTICE ConnectorStandard = "DOMESTIC_E" + ConnectorStandardDOMESTICF ConnectorStandard = "DOMESTIC_F" + ConnectorStandardDOMESTICG ConnectorStandard = "DOMESTIC_G" + ConnectorStandardDOMESTICH ConnectorStandard = "DOMESTIC_H" + ConnectorStandardDOMESTICI ConnectorStandard = "DOMESTIC_I" + ConnectorStandardDOMESTICJ ConnectorStandard = "DOMESTIC_J" + ConnectorStandardDOMESTICK ConnectorStandard = "DOMESTIC_K" + ConnectorStandardDOMESTICL ConnectorStandard = "DOMESTIC_L" + ConnectorStandardGBTAC ConnectorStandard = "GBT_AC" + ConnectorStandardGBTDC ConnectorStandard = "GBT_DC" + ConnectorStandardIEC603092Single16 ConnectorStandard = "IEC_60309_2_single_16" + ConnectorStandardIEC603092Three16 ConnectorStandard = "IEC_60309_2_three_16" + ConnectorStandardIEC603092Three32 ConnectorStandard = "IEC_60309_2_three_32" + ConnectorStandardIEC603092Three64 ConnectorStandard = "IEC_60309_2_three_64" + ConnectorStandardIEC62196T1 ConnectorStandard = "IEC_62196_T1" + ConnectorStandardIEC62196T1COMBO ConnectorStandard = "IEC_62196_T1_COMBO" + ConnectorStandardIEC62196T2 ConnectorStandard = "IEC_62196_T2" + ConnectorStandardIEC62196T2COMBO ConnectorStandard = "IEC_62196_T2_COMBO" + ConnectorStandardIEC62196T3A ConnectorStandard = "IEC_62196_T3A" + ConnectorStandardIEC62196T3C ConnectorStandard = "IEC_62196_T3C" + ConnectorStandardNEMA1030 ConnectorStandard = "NEMA_10_30" + ConnectorStandardNEMA1050 ConnectorStandard = "NEMA_10_50" + ConnectorStandardNEMA1430 ConnectorStandard = "NEMA_14_30" + ConnectorStandardNEMA1450 ConnectorStandard = "NEMA_14_50" + ConnectorStandardNEMA520 ConnectorStandard = "NEMA_5_20" + ConnectorStandardNEMA630 ConnectorStandard = "NEMA_6_30" + ConnectorStandardNEMA650 ConnectorStandard = "NEMA_6_50" + ConnectorStandardPANTOGRAPHBOTTOMUP ConnectorStandard = "PANTOGRAPH_BOTTOM_UP" + ConnectorStandardPANTOGRAPHTOPDOWN ConnectorStandard = "PANTOGRAPH_TOP_DOWN" + ConnectorStandardTESLAR ConnectorStandard = "TESLA_R" + ConnectorStandardTESLAS ConnectorStandard = "TESLA_S" + ConnectorStandardUNKNOWN ConnectorStandard = "UNKNOWN" +) + +// Defines values for CredentialsRoleRole. +const ( + CredentialsRoleRoleCPO CredentialsRoleRole = "CPO" + CredentialsRoleRoleEMSP CredentialsRoleRole = "EMSP" + CredentialsRoleRoleHUB CredentialsRoleRole = "HUB" + CredentialsRoleRoleNAP CredentialsRoleRole = "NAP" + CredentialsRoleRoleNSP CredentialsRoleRole = "NSP" + CredentialsRoleRoleOTHER CredentialsRoleRole = "OTHER" + CredentialsRoleRoleSCSP CredentialsRoleRole = "SCSP" +) + +// Defines values for EndpointRole. +const ( + RECEIVER EndpointRole = "RECEIVER" + SENDER EndpointRole = "SENDER" +) + +// Defines values for EnergySourceSource. +const ( + COAL EnergySourceSource = "COAL" + GAS EnergySourceSource = "GAS" + GENERALFOSSIL EnergySourceSource = "GENERAL_FOSSIL" + GENERALGREEN EnergySourceSource = "GENERAL_GREEN" + NUCLEAR EnergySourceSource = "NUCLEAR" + SOLAR EnergySourceSource = "SOLAR" + WATER EnergySourceSource = "WATER" + WIND EnergySourceSource = "WIND" +) + +// Defines values for EnvironmentalImpactCategory. +const ( + CARBONDIOXIDE EnvironmentalImpactCategory = "CARBON_DIOXIDE" + NUCLEARWASTE EnvironmentalImpactCategory = "NUCLEAR_WASTE" +) + +// Defines values for EvseCapabilities. +const ( + CHARGINGPREFERENCESCAPABLE EvseCapabilities = "CHARGING_PREFERENCES_CAPABLE" + CHARGINGPROFILECAPABLE EvseCapabilities = "CHARGING_PROFILE_CAPABLE" + CHIPCARDSUPPORT EvseCapabilities = "CHIP_CARD_SUPPORT" + CONTACTLESSCARDSUPPORT EvseCapabilities = "CONTACTLESS_CARD_SUPPORT" + CREDITCARDPAYABLE EvseCapabilities = "CREDIT_CARD_PAYABLE" + DEBITCARDPAYABLE EvseCapabilities = "DEBIT_CARD_PAYABLE" + PEDTERMINAL EvseCapabilities = "PED_TERMINAL" + REMOTESTARTSTOPCAPABLE EvseCapabilities = "REMOTE_START_STOP_CAPABLE" + RESERVABLE EvseCapabilities = "RESERVABLE" + RFIDREADER EvseCapabilities = "RFID_READER" + TOKENGROUPCAPABLE EvseCapabilities = "TOKEN_GROUP_CAPABLE" + UNLOCKCAPABLE EvseCapabilities = "UNLOCK_CAPABLE" +) + +// Defines values for EvseParkingRestrictions. +const ( + CUSTOMERS EvseParkingRestrictions = "CUSTOMERS" + DISABLED EvseParkingRestrictions = "DISABLED" + EVONLY EvseParkingRestrictions = "EV_ONLY" + MOTORCYCLES EvseParkingRestrictions = "MOTORCYCLES" + PLUGGED EvseParkingRestrictions = "PLUGGED" +) + +// Defines values for EvseStatus. +const ( + EvseStatusAVAILABLE EvseStatus = "AVAILABLE" + EvseStatusBLOCKED EvseStatus = "BLOCKED" + EvseStatusCHARGING EvseStatus = "CHARGING" + EvseStatusINOPERATIVE EvseStatus = "INOPERATIVE" + EvseStatusOUTOFORDER EvseStatus = "OUTOFORDER" + EvseStatusPLANNED EvseStatus = "PLANNED" + EvseStatusREMOVED EvseStatus = "REMOVED" + EvseStatusRESERVED EvseStatus = "RESERVED" + EvseStatusUNKNOWN EvseStatus = "UNKNOWN" +) + +// Defines values for GenericChargingProfileResultResult. +const ( + GenericChargingProfileResultResultACCEPTED GenericChargingProfileResultResult = "ACCEPTED" + GenericChargingProfileResultResultREJECTED GenericChargingProfileResultResult = "REJECTED" + GenericChargingProfileResultResultUNKNOWN GenericChargingProfileResultResult = "UNKNOWN" +) + +// Defines values for ImageCategory. +const ( + ImageCategoryCHARGER ImageCategory = "CHARGER" + ImageCategoryENTRANCE ImageCategory = "ENTRANCE" + ImageCategoryLOCATION ImageCategory = "LOCATION" + ImageCategoryNETWORK ImageCategory = "NETWORK" + ImageCategoryOPERATOR ImageCategory = "OPERATOR" + ImageCategoryOTHER ImageCategory = "OTHER" + ImageCategoryOWNER ImageCategory = "OWNER" +) + +// Defines values for LocationFacilities. +const ( + LocationFacilitiesAIRPORT LocationFacilities = "AIRPORT" + LocationFacilitiesBIKESHARING LocationFacilities = "BIKE_SHARING" + LocationFacilitiesBUSSTOP LocationFacilities = "BUS_STOP" + LocationFacilitiesCAFE LocationFacilities = "CAFE" + LocationFacilitiesCARPOOLPARKING LocationFacilities = "CARPOOL_PARKING" + LocationFacilitiesFUELSTATION LocationFacilities = "FUEL_STATION" + LocationFacilitiesHOTEL LocationFacilities = "HOTEL" + LocationFacilitiesMALL LocationFacilities = "MALL" + LocationFacilitiesMETROSTATION LocationFacilities = "METRO_STATION" + LocationFacilitiesMUSEUM LocationFacilities = "MUSEUM" + LocationFacilitiesNATURE LocationFacilities = "NATURE" + LocationFacilitiesPARKINGLOT LocationFacilities = "PARKING_LOT" + LocationFacilitiesRECREATIONAREA LocationFacilities = "RECREATION_AREA" + LocationFacilitiesRESTAURANT LocationFacilities = "RESTAURANT" + LocationFacilitiesSPORT LocationFacilities = "SPORT" + LocationFacilitiesSUPERMARKET LocationFacilities = "SUPERMARKET" + LocationFacilitiesTAXISTAND LocationFacilities = "TAXI_STAND" + LocationFacilitiesTRAINSTATION LocationFacilities = "TRAIN_STATION" + LocationFacilitiesTRAMSTOP LocationFacilities = "TRAM_STOP" + LocationFacilitiesWIFI LocationFacilities = "WIFI" +) + +// Defines values for LocationParkingType. +const ( + LocationParkingTypeALONGMOTORWAY LocationParkingType = "ALONG_MOTORWAY" + LocationParkingTypeONDRIVEWAY LocationParkingType = "ON_DRIVEWAY" + LocationParkingTypeONSTREET LocationParkingType = "ON_STREET" + LocationParkingTypePARKINGGARAGE LocationParkingType = "PARKING_GARAGE" + LocationParkingTypePARKINGLOT LocationParkingType = "PARKING_LOT" + LocationParkingTypeUNDERGROUNDGARAGE LocationParkingType = "UNDERGROUND_GARAGE" +) + +// Defines values for OcpiResponseChargingPreferencesResponseData. +const ( + ACCEPTED OcpiResponseChargingPreferencesResponseData = "ACCEPTED" + DEPARTUREREQUIRED OcpiResponseChargingPreferencesResponseData = "DEPARTURE_REQUIRED" + ENERGYNEEDREQUIRED OcpiResponseChargingPreferencesResponseData = "ENERGY_NEED_REQUIRED" + NOTPOSSIBLE OcpiResponseChargingPreferencesResponseData = "NOT_POSSIBLE" + PROFILETYPENOTSUPPORTED OcpiResponseChargingPreferencesResponseData = "PROFILE_TYPE_NOT_SUPPORTED" +) + +// Defines values for PriceComponentType. +const ( + PriceComponentTypeENERGY PriceComponentType = "ENERGY" + PriceComponentTypeFLAT PriceComponentType = "FLAT" + PriceComponentTypePARKINGTIME PriceComponentType = "PARKING_TIME" + PriceComponentTypeTIME PriceComponentType = "TIME" +) + +// Defines values for PublishTokenTypeType. +const ( + PublishTokenTypeTypeADHOCUSER PublishTokenTypeType = "AD_HOC_USER" + PublishTokenTypeTypeAPPUSER PublishTokenTypeType = "APP_USER" + PublishTokenTypeTypeOTHER PublishTokenTypeType = "OTHER" + PublishTokenTypeTypeRFID PublishTokenTypeType = "RFID" +) + +// Defines values for SessionAuthMethod. +const ( + SessionAuthMethodAUTHREQUEST SessionAuthMethod = "AUTH_REQUEST" + SessionAuthMethodCOMMAND SessionAuthMethod = "COMMAND" + SessionAuthMethodWHITELIST SessionAuthMethod = "WHITELIST" +) + +// Defines values for SessionStatus. +const ( + SessionStatusACTIVE SessionStatus = "ACTIVE" + SessionStatusCOMPLETED SessionStatus = "COMPLETED" + SessionStatusINVALID SessionStatus = "INVALID" + SessionStatusPENDING SessionStatus = "PENDING" + SessionStatusRESERVATION SessionStatus = "RESERVATION" +) + +// Defines values for StatusScheduleStatus. +const ( + AVAILABLE StatusScheduleStatus = "AVAILABLE" + BLOCKED StatusScheduleStatus = "BLOCKED" + CHARGING StatusScheduleStatus = "CHARGING" + INOPERATIVE StatusScheduleStatus = "INOPERATIVE" + OUTOFORDER StatusScheduleStatus = "OUTOFORDER" + PLANNED StatusScheduleStatus = "PLANNED" + REMOVED StatusScheduleStatus = "REMOVED" + RESERVED StatusScheduleStatus = "RESERVED" + UNKNOWN StatusScheduleStatus = "UNKNOWN" +) + +// Defines values for TariffType. +const ( + TariffTypeADHOCPAYMENT TariffType = "AD_HOC_PAYMENT" + TariffTypePROFILECHEAP TariffType = "PROFILE_CHEAP" + TariffTypePROFILEFAST TariffType = "PROFILE_FAST" + TariffTypePROFILEGREEN TariffType = "PROFILE_GREEN" + TariffTypeREGULAR TariffType = "REGULAR" +) + +// Defines values for TariffRestrictionsDayOfWeek. +const ( + FRIDAY TariffRestrictionsDayOfWeek = "FRIDAY" + MONDAY TariffRestrictionsDayOfWeek = "MONDAY" + SATURDAY TariffRestrictionsDayOfWeek = "SATURDAY" + SUNDAY TariffRestrictionsDayOfWeek = "SUNDAY" + THURSDAY TariffRestrictionsDayOfWeek = "THURSDAY" + TUESDAY TariffRestrictionsDayOfWeek = "TUESDAY" + WEDNESDAY TariffRestrictionsDayOfWeek = "WEDNESDAY" +) + +// Defines values for TariffRestrictionsReservation. +const ( + TariffRestrictionsReservationRESERVATION TariffRestrictionsReservation = "RESERVATION" + TariffRestrictionsReservationRESERVATIONEXPIRES TariffRestrictionsReservation = "RESERVATION_EXPIRES" +) + +// Defines values for TokenDefaultProfileType. +const ( + CHEAP TokenDefaultProfileType = "CHEAP" + FAST TokenDefaultProfileType = "FAST" + GREEN TokenDefaultProfileType = "GREEN" + REGULAR TokenDefaultProfileType = "REGULAR" +) + +// Defines values for TokenType. +const ( + TokenTypeADHOCUSER TokenType = "AD_HOC_USER" + TokenTypeAPPUSER TokenType = "APP_USER" + TokenTypeOTHER TokenType = "OTHER" + TokenTypeRFID TokenType = "RFID" +) + +// Defines values for TokenWhitelist. +const ( + ALLOWED TokenWhitelist = "ALLOWED" + ALLOWEDOFFLINE TokenWhitelist = "ALLOWED_OFFLINE" + ALWAYS TokenWhitelist = "ALWAYS" + NEVER TokenWhitelist = "NEVER" +) + +// Defines values for GetClientOwnedTokenParamsType. +const ( + GetClientOwnedTokenParamsTypeADHOCUSER GetClientOwnedTokenParamsType = "AD_HOC_USER" + GetClientOwnedTokenParamsTypeAPPUSER GetClientOwnedTokenParamsType = "APP_USER" + GetClientOwnedTokenParamsTypeOTHER GetClientOwnedTokenParamsType = "OTHER" + GetClientOwnedTokenParamsTypeRFID GetClientOwnedTokenParamsType = "RFID" +) + +// Defines values for PatchClientOwnedTokenParamsType. +const ( + PatchClientOwnedTokenParamsTypeADHOCUSER PatchClientOwnedTokenParamsType = "AD_HOC_USER" + PatchClientOwnedTokenParamsTypeAPPUSER PatchClientOwnedTokenParamsType = "APP_USER" + PatchClientOwnedTokenParamsTypeOTHER PatchClientOwnedTokenParamsType = "OTHER" + PatchClientOwnedTokenParamsTypeRFID PatchClientOwnedTokenParamsType = "RFID" +) + +// Defines values for PutClientOwnedTokenParamsType. +const ( + PutClientOwnedTokenParamsTypeADHOCUSER PutClientOwnedTokenParamsType = "AD_HOC_USER" + PutClientOwnedTokenParamsTypeAPPUSER PutClientOwnedTokenParamsType = "APP_USER" + PutClientOwnedTokenParamsTypeOTHER PutClientOwnedTokenParamsType = "OTHER" + PutClientOwnedTokenParamsTypeRFID PutClientOwnedTokenParamsType = "RFID" +) + +// Defines values for PostAsyncResponseParamsCommand. +const ( + CANCELRESERVATION PostAsyncResponseParamsCommand = "CANCEL_RESERVATION" + RESERVENOW PostAsyncResponseParamsCommand = "RESERVE_NOW" + STARTSESSION PostAsyncResponseParamsCommand = "START_SESSION" + STOPSESSION PostAsyncResponseParamsCommand = "STOP_SESSION" + UNLOCKCONNECTOR PostAsyncResponseParamsCommand = "UNLOCK_CONNECTOR" +) + +// Defines values for PostRealTimeTokenAuthorizationParamsType. +const ( + ADHOCUSER PostRealTimeTokenAuthorizationParamsType = "AD_HOC_USER" + APPUSER PostRealTimeTokenAuthorizationParamsType = "APP_USER" + OTHER PostRealTimeTokenAuthorizationParamsType = "OTHER" + RFID PostRealTimeTokenAuthorizationParamsType = "RFID" +) + +// ActiveChargingProfile defines model for ActiveChargingProfile. +type ActiveChargingProfile struct { + ChargingProfile ChargingProfile `json:"charging_profile"` + StartDateTime string `json:"start_date_time"` +} + +// AdditionalGeoLocation defines model for AdditionalGeoLocation. +type AdditionalGeoLocation struct { + Latitude string `json:"latitude"` + Longitude string `json:"longitude"` + Name *DisplayText `json:"name,omitempty"` +} + +// AuthorizationInfo defines model for AuthorizationInfo. +type AuthorizationInfo struct { + Allowed AuthorizationInfoAllowed `json:"allowed"` + AuthorizationReference *string `json:"authorization_reference,omitempty"` + Info *DisplayText `json:"info,omitempty"` + Location *LocationReferences `json:"location,omitempty"` + Token Token `json:"token"` +} + +// AuthorizationInfoAllowed defines model for AuthorizationInfo.Allowed. +type AuthorizationInfoAllowed string + +// BusinessDetails defines model for BusinessDetails. +type BusinessDetails struct { + Logo *Image `json:"logo,omitempty"` + Name string `json:"name"` + Website *string `json:"website,omitempty"` +} + +// CDR defines model for CDR. +type CDR struct { + AuthMethod CDRAuthMethod `json:"auth_method"` + AuthorizationReference *string `json:"authorization_reference,omitempty"` + CdrLocation CdrLocation `json:"cdr_location"` + CdrToken CdrToken `json:"cdr_token"` + ChargingPeriods []ChargingPeriod `json:"charging_periods"` + CountryCode string `json:"country_code"` + Credit *bool `json:"credit,omitempty"` + CreditReferenceId *string `json:"credit_reference_id,omitempty"` + Currency string `json:"currency"` + EndDateTime string `json:"end_date_time"` + Id string `json:"id"` + InvoiceReferenceId *string `json:"invoice_reference_id,omitempty"` + LastUpdated string `json:"last_updated"` + MeterId *string `json:"meter_id,omitempty"` + PartyId string `json:"party_id"` + Remark *string `json:"remark,omitempty"` + SessionId *string `json:"session_id,omitempty"` + SignedData *SignedData `json:"signed_data,omitempty"` + StartDateTime string `json:"start_date_time"` + Tariffs *[]Tariff `json:"tariffs,omitempty"` + TotalCost Price `json:"total_cost"` + TotalEnergy float32 `json:"total_energy"` + TotalEnergyCost *Price `json:"total_energy_cost,omitempty"` + TotalFixedCost *Price `json:"total_fixed_cost,omitempty"` + TotalParkingCost *Price `json:"total_parking_cost,omitempty"` + TotalParkingTime *float32 `json:"total_parking_time,omitempty"` + TotalReservationCost *Price `json:"total_reservation_cost,omitempty"` + TotalTime float32 `json:"total_time"` + TotalTimeCost *Price `json:"total_time_cost,omitempty"` +} + +// CDRAuthMethod defines model for CDR.AuthMethod. +type CDRAuthMethod string + +// CancelReservation defines model for CancelReservation. +type CancelReservation struct { + ReservationId string `json:"reservation_id"` + ResponseUrl string `json:"response_url"` +} + +// CdrDimension defines model for CdrDimension. +type CdrDimension struct { + Type CdrDimensionType `json:"type"` + Volume float32 `json:"volume"` +} + +// CdrDimensionType defines model for CdrDimension.Type. +type CdrDimensionType string + +// CdrLocation defines model for CdrLocation. +type CdrLocation struct { + Address string `json:"address"` + City string `json:"city"` + ConnectorFormat CdrLocationConnectorFormat `json:"connector_format"` + ConnectorId string `json:"connector_id"` + ConnectorPowerType CdrLocationConnectorPowerType `json:"connector_power_type"` + ConnectorStandard CdrLocationConnectorStandard `json:"connector_standard"` + Coordinates GeoLocation `json:"coordinates"` + Country string `json:"country"` + EvseId string `json:"evse_id"` + EvseUid string `json:"evse_uid"` + Id string `json:"id"` + Name *string `json:"name,omitempty"` + PostalCode string `json:"postal_code"` +} + +// CdrLocationConnectorFormat defines model for CdrLocation.ConnectorFormat. +type CdrLocationConnectorFormat string + +// CdrLocationConnectorPowerType defines model for CdrLocation.ConnectorPowerType. +type CdrLocationConnectorPowerType string + +// CdrLocationConnectorStandard defines model for CdrLocation.ConnectorStandard. +type CdrLocationConnectorStandard string + +// CdrToken defines model for CdrToken. +type CdrToken struct { + ContractId string `json:"contract_id"` + Type CdrTokenType `json:"type"` + Uid string `json:"uid"` +} + +// CdrTokenType defines model for CdrToken.Type. +type CdrTokenType string + +// ChargingPeriod defines model for ChargingPeriod. +type ChargingPeriod struct { + Dimensions []CdrDimension `json:"dimensions"` + StartDateTime string `json:"start_date_time"` + TariffId *string `json:"tariff_id,omitempty"` +} + +// ChargingPreferences defines model for ChargingPreferences. +type ChargingPreferences struct { + DepartureTime *string `json:"departure_time,omitempty"` + DischargeAllowed *bool `json:"discharge_allowed,omitempty"` + EnergyNeed *float32 `json:"energy_need,omitempty"` + ProfileType ChargingPreferencesProfileType `json:"profile_type"` +} + +// ChargingPreferencesProfileType defines model for ChargingPreferences.ProfileType. +type ChargingPreferencesProfileType string + +// ChargingProfile defines model for ChargingProfile. +type ChargingProfile struct { + ChargingProfilePeriod *[]ChargingProfilePeriod `json:"charging_profile_period,omitempty"` + ChargingRateUnit ChargingProfileChargingRateUnit `json:"charging_rate_unit"` + Duration *int32 `json:"duration,omitempty"` + MinChargingRate *float32 `json:"min_charging_rate,omitempty"` + StartDateTime *string `json:"start_date_time,omitempty"` +} + +// ChargingProfileChargingRateUnit defines model for ChargingProfile.ChargingRateUnit. +type ChargingProfileChargingRateUnit string + +// ChargingProfilePeriod defines model for ChargingProfilePeriod. +type ChargingProfilePeriod struct { + Limit float32 `json:"limit"` + StartPeriod int32 `json:"start_period"` +} + +// ChargingProfileResponse defines model for ChargingProfileResponse. +type ChargingProfileResponse struct { + Result ChargingProfileResponseResult `json:"result"` + Timeout int32 `json:"timeout"` +} + +// ChargingProfileResponseResult defines model for ChargingProfileResponse.Result. +type ChargingProfileResponseResult string + +// CommandResponse defines model for CommandResponse. +type CommandResponse struct { + Message *DisplayText `json:"message,omitempty"` + Result CommandResponseResult `json:"result"` + Timeout int32 `json:"timeout"` +} + +// CommandResponseResult defines model for CommandResponse.Result. +type CommandResponseResult string + +// CommandResult defines model for CommandResult. +type CommandResult struct { + Message *DisplayText `json:"message,omitempty"` + Result CommandResultResult `json:"result"` +} + +// CommandResultResult defines model for CommandResult.Result. +type CommandResultResult string + +// Connector defines model for Connector. +type Connector struct { + Format ConnectorFormat `json:"format"` + Id string `json:"id"` + LastUpdated string `json:"last_updated"` + MaxAmperage int32 `json:"max_amperage"` + MaxElectricPower *int32 `json:"max_electric_power,omitempty"` + MaxVoltage int32 `json:"max_voltage"` + PowerType ConnectorPowerType `json:"power_type"` + Standard ConnectorStandard `json:"standard"` + TariffIds *[]string `json:"tariff_ids,omitempty"` + TermsAndConditions *string `json:"terms_and_conditions,omitempty"` +} + +// 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 + +// Credentials defines model for Credentials. +type Credentials struct { + Roles []CredentialsRole `json:"roles"` + Token string `json:"token"` + Url string `json:"url"` +} + +// CredentialsRole defines model for CredentialsRole. +type CredentialsRole struct { + BusinessDetails BusinessDetails `json:"business_details"` + CountryCode string `json:"country_code"` + PartyId string `json:"party_id"` + Role CredentialsRoleRole `json:"role"` +} + +// CredentialsRoleRole defines model for CredentialsRole.Role. +type CredentialsRoleRole string + +// DisplayText defines model for DisplayText. +type DisplayText struct { + Language string `json:"language"` + Text string `json:"text"` +} + +// Endpoint defines model for Endpoint. +type Endpoint struct { + Identifier string `json:"identifier"` + Role EndpointRole `json:"role"` + Url string `json:"url"` +} + +// EndpointRole defines model for Endpoint.Role. +type EndpointRole string + +// EnergyContract defines model for EnergyContract. +type EnergyContract struct { + ContractId *string `json:"contract_id,omitempty"` + SupplierName string `json:"supplier_name"` +} + +// EnergyMix defines model for EnergyMix. +type EnergyMix struct { + EnergyProductName *string `json:"energy_product_name,omitempty"` + EnergySources *[]EnergySource `json:"energy_sources,omitempty"` + EnvironImpact *[]EnvironmentalImpact `json:"environ_impact,omitempty"` + IsGreenEnergy bool `json:"is_green_energy"` + SupplierName *string `json:"supplier_name,omitempty"` +} + +// EnergySource defines model for EnergySource. +type EnergySource struct { + Percentage float32 `json:"percentage"` + Source EnergySourceSource `json:"source"` +} + +// EnergySourceSource defines model for EnergySource.Source. +type EnergySourceSource string + +// EnvironmentalImpact defines model for EnvironmentalImpact. +type EnvironmentalImpact struct { + Amount float32 `json:"amount"` + Category EnvironmentalImpactCategory `json:"category"` +} + +// EnvironmentalImpactCategory defines model for EnvironmentalImpact.Category. +type EnvironmentalImpactCategory string + +// Evse defines model for Evse. +type Evse struct { + Capabilities *[]EvseCapabilities `json:"capabilities,omitempty"` + Connectors []Connector `json:"connectors"` + Coordinates *GeoLocation `json:"coordinates,omitempty"` + Directions *[]DisplayText `json:"directions,omitempty"` + EvseId *string `json:"evse_id"` + FloorLevel *string `json:"floor_level,omitempty"` + Images *[]Image `json:"images,omitempty"` + LastUpdated string `json:"last_updated"` + ParkingRestrictions *[]EvseParkingRestrictions `json:"parking_restrictions,omitempty"` + PhysicalReference *string `json:"physical_reference,omitempty"` + Status EvseStatus `json:"status"` + StatusSchedule *[]StatusSchedule `json:"status_schedule,omitempty"` + + // Uid Uniquely identifies the EVSE within the CPOs platform (and + // suboperator platforms). + Uid string `json:"uid"` +} + +// EvseCapabilities defines model for Evse.Capabilities. +type EvseCapabilities string + +// EvseParkingRestrictions defines model for Evse.ParkingRestrictions. +type EvseParkingRestrictions string + +// EvseStatus defines model for Evse.Status. +type EvseStatus string + +// ExceptionalPeriod defines model for ExceptionalPeriod. +type ExceptionalPeriod struct { + PeriodBegin string `json:"period_begin"` + PeriodEnd string `json:"period_end"` +} + +// GenericChargingProfileResult defines model for GenericChargingProfileResult. +type GenericChargingProfileResult struct { + Profile *ActiveChargingProfile `json:"profile,omitempty"` + Result GenericChargingProfileResultResult `json:"result"` +} + +// GenericChargingProfileResultResult defines model for GenericChargingProfileResult.Result. +type GenericChargingProfileResultResult string + +// GeoLocation defines model for GeoLocation. +type GeoLocation struct { + Latitude string `json:"latitude"` + Longitude string `json:"longitude"` +} + +// Hours defines model for Hours. +type Hours struct { + ExceptionalClosings *ExceptionalPeriod `json:"exceptional_closings,omitempty"` + ExceptionalOpenings *ExceptionalPeriod `json:"exceptional_openings,omitempty"` + RegularHours *RegularHours `json:"regular_hours,omitempty"` + Twentyfourseven bool `json:"twentyfourseven"` +} + +// Image defines model for Image. +type Image struct { + Category ImageCategory `json:"category"` + Height *int32 `json:"height"` + Thumbnail *string `json:"thumbnail"` + Type string `json:"type"` + Url string `json:"url"` + Width *int32 `json:"width"` +} + +// ImageCategory defines model for Image.Category. +type ImageCategory string + +// Location defines model for Location. +type Location struct { + Address string `json:"address"` + ChargingWhenClosed *string `json:"charging_when_closed,omitempty"` + City string `json:"city"` + Coordinates GeoLocation `json:"coordinates"` + Country string `json:"country"` + CountryCode string `json:"country_code"` + Directions *[]DisplayText `json:"directions,omitempty"` + EnergyMix *EnergyMix `json:"energy_mix,omitempty"` + Evses *[]Evse `json:"evses,omitempty"` + Facilities *[]LocationFacilities `json:"facilities,omitempty"` + Id string `json:"id"` + Images *[]Image `json:"images,omitempty"` + LastUpdated string `json:"last_updated"` + Name *string `json:"name"` + OpeningTimes *Hours `json:"opening_times,omitempty"` + Operator *BusinessDetails `json:"operator,omitempty"` + Owner *BusinessDetails `json:"owner,omitempty"` + ParkingType *LocationParkingType `json:"parking_type"` + PartyId string `json:"party_id"` + PostalCode *string `json:"postal_code"` + Publish bool `json:"publish"` + PublishAllowedTo *[]PublishTokenType `json:"publish_allowed_to,omitempty"` + RelatedLocations *[]AdditionalGeoLocation `json:"related_locations,omitempty"` + State *string `json:"state"` + Suboperator *BusinessDetails `json:"suboperator,omitempty"` + TimeZone *string `json:"time_zone,omitempty"` +} + +// LocationFacilities defines model for Location.Facilities. +type LocationFacilities string + +// LocationParkingType defines model for Location.ParkingType. +type LocationParkingType string + +// LocationReferences defines model for LocationReferences. +type LocationReferences struct { + ConnectorIds *[]string `json:"connector_ids,omitempty"` + EvseUids *[]string `json:"evse_uids,omitempty"` + LocationId string `json:"location_id"` +} + +// OcpiResponse defines model for OcpiResponse. +type OcpiResponse struct { + Data *map[string]interface{} `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseAuthorizationInfo defines model for OcpiResponseAuthorizationInfo. +type OcpiResponseAuthorizationInfo struct { + Data *AuthorizationInfo `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseCDR defines model for OcpiResponseCDR. +type OcpiResponseCDR struct { + Data *CDR `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseCDRList defines model for OcpiResponseCDRList. +type OcpiResponseCDRList struct { + Data *[]CDR `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseChargingPreferencesResponse defines model for OcpiResponseChargingPreferencesResponse. +type OcpiResponseChargingPreferencesResponse struct { + Data *OcpiResponseChargingPreferencesResponseData `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseChargingPreferencesResponseData defines model for OcpiResponseChargingPreferencesResponse.Data. +type OcpiResponseChargingPreferencesResponseData string + +// OcpiResponseChargingProfileResponse defines model for OcpiResponseChargingProfileResponse. +type OcpiResponseChargingProfileResponse struct { + Data *ChargingProfileResponse `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseCommandResponse defines model for OcpiResponseCommandResponse. +type OcpiResponseCommandResponse struct { + Data *CommandResponse `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseConnector defines model for OcpiResponseConnector. +type OcpiResponseConnector struct { + Data *Connector `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseCredentials defines model for OcpiResponseCredentials. +type OcpiResponseCredentials struct { + Data *Credentials `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseEvse defines model for OcpiResponseEvse. +type OcpiResponseEvse struct { + Data *Evse `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseListVersion defines model for OcpiResponseListVersion. +type OcpiResponseListVersion struct { + Data *[]Version `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseLocation defines model for OcpiResponseLocation. +type OcpiResponseLocation struct { + Data *Location `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseLocationList defines model for OcpiResponseLocationList. +type OcpiResponseLocationList struct { + Data *[]Location `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseSession defines model for OcpiResponseSession. +type OcpiResponseSession struct { + Data *Session `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseSessionList defines model for OcpiResponseSessionList. +type OcpiResponseSessionList struct { + Data *[]Session `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseTariff defines model for OcpiResponseTariff. +type OcpiResponseTariff struct { + Data *Tariff `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseTariffList defines model for OcpiResponseTariffList. +type OcpiResponseTariffList struct { + Data *[]Tariff `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseToken defines model for OcpiResponseToken. +type OcpiResponseToken struct { + Data *Token `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseTokenList defines model for OcpiResponseTokenList. +type OcpiResponseTokenList struct { + Data *[]Token `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseUnit defines model for OcpiResponseUnit. +type OcpiResponseUnit struct { + Data *Unit `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// OcpiResponseVersionDetail defines model for OcpiResponseVersionDetail. +type OcpiResponseVersionDetail struct { + Data *VersionDetail `json:"data,omitempty"` + StatusCode int32 `json:"status_code"` + StatusMessage *string `json:"status_message,omitempty"` + Timestamp string `json:"timestamp"` +} + +// Price defines model for Price. +type Price struct { + ExclVat float32 `json:"excl_vat"` + InclVat float32 `json:"incl_vat"` +} + +// PriceComponent defines model for PriceComponent. +type PriceComponent struct { + Price float32 `json:"price"` + StepSize int32 `json:"step_size"` + Type PriceComponentType `json:"type"` + Vat *float32 `json:"vat,omitempty"` +} + +// PriceComponentType defines model for PriceComponent.Type. +type PriceComponentType string + +// PublishTokenType defines model for PublishTokenType. +type PublishTokenType struct { + GroupId *string `json:"group_id ,omitempty"` + Issuer *string `json:"issuer,omitempty"` + Type *PublishTokenTypeType `json:"type,omitempty"` + Uid *string `json:"uid,omitempty"` + VisualNumber *string `json:"visual_number,omitempty"` +} + +// PublishTokenTypeType defines model for PublishTokenType.Type. +type PublishTokenTypeType string + +// RegularHours defines model for RegularHours. +type RegularHours struct { + PeriodBegin string `json:"period_begin"` + PeriodEnd string `json:"period_end"` + Weekday int32 `json:"weekday"` +} + +// ReserveNow defines model for ReserveNow. +type ReserveNow struct { + AuthorizationReference *string `json:"authorization_reference,omitempty"` + EvseUid *string `json:"evse_uid,omitempty"` + ExpiryDate string `json:"expiry_date"` + LocationId string `json:"location_id"` + ReservationId string `json:"reservation_id"` + ResponseUrl string `json:"response_url"` + Token Token `json:"token"` +} + +// Session defines model for Session. +type Session struct { + AuthMethod SessionAuthMethod `json:"auth_method"` + AuthorizationReference *string `json:"authorization_reference,omitempty"` + CdrToken CdrToken `json:"cdr_token"` + ChargingPeriods *[]ChargingPeriod `json:"charging_periods,omitempty"` + ConnectorId string `json:"connector_id"` + CountryCode string `json:"country_code"` + Currency string `json:"currency"` + EndDateTime *string `json:"end_date_time,omitempty"` + EvseUid string `json:"evse_uid"` + Id string `json:"id"` + Kwh float32 `json:"kwh"` + LastUpdated string `json:"last_updated"` + LocationId string `json:"location_id"` + MeterId *string `json:"meter_id,omitempty"` + PartyId string `json:"party_id"` + StartDateTime string `json:"start_date_time"` + Status SessionStatus `json:"status"` + TotalCost *Price `json:"total_cost,omitempty"` +} + +// SessionAuthMethod defines model for Session.AuthMethod. +type SessionAuthMethod string + +// SessionStatus defines model for Session.Status. +type SessionStatus string + +// SetChargingProfile defines model for SetChargingProfile. +type SetChargingProfile struct { + ChargingProfile ChargingProfile `json:"charging_profile"` + ResponseUrl string `json:"response_url"` +} + +// SignedData defines model for SignedData. +type SignedData struct { + EncodingMethod string `json:"encoding_method"` + EncodingMethodVersion *int32 `json:"encoding_method_version,omitempty"` + PublicKey *string `json:"public_key,omitempty"` + SignedValues []SignedValue `json:"signed_values"` + Url string `json:"url"` +} + +// SignedValue defines model for SignedValue. +type SignedValue struct { + Nature string `json:"nature"` + PlainData string `json:"plain_data"` + SignedData string `json:"signed_data"` +} + +// StartSession defines model for StartSession. +type StartSession struct { + AuthorizationReference *string `json:"authorization_reference,omitempty"` + EvseUid *string `json:"evse_uid,omitempty"` + LocationId string `json:"location_id"` + ResponseUrl string `json:"response_url"` + Token Token `json:"token"` +} + +// StatusSchedule defines model for StatusSchedule. +type StatusSchedule struct { + PeriodBegin string `json:"period_begin"` + PeriodEnd *string `json:"period_end,omitempty"` + Status StatusScheduleStatus `json:"status"` +} + +// StatusScheduleStatus defines model for StatusSchedule.Status. +type StatusScheduleStatus string + +// StopSession defines model for StopSession. +type StopSession struct { + ResponseUrl string `json:"response_url"` + SessionId string `json:"session_id"` +} + +// Tariff defines model for Tariff. +type Tariff struct { + CountryCode string `json:"country_code"` + Currency string `json:"currency"` + Elements []TariffElement `json:"elements"` + EndDateTime *string `json:"end_date_time,omitempty"` + EnergyMix *EnergyMix `json:"energy_mix,omitempty"` + Id string `json:"id"` + LastUpdated string `json:"last_updated"` + MaxPrice *Price `json:"max_price,omitempty"` + MinPrice *Price `json:"min_price,omitempty"` + PartyId string `json:"party_id"` + StartDateTime *string `json:"start_date_time,omitempty"` + TariffAltText *[]DisplayText `json:"tariff_alt_text,omitempty"` + TariffAltUrl *string `json:"tariff_alt_url,omitempty"` + Type *TariffType `json:"type,omitempty"` +} + +// TariffType defines model for Tariff.Type. +type TariffType string + +// TariffElement defines model for TariffElement. +type TariffElement struct { + PriceComponents []PriceComponent `json:"price_components"` + Restrictions *TariffRestrictions `json:"restrictions,omitempty"` +} + +// TariffRestrictions defines model for TariffRestrictions. +type TariffRestrictions struct { + DayOfWeek *[]TariffRestrictionsDayOfWeek `json:"day_of_week,omitempty"` + EndDate *string `json:"end_date,omitempty"` + EndTime *string `json:"end_time,omitempty"` + MaxCurrent *float32 `json:"max_current,omitempty"` + MaxDuration *int32 `json:"max_duration,omitempty"` + MaxKwh *float32 `json:"max_kwh,omitempty"` + MaxPower *float32 `json:"max_power,omitempty"` + MinCurrent *float32 `json:"min_current,omitempty"` + MinDuration *int32 `json:"min_duration,omitempty"` + MinKwh *float32 `json:"min_kwh,omitempty"` + MinPower *float32 `json:"min_power,omitempty"` + Reservation *TariffRestrictionsReservation `json:"reservation,omitempty"` + StartDate *string `json:"start_date,omitempty"` + StartTime *string `json:"start_time,omitempty"` +} + +// TariffRestrictionsDayOfWeek defines model for TariffRestrictions.DayOfWeek. +type TariffRestrictionsDayOfWeek string + +// TariffRestrictionsReservation defines model for TariffRestrictions.Reservation. +type TariffRestrictionsReservation string + +// Token defines model for Token. +type Token struct { + ContractId string `json:"contract_id"` + CountryCode string `json:"country_code"` + DefaultProfileType *TokenDefaultProfileType `json:"default_profile_type,omitempty"` + EnergyContract *EnergyContract `json:"energy_contract,omitempty"` + GroupId *string `json:"group_id,omitempty"` + Issuer string `json:"issuer"` + Language *string `json:"language,omitempty"` + LastUpdated string `json:"last_updated"` + PartyId string `json:"party_id"` + Type TokenType `json:"type"` + Uid string `json:"uid"` + Valid bool `json:"valid"` + VisualNumber *string `json:"visual_number,omitempty"` + Whitelist TokenWhitelist `json:"whitelist"` +} + +// TokenDefaultProfileType defines model for Token.DefaultProfileType. +type TokenDefaultProfileType string + +// TokenType defines model for Token.Type. +type TokenType string + +// TokenWhitelist defines model for Token.Whitelist. +type TokenWhitelist string + +// Unit defines model for Unit. +type Unit = map[string]interface{} + +// UnlockConnector defines model for UnlockConnector. +type UnlockConnector struct { + ConnectorId string `json:"connector_id"` + EvseUid string `json:"evse_uid"` + LocationId string `json:"location_id"` + ResponseUrl string `json:"response_url"` +} + +// Version defines model for Version. +type Version struct { + Url string `json:"url"` + Version string `json:"version"` +} + +// VersionDetail defines model for VersionDetail. +type VersionDetail struct { + Endpoints []Endpoint `json:"endpoints"` + Version string `json:"version"` +} + +// GetVersionParams defines parameters for GetVersion. +type GetVersionParams struct { + Authorization string `json:"Authorization"` +} + +// DeleteCredentialsParams defines parameters for DeleteCredentials. +type DeleteCredentialsParams struct { + Authorization string `json:"Authorization"` +} + +// GetCredentialsParams defines parameters for GetCredentials. +type GetCredentialsParams struct { + Authorization string `json:"Authorization"` +} + +// PostCredentialsParams defines parameters for PostCredentials. +type PostCredentialsParams struct { + Authorization string `json:"Authorization"` +} + +// PutCredentialsParams defines parameters for PutCredentials. +type PutCredentialsParams struct { + Authorization string `json:"Authorization"` +} + +// DeleteReceiverChargingProfileParams defines parameters for DeleteReceiverChargingProfile. +type DeleteReceiverChargingProfileParams struct { + ResponseUrl string `form:"response_url" json:"response_url"` + Authorization string `json:"Authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetReceiverChargingProfileParams defines parameters for GetReceiverChargingProfile. +type GetReceiverChargingProfileParams struct { + Duration int32 `form:"duration" json:"duration"` + ResponseUrl string `form:"response_url" json:"response_url"` + Authorization string `json:"Authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PutReceiverChargingProfileParams defines parameters for PutReceiverChargingProfile. +type PutReceiverChargingProfileParams struct { + Authorization string `json:"Authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostGenericChargingProfileResultParams defines parameters for PostGenericChargingProfileResult. +type PostGenericChargingProfileResultParams struct { + Authorization string `json:"Authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PutSenderChargingProfileParams defines parameters for PutSenderChargingProfile. +type PutSenderChargingProfileParams struct { + Authorization string `json:"Authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostClientOwnedCdrParams defines parameters for PostClientOwnedCdr. +type PostClientOwnedCdrParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetClientOwnedCdrParams defines parameters for GetClientOwnedCdr. +type GetClientOwnedCdrParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostCancelReservationParams defines parameters for PostCancelReservation. +type PostCancelReservationParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostReserveNowParams defines parameters for PostReserveNow. +type PostReserveNowParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostStartSessionParams defines parameters for PostStartSession. +type PostStartSessionParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostStopSessionParams defines parameters for PostStopSession. +type PostStopSessionParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostUnlockConnectorParams defines parameters for PostUnlockConnector. +type PostUnlockConnectorParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetClientOwnedLocationParams defines parameters for GetClientOwnedLocation. +type GetClientOwnedLocationParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PatchClientOwnedLocationJSONBody defines parameters for PatchClientOwnedLocation. +type PatchClientOwnedLocationJSONBody map[string]map[string]interface{} + +// PatchClientOwnedLocationParams defines parameters for PatchClientOwnedLocation. +type PatchClientOwnedLocationParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PutClientOwnedLocationParams defines parameters for PutClientOwnedLocation. +type PutClientOwnedLocationParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetClientOwnedEvseParams defines parameters for GetClientOwnedEvse. +type GetClientOwnedEvseParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PatchClientOwnedEvseJSONBody defines parameters for PatchClientOwnedEvse. +type PatchClientOwnedEvseJSONBody map[string]map[string]interface{} + +// PatchClientOwnedEvseParams defines parameters for PatchClientOwnedEvse. +type PatchClientOwnedEvseParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PutClientOwnedEvseParams defines parameters for PutClientOwnedEvse. +type PutClientOwnedEvseParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetClientOwnedConnectorParams defines parameters for GetClientOwnedConnector. +type GetClientOwnedConnectorParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PatchClientOwnedConnectorJSONBody defines parameters for PatchClientOwnedConnector. +type PatchClientOwnedConnectorJSONBody map[string]map[string]interface{} + +// PatchClientOwnedConnectorParams defines parameters for PatchClientOwnedConnector. +type PatchClientOwnedConnectorParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PutClientOwnedConnectorParams defines parameters for PutClientOwnedConnector. +type PutClientOwnedConnectorParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetClientOwnedSessionParams defines parameters for GetClientOwnedSession. +type GetClientOwnedSessionParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PatchClientOwnedSessionJSONBody defines parameters for PatchClientOwnedSession. +type PatchClientOwnedSessionJSONBody map[string]map[string]interface{} + +// PatchClientOwnedSessionParams defines parameters for PatchClientOwnedSession. +type PatchClientOwnedSessionParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PutClientOwnedSessionParams defines parameters for PutClientOwnedSession. +type PutClientOwnedSessionParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// DeleteClientOwnedTariffParams defines parameters for DeleteClientOwnedTariff. +type DeleteClientOwnedTariffParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetClientOwnedTariffParams defines parameters for GetClientOwnedTariff. +type GetClientOwnedTariffParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PutClientOwnedTariffParams defines parameters for PutClientOwnedTariff. +type PutClientOwnedTariffParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetClientOwnedTokenParams defines parameters for GetClientOwnedToken. +type GetClientOwnedTokenParams struct { + Type *GetClientOwnedTokenParamsType `form:"type,omitempty" json:"type,omitempty"` + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetClientOwnedTokenParamsType defines parameters for GetClientOwnedToken. +type GetClientOwnedTokenParamsType string + +// PatchClientOwnedTokenJSONBody defines parameters for PatchClientOwnedToken. +type PatchClientOwnedTokenJSONBody map[string]map[string]interface{} + +// PatchClientOwnedTokenParams defines parameters for PatchClientOwnedToken. +type PatchClientOwnedTokenParams struct { + Type *PatchClientOwnedTokenParamsType `form:"type,omitempty" json:"type,omitempty"` + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PatchClientOwnedTokenParamsType defines parameters for PatchClientOwnedToken. +type PatchClientOwnedTokenParamsType string + +// PutClientOwnedTokenParams defines parameters for PutClientOwnedToken. +type PutClientOwnedTokenParams struct { + Type *PutClientOwnedTokenParamsType `form:"type,omitempty" json:"type,omitempty"` + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PutClientOwnedTokenParamsType defines parameters for PutClientOwnedToken. +type PutClientOwnedTokenParamsType string + +// GetCdrsFromDataOwnerParams defines parameters for GetCdrsFromDataOwner. +type GetCdrsFromDataOwnerParams struct { + DateFrom *string `form:"date_from,omitempty" json:"date_from,omitempty"` + DateTo *string `form:"date_to,omitempty" json:"date_to,omitempty"` + Offset *int32 `form:"offset,omitempty" json:"offset,omitempty"` + Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"` + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetCdrPageFromDataOwnerParams defines parameters for GetCdrPageFromDataOwner. +type GetCdrPageFromDataOwnerParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostAsyncResponseParams defines parameters for PostAsyncResponse. +type PostAsyncResponseParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostAsyncResponseParamsCommand defines parameters for PostAsyncResponse. +type PostAsyncResponseParamsCommand string + +// GetLocationListFromDataOwnerParams defines parameters for GetLocationListFromDataOwner. +type GetLocationListFromDataOwnerParams struct { + DateFrom *string `form:"date_from,omitempty" json:"date_from,omitempty"` + DateTo *string `form:"date_to,omitempty" json:"date_to,omitempty"` + Offset *int32 `form:"offset,omitempty" json:"offset,omitempty"` + Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"` + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetLocationPageFromDataOwnerParams defines parameters for GetLocationPageFromDataOwner. +type GetLocationPageFromDataOwnerParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetLocationObjectFromDataOwnerParams defines parameters for GetLocationObjectFromDataOwner. +type GetLocationObjectFromDataOwnerParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetEvseObjectFromDataOwnerParams defines parameters for GetEvseObjectFromDataOwner. +type GetEvseObjectFromDataOwnerParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetConnectorObjectFromDataOwnerParams defines parameters for GetConnectorObjectFromDataOwner. +type GetConnectorObjectFromDataOwnerParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetSessionsFromDataOwnerParams defines parameters for GetSessionsFromDataOwner. +type GetSessionsFromDataOwnerParams struct { + DateFrom *string `form:"date_from,omitempty" json:"date_from,omitempty"` + DateTo *string `form:"date_to,omitempty" json:"date_to,omitempty"` + Offset *int32 `form:"offset,omitempty" json:"offset,omitempty"` + Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"` + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetSessionsPageFromDataOwnerParams defines parameters for GetSessionsPageFromDataOwner. +type GetSessionsPageFromDataOwnerParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PutChargingPreferencesParams defines parameters for PutChargingPreferences. +type PutChargingPreferencesParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetTariffsFromDataOwnerParams defines parameters for GetTariffsFromDataOwner. +type GetTariffsFromDataOwnerParams struct { + DateFrom *string `form:"date_from,omitempty" json:"date_from,omitempty"` + DateTo *string `form:"date_to,omitempty" json:"date_to,omitempty"` + Offset *int32 `form:"offset,omitempty" json:"offset,omitempty"` + Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"` + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetTariffsPageFromDataOwnerParams defines parameters for GetTariffsPageFromDataOwner. +type GetTariffsPageFromDataOwnerParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetTokensFromDataOwnerParams defines parameters for GetTokensFromDataOwner. +type GetTokensFromDataOwnerParams struct { + DateFrom *string `form:"date_from,omitempty" json:"date_from,omitempty"` + DateTo *string `form:"date_to,omitempty" json:"date_to,omitempty"` + Offset *int32 `form:"offset,omitempty" json:"offset,omitempty"` + Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"` + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// GetTokensPageFromDataOwnerParams defines parameters for GetTokensPageFromDataOwner. +type GetTokensPageFromDataOwnerParams struct { + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostRealTimeTokenAuthorizationParams defines parameters for PostRealTimeTokenAuthorization. +type PostRealTimeTokenAuthorizationParams struct { + Type *PostRealTimeTokenAuthorizationParamsType `form:"type,omitempty" json:"type,omitempty"` + Authorization string `json:"authorization"` + XRequestID string `json:"X-Request-ID"` + XCorrelationID string `json:"X-Correlation-ID"` + OCPIFromCountryCode string `json:"OCPI-from-country-code"` + OCPIFromPartyId string `json:"OCPI-from-party-id"` + OCPIToCountryCode string `json:"OCPI-to-country-code"` + OCPIToPartyId string `json:"OCPI-to-party-id"` +} + +// PostRealTimeTokenAuthorizationParamsType defines parameters for PostRealTimeTokenAuthorization. +type PostRealTimeTokenAuthorizationParamsType string + +// GetVersionsParams defines parameters for GetVersions. +type GetVersionsParams struct { + Authorization string `json:"Authorization"` +} + +// PostCredentialsJSONRequestBody defines body for PostCredentials for application/json ContentType. +type PostCredentialsJSONRequestBody = Credentials + +// PutCredentialsJSONRequestBody defines body for PutCredentials for application/json ContentType. +type PutCredentialsJSONRequestBody = Credentials + +// PutReceiverChargingProfileJSONRequestBody defines body for PutReceiverChargingProfile for application/json ContentType. +type PutReceiverChargingProfileJSONRequestBody = SetChargingProfile + +// PostGenericChargingProfileResultJSONRequestBody defines body for PostGenericChargingProfileResult for application/json ContentType. +type PostGenericChargingProfileResultJSONRequestBody = GenericChargingProfileResult + +// PutSenderChargingProfileJSONRequestBody defines body for PutSenderChargingProfile for application/json ContentType. +type PutSenderChargingProfileJSONRequestBody = ActiveChargingProfile + +// PostClientOwnedCdrJSONRequestBody defines body for PostClientOwnedCdr for application/json ContentType. +type PostClientOwnedCdrJSONRequestBody = CDR + +// PostCancelReservationJSONRequestBody defines body for PostCancelReservation for application/json ContentType. +type PostCancelReservationJSONRequestBody = CancelReservation + +// PostReserveNowJSONRequestBody defines body for PostReserveNow for application/json ContentType. +type PostReserveNowJSONRequestBody = ReserveNow + +// PostStartSessionJSONRequestBody defines body for PostStartSession for application/json ContentType. +type PostStartSessionJSONRequestBody = StartSession + +// PostStopSessionJSONRequestBody defines body for PostStopSession for application/json ContentType. +type PostStopSessionJSONRequestBody = StopSession + +// PostUnlockConnectorJSONRequestBody defines body for PostUnlockConnector for application/json ContentType. +type PostUnlockConnectorJSONRequestBody = UnlockConnector + +// PatchClientOwnedLocationJSONRequestBody defines body for PatchClientOwnedLocation for application/json ContentType. +type PatchClientOwnedLocationJSONRequestBody PatchClientOwnedLocationJSONBody + +// PutClientOwnedLocationJSONRequestBody defines body for PutClientOwnedLocation for application/json ContentType. +type PutClientOwnedLocationJSONRequestBody = Location + +// PatchClientOwnedEvseJSONRequestBody defines body for PatchClientOwnedEvse for application/json ContentType. +type PatchClientOwnedEvseJSONRequestBody PatchClientOwnedEvseJSONBody + +// PutClientOwnedEvseJSONRequestBody defines body for PutClientOwnedEvse for application/json ContentType. +type PutClientOwnedEvseJSONRequestBody = Evse + +// PatchClientOwnedConnectorJSONRequestBody defines body for PatchClientOwnedConnector for application/json ContentType. +type PatchClientOwnedConnectorJSONRequestBody PatchClientOwnedConnectorJSONBody + +// PutClientOwnedConnectorJSONRequestBody defines body for PutClientOwnedConnector for application/json ContentType. +type PutClientOwnedConnectorJSONRequestBody = Connector + +// PatchClientOwnedSessionJSONRequestBody defines body for PatchClientOwnedSession for application/json ContentType. +type PatchClientOwnedSessionJSONRequestBody PatchClientOwnedSessionJSONBody + +// PutClientOwnedSessionJSONRequestBody defines body for PutClientOwnedSession for application/json ContentType. +type PutClientOwnedSessionJSONRequestBody = Session + +// PutClientOwnedTariffJSONRequestBody defines body for PutClientOwnedTariff for application/json ContentType. +type PutClientOwnedTariffJSONRequestBody = Tariff + +// PatchClientOwnedTokenJSONRequestBody defines body for PatchClientOwnedToken for application/json ContentType. +type PatchClientOwnedTokenJSONRequestBody PatchClientOwnedTokenJSONBody + +// PutClientOwnedTokenJSONRequestBody defines body for PutClientOwnedToken for application/json ContentType. +type PutClientOwnedTokenJSONRequestBody = Token + +// PostAsyncResponseJSONRequestBody defines body for PostAsyncResponse for application/json ContentType. +type PostAsyncResponseJSONRequestBody = CommandResult + +// PutChargingPreferencesJSONRequestBody defines body for PutChargingPreferences for application/json ContentType. +type PutChargingPreferencesJSONRequestBody = ChargingPreferences + +// PostRealTimeTokenAuthorizationJSONRequestBody defines body for PostRealTimeTokenAuthorization for application/json ContentType. +type PostRealTimeTokenAuthorizationJSONRequestBody = LocationReferences + +// ServerInterface represents all server handlers. +type ServerInterface interface { + + // (GET /ocpi/2.2) + GetVersion(w http.ResponseWriter, r *http.Request, params GetVersionParams) + + // (DELETE /ocpi/2.2/credentials) + DeleteCredentials(w http.ResponseWriter, r *http.Request, params DeleteCredentialsParams) + + // (GET /ocpi/2.2/credentials) + GetCredentials(w http.ResponseWriter, r *http.Request, params GetCredentialsParams) + + // (POST /ocpi/2.2/credentials) + PostCredentials(w http.ResponseWriter, r *http.Request, params PostCredentialsParams) + + // (PUT /ocpi/2.2/credentials) + PutCredentials(w http.ResponseWriter, r *http.Request, params PutCredentialsParams) + + // (DELETE /ocpi/2.2/receiver/chargingprofiles/{sessionId}) + DeleteReceiverChargingProfile(w http.ResponseWriter, r *http.Request, sessionId string, params DeleteReceiverChargingProfileParams) + + // (GET /ocpi/2.2/receiver/chargingprofiles/{sessionId}) + GetReceiverChargingProfile(w http.ResponseWriter, r *http.Request, sessionId string, params GetReceiverChargingProfileParams) + + // (PUT /ocpi/2.2/receiver/chargingprofiles/{sessionId}) + PutReceiverChargingProfile(w http.ResponseWriter, r *http.Request, sessionId string, params PutReceiverChargingProfileParams) + + // (POST /ocpi/2.2/sender/chargingprofiles/result/{uid}) + PostGenericChargingProfileResult(w http.ResponseWriter, r *http.Request, uid string, params PostGenericChargingProfileResultParams) + + // (PUT /ocpi/2.2/sender/chargingprofiles/{sessionId}) + PutSenderChargingProfile(w http.ResponseWriter, r *http.Request, sessionId string, params PutSenderChargingProfileParams) + + // (POST /ocpi/receiver/2.2/cdrs) + PostClientOwnedCdr(w http.ResponseWriter, r *http.Request, params PostClientOwnedCdrParams) + + // (GET /ocpi/receiver/2.2/cdrs/{cdrID}) + GetClientOwnedCdr(w http.ResponseWriter, r *http.Request, cdrID string, params GetClientOwnedCdrParams) + + // (POST /ocpi/receiver/2.2/commands/CANCEL_RESERVATION) + PostCancelReservation(w http.ResponseWriter, r *http.Request, params PostCancelReservationParams) + + // (POST /ocpi/receiver/2.2/commands/RESERVE_NOW) + PostReserveNow(w http.ResponseWriter, r *http.Request, params PostReserveNowParams) + + // (POST /ocpi/receiver/2.2/commands/START_SESSION) + PostStartSession(w http.ResponseWriter, r *http.Request, params PostStartSessionParams) + + // (POST /ocpi/receiver/2.2/commands/STOP_SESSION) + PostStopSession(w http.ResponseWriter, r *http.Request, params PostStopSessionParams) + + // (POST /ocpi/receiver/2.2/commands/UNLOCK_CONNECTOR) + PostUnlockConnector(w http.ResponseWriter, r *http.Request, params PostUnlockConnectorParams) + + // (GET /ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}) + GetClientOwnedLocation(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, params GetClientOwnedLocationParams) + + // (PATCH /ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}) + PatchClientOwnedLocation(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, params PatchClientOwnedLocationParams) + + // (PUT /ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}) + PutClientOwnedLocation(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, params PutClientOwnedLocationParams) + + // (GET /ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}) + GetClientOwnedEvse(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, params GetClientOwnedEvseParams) + + // (PATCH /ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}) + PatchClientOwnedEvse(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, params PatchClientOwnedEvseParams) + + // (PUT /ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}) + PutClientOwnedEvse(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, params PutClientOwnedEvseParams) + + // (GET /ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}/{connectorID}) + GetClientOwnedConnector(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, connectorID string, params GetClientOwnedConnectorParams) + + // (PATCH /ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}/{connectorID}) + PatchClientOwnedConnector(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, connectorID string, params PatchClientOwnedConnectorParams) + + // (PUT /ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}/{connectorID}) + PutClientOwnedConnector(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, connectorID string, params PutClientOwnedConnectorParams) + + // (GET /ocpi/receiver/2.2/sessions/{countryCode}/{partyID}/{sessionID}) + GetClientOwnedSession(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, sessionID string, params GetClientOwnedSessionParams) + + // (PATCH /ocpi/receiver/2.2/sessions/{countryCode}/{partyID}/{sessionID}) + PatchClientOwnedSession(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, sessionID string, params PatchClientOwnedSessionParams) + + // (PUT /ocpi/receiver/2.2/sessions/{countryCode}/{partyID}/{sessionID}) + PutClientOwnedSession(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, sessionID string, params PutClientOwnedSessionParams) + + // (DELETE /ocpi/receiver/2.2/tariffs/{countryCode}/{partyID}/{tariffID}) + DeleteClientOwnedTariff(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tariffID string, params DeleteClientOwnedTariffParams) + + // (GET /ocpi/receiver/2.2/tariffs/{countryCode}/{partyID}/{tariffID}) + GetClientOwnedTariff(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tariffID string, params GetClientOwnedTariffParams) + + // (PUT /ocpi/receiver/2.2/tariffs/{countryCode}/{partyID}/{tariffID}) + PutClientOwnedTariff(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tariffID string, params PutClientOwnedTariffParams) + + // (GET /ocpi/receiver/2.2/tokens/{countryCode}/{partyID}/{tokenUID}) + GetClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params GetClientOwnedTokenParams) + + // (PATCH /ocpi/receiver/2.2/tokens/{countryCode}/{partyID}/{tokenUID}) + PatchClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params PatchClientOwnedTokenParams) + + // (PUT /ocpi/receiver/2.2/tokens/{countryCode}/{partyID}/{tokenUID}) + PutClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params PutClientOwnedTokenParams) + + // (GET /ocpi/sender/2.2/cdrs) + GetCdrsFromDataOwner(w http.ResponseWriter, r *http.Request, params GetCdrsFromDataOwnerParams) + + // (GET /ocpi/sender/2.2/cdrs/page/{uid}) + GetCdrPageFromDataOwner(w http.ResponseWriter, r *http.Request, uid string, params GetCdrPageFromDataOwnerParams) + + // (POST /ocpi/sender/2.2/commands/{command}/{uid}) + PostAsyncResponse(w http.ResponseWriter, r *http.Request, command PostAsyncResponseParamsCommand, uid string, params PostAsyncResponseParams) + + // (GET /ocpi/sender/2.2/locations) + GetLocationListFromDataOwner(w http.ResponseWriter, r *http.Request, params GetLocationListFromDataOwnerParams) + + // (GET /ocpi/sender/2.2/locations/page/{uid}) + GetLocationPageFromDataOwner(w http.ResponseWriter, r *http.Request, uid string, params GetLocationPageFromDataOwnerParams) + + // (GET /ocpi/sender/2.2/locations/{locationID}) + GetLocationObjectFromDataOwner(w http.ResponseWriter, r *http.Request, locationID string, params GetLocationObjectFromDataOwnerParams) + + // (GET /ocpi/sender/2.2/locations/{locationID}/{evseUID}) + GetEvseObjectFromDataOwner(w http.ResponseWriter, r *http.Request, locationID string, evseUID string, params GetEvseObjectFromDataOwnerParams) + + // (GET /ocpi/sender/2.2/locations/{locationID}/{evseUID}/{connectorID}) + GetConnectorObjectFromDataOwner(w http.ResponseWriter, r *http.Request, locationID string, evseUID string, connectorID string, params GetConnectorObjectFromDataOwnerParams) + + // (GET /ocpi/sender/2.2/sessions) + GetSessionsFromDataOwner(w http.ResponseWriter, r *http.Request, params GetSessionsFromDataOwnerParams) + + // (GET /ocpi/sender/2.2/sessions/page/{uid}) + GetSessionsPageFromDataOwner(w http.ResponseWriter, r *http.Request, uid string, params GetSessionsPageFromDataOwnerParams) + + // (PUT /ocpi/sender/2.2/sessions/{sessionID}/charging_preferences) + PutChargingPreferences(w http.ResponseWriter, r *http.Request, sessionID string, params PutChargingPreferencesParams) + + // (GET /ocpi/sender/2.2/tariffs) + GetTariffsFromDataOwner(w http.ResponseWriter, r *http.Request, params GetTariffsFromDataOwnerParams) + + // (GET /ocpi/sender/2.2/tariffs/page/{uid}) + GetTariffsPageFromDataOwner(w http.ResponseWriter, r *http.Request, uid string, params GetTariffsPageFromDataOwnerParams) + + // (GET /ocpi/sender/2.2/tokens) + GetTokensFromDataOwner(w http.ResponseWriter, r *http.Request, params GetTokensFromDataOwnerParams) + + // (GET /ocpi/sender/2.2/tokens/page/{uid}) + GetTokensPageFromDataOwner(w http.ResponseWriter, r *http.Request, uid string, params GetTokensPageFromDataOwnerParams) + + // (POST /ocpi/sender/2.2/tokens/{tokenUID}/authorize) + PostRealTimeTokenAuthorization(w http.ResponseWriter, r *http.Request, tokenUID string, params PostRealTimeTokenAuthorizationParams) + + // (GET /ocpi/versions) + GetVersions(w http.ResponseWriter, r *http.Request, params GetVersionsParams) +} + +// 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 + +// GetVersion operation middleware +func (siw *ServerInterfaceWrapper) GetVersion(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetVersionParams + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetVersion(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// DeleteCredentials operation middleware +func (siw *ServerInterfaceWrapper) DeleteCredentials(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params DeleteCredentialsParams + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.DeleteCredentials(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetCredentials operation middleware +func (siw *ServerInterfaceWrapper) GetCredentials(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetCredentialsParams + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetCredentials(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PostCredentials operation middleware +func (siw *ServerInterfaceWrapper) PostCredentials(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PostCredentialsParams + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostCredentials(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PutCredentials operation middleware +func (siw *ServerInterfaceWrapper) PutCredentials(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PutCredentialsParams + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PutCredentials(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// DeleteReceiverChargingProfile operation middleware +func (siw *ServerInterfaceWrapper) DeleteReceiverChargingProfile(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "sessionId" ------------- + var sessionId string + + err = runtime.BindStyledParameterWithLocation("simple", false, "sessionId", runtime.ParamLocationPath, chi.URLParam(r, "sessionId"), &sessionId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sessionId", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params DeleteReceiverChargingProfileParams + + // ------------- Required query parameter "response_url" ------------- + + if paramValue := r.URL.Query().Get("response_url"); paramValue != "" { + + } else { + siw.ErrorHandlerFunc(w, r, &RequiredParamError{ParamName: "response_url"}) + return + } + + err = runtime.BindQueryParameter("form", true, true, "response_url", r.URL.Query(), ¶ms.ResponseUrl) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "response_url", Err: err}) + return + } + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.DeleteReceiverChargingProfile(w, r, sessionId, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetReceiverChargingProfile operation middleware +func (siw *ServerInterfaceWrapper) GetReceiverChargingProfile(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "sessionId" ------------- + var sessionId string + + err = runtime.BindStyledParameterWithLocation("simple", false, "sessionId", runtime.ParamLocationPath, chi.URLParam(r, "sessionId"), &sessionId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sessionId", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetReceiverChargingProfileParams + + // ------------- Required query parameter "duration" ------------- + + if paramValue := r.URL.Query().Get("duration"); paramValue != "" { + + } else { + siw.ErrorHandlerFunc(w, r, &RequiredParamError{ParamName: "duration"}) + return + } + + err = runtime.BindQueryParameter("form", true, true, "duration", r.URL.Query(), ¶ms.Duration) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "duration", Err: err}) + return + } + + // ------------- Required query parameter "response_url" ------------- + + if paramValue := r.URL.Query().Get("response_url"); paramValue != "" { + + } else { + siw.ErrorHandlerFunc(w, r, &RequiredParamError{ParamName: "response_url"}) + return + } + + err = runtime.BindQueryParameter("form", true, true, "response_url", r.URL.Query(), ¶ms.ResponseUrl) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "response_url", Err: err}) + return + } + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetReceiverChargingProfile(w, r, sessionId, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PutReceiverChargingProfile operation middleware +func (siw *ServerInterfaceWrapper) PutReceiverChargingProfile(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "sessionId" ------------- + var sessionId string + + err = runtime.BindStyledParameterWithLocation("simple", false, "sessionId", runtime.ParamLocationPath, chi.URLParam(r, "sessionId"), &sessionId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sessionId", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PutReceiverChargingProfileParams + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PutReceiverChargingProfile(w, r, sessionId, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PostGenericChargingProfileResult operation middleware +func (siw *ServerInterfaceWrapper) PostGenericChargingProfileResult(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "uid" ------------- + var uid string + + err = runtime.BindStyledParameterWithLocation("simple", false, "uid", runtime.ParamLocationPath, chi.URLParam(r, "uid"), &uid) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "uid", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PostGenericChargingProfileResultParams + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostGenericChargingProfileResult(w, r, uid, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PutSenderChargingProfile operation middleware +func (siw *ServerInterfaceWrapper) PutSenderChargingProfile(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "sessionId" ------------- + var sessionId string + + err = runtime.BindStyledParameterWithLocation("simple", false, "sessionId", runtime.ParamLocationPath, chi.URLParam(r, "sessionId"), &sessionId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sessionId", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PutSenderChargingProfileParams + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PutSenderChargingProfile(w, r, sessionId, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PostClientOwnedCdr operation middleware +func (siw *ServerInterfaceWrapper) PostClientOwnedCdr(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PostClientOwnedCdrParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostClientOwnedCdr(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetClientOwnedCdr operation middleware +func (siw *ServerInterfaceWrapper) GetClientOwnedCdr(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "cdrID" ------------- + var cdrID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "cdrID", runtime.ParamLocationPath, chi.URLParam(r, "cdrID"), &cdrID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "cdrID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetClientOwnedCdrParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetClientOwnedCdr(w, r, cdrID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PostCancelReservation operation middleware +func (siw *ServerInterfaceWrapper) PostCancelReservation(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PostCancelReservationParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostCancelReservation(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PostReserveNow operation middleware +func (siw *ServerInterfaceWrapper) PostReserveNow(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PostReserveNowParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostReserveNow(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PostStartSession operation middleware +func (siw *ServerInterfaceWrapper) PostStartSession(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PostStartSessionParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostStartSession(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PostStopSession operation middleware +func (siw *ServerInterfaceWrapper) PostStopSession(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PostStopSessionParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostStopSession(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PostUnlockConnector operation middleware +func (siw *ServerInterfaceWrapper) PostUnlockConnector(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PostUnlockConnectorParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostUnlockConnector(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetClientOwnedLocation operation middleware +func (siw *ServerInterfaceWrapper) GetClientOwnedLocation(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetClientOwnedLocationParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetClientOwnedLocation(w, r, countryCode, partyID, locationID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PatchClientOwnedLocation operation middleware +func (siw *ServerInterfaceWrapper) PatchClientOwnedLocation(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PatchClientOwnedLocationParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PatchClientOwnedLocation(w, r, countryCode, partyID, locationID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PutClientOwnedLocation operation middleware +func (siw *ServerInterfaceWrapper) PutClientOwnedLocation(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PutClientOwnedLocationParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PutClientOwnedLocation(w, r, countryCode, partyID, locationID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetClientOwnedEvse operation middleware +func (siw *ServerInterfaceWrapper) GetClientOwnedEvse(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + // ------------- Path parameter "evseUID" ------------- + var evseUID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "evseUID", runtime.ParamLocationPath, chi.URLParam(r, "evseUID"), &evseUID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "evseUID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetClientOwnedEvseParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetClientOwnedEvse(w, r, countryCode, partyID, locationID, evseUID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PatchClientOwnedEvse operation middleware +func (siw *ServerInterfaceWrapper) PatchClientOwnedEvse(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + // ------------- Path parameter "evseUID" ------------- + var evseUID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "evseUID", runtime.ParamLocationPath, chi.URLParam(r, "evseUID"), &evseUID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "evseUID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PatchClientOwnedEvseParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PatchClientOwnedEvse(w, r, countryCode, partyID, locationID, evseUID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PutClientOwnedEvse operation middleware +func (siw *ServerInterfaceWrapper) PutClientOwnedEvse(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + // ------------- Path parameter "evseUID" ------------- + var evseUID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "evseUID", runtime.ParamLocationPath, chi.URLParam(r, "evseUID"), &evseUID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "evseUID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PutClientOwnedEvseParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PutClientOwnedEvse(w, r, countryCode, partyID, locationID, evseUID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetClientOwnedConnector operation middleware +func (siw *ServerInterfaceWrapper) GetClientOwnedConnector(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + // ------------- Path parameter "evseUID" ------------- + var evseUID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "evseUID", runtime.ParamLocationPath, chi.URLParam(r, "evseUID"), &evseUID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "evseUID", Err: err}) + return + } + + // ------------- Path parameter "connectorID" ------------- + var connectorID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "connectorID", runtime.ParamLocationPath, chi.URLParam(r, "connectorID"), &connectorID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "connectorID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetClientOwnedConnectorParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetClientOwnedConnector(w, r, countryCode, partyID, locationID, evseUID, connectorID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PatchClientOwnedConnector operation middleware +func (siw *ServerInterfaceWrapper) PatchClientOwnedConnector(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + // ------------- Path parameter "evseUID" ------------- + var evseUID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "evseUID", runtime.ParamLocationPath, chi.URLParam(r, "evseUID"), &evseUID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "evseUID", Err: err}) + return + } + + // ------------- Path parameter "connectorID" ------------- + var connectorID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "connectorID", runtime.ParamLocationPath, chi.URLParam(r, "connectorID"), &connectorID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "connectorID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PatchClientOwnedConnectorParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PatchClientOwnedConnector(w, r, countryCode, partyID, locationID, evseUID, connectorID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PutClientOwnedConnector operation middleware +func (siw *ServerInterfaceWrapper) PutClientOwnedConnector(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + // ------------- Path parameter "evseUID" ------------- + var evseUID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "evseUID", runtime.ParamLocationPath, chi.URLParam(r, "evseUID"), &evseUID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "evseUID", Err: err}) + return + } + + // ------------- Path parameter "connectorID" ------------- + var connectorID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "connectorID", runtime.ParamLocationPath, chi.URLParam(r, "connectorID"), &connectorID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "connectorID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PutClientOwnedConnectorParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PutClientOwnedConnector(w, r, countryCode, partyID, locationID, evseUID, connectorID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetClientOwnedSession operation middleware +func (siw *ServerInterfaceWrapper) GetClientOwnedSession(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- Path parameter "sessionID" ------------- + var sessionID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "sessionID", runtime.ParamLocationPath, chi.URLParam(r, "sessionID"), &sessionID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sessionID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetClientOwnedSessionParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetClientOwnedSession(w, r, countryCode, partyID, sessionID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PatchClientOwnedSession operation middleware +func (siw *ServerInterfaceWrapper) PatchClientOwnedSession(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- Path parameter "sessionID" ------------- + var sessionID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "sessionID", runtime.ParamLocationPath, chi.URLParam(r, "sessionID"), &sessionID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sessionID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PatchClientOwnedSessionParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PatchClientOwnedSession(w, r, countryCode, partyID, sessionID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PutClientOwnedSession operation middleware +func (siw *ServerInterfaceWrapper) PutClientOwnedSession(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- Path parameter "sessionID" ------------- + var sessionID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "sessionID", runtime.ParamLocationPath, chi.URLParam(r, "sessionID"), &sessionID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sessionID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PutClientOwnedSessionParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PutClientOwnedSession(w, r, countryCode, partyID, sessionID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// DeleteClientOwnedTariff operation middleware +func (siw *ServerInterfaceWrapper) DeleteClientOwnedTariff(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- Path parameter "tariffID" ------------- + var tariffID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "tariffID", runtime.ParamLocationPath, chi.URLParam(r, "tariffID"), &tariffID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "tariffID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params DeleteClientOwnedTariffParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.DeleteClientOwnedTariff(w, r, countryCode, partyID, tariffID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetClientOwnedTariff operation middleware +func (siw *ServerInterfaceWrapper) GetClientOwnedTariff(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- Path parameter "tariffID" ------------- + var tariffID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "tariffID", runtime.ParamLocationPath, chi.URLParam(r, "tariffID"), &tariffID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "tariffID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetClientOwnedTariffParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetClientOwnedTariff(w, r, countryCode, partyID, tariffID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PutClientOwnedTariff operation middleware +func (siw *ServerInterfaceWrapper) PutClientOwnedTariff(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- Path parameter "tariffID" ------------- + var tariffID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "tariffID", runtime.ParamLocationPath, chi.URLParam(r, "tariffID"), &tariffID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "tariffID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PutClientOwnedTariffParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PutClientOwnedTariff(w, r, countryCode, partyID, tariffID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetClientOwnedToken operation middleware +func (siw *ServerInterfaceWrapper) GetClientOwnedToken(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetClientOwnedTokenParams + + // ------------- Optional query parameter "type" ------------- + + err = runtime.BindQueryParameter("form", true, false, "type", r.URL.Query(), ¶ms.Type) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "type", Err: err}) + return + } + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetClientOwnedToken(w, r, countryCode, partyID, tokenUID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PatchClientOwnedToken operation middleware +func (siw *ServerInterfaceWrapper) PatchClientOwnedToken(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PatchClientOwnedTokenParams + + // ------------- Optional query parameter "type" ------------- + + err = runtime.BindQueryParameter("form", true, false, "type", r.URL.Query(), ¶ms.Type) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "type", Err: err}) + return + } + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PatchClientOwnedToken(w, r, countryCode, partyID, tokenUID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PutClientOwnedToken operation middleware +func (siw *ServerInterfaceWrapper) PutClientOwnedToken(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "countryCode" ------------- + var countryCode string + + err = runtime.BindStyledParameterWithLocation("simple", false, "countryCode", runtime.ParamLocationPath, chi.URLParam(r, "countryCode"), &countryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "countryCode", Err: err}) + return + } + + // ------------- Path parameter "partyID" ------------- + var partyID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "partyID", runtime.ParamLocationPath, chi.URLParam(r, "partyID"), &partyID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "partyID", Err: err}) + return + } + + // ------------- 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 + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PutClientOwnedTokenParams + + // ------------- Optional query parameter "type" ------------- + + err = runtime.BindQueryParameter("form", true, false, "type", r.URL.Query(), ¶ms.Type) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "type", Err: err}) + return + } + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PutClientOwnedToken(w, r, countryCode, partyID, tokenUID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetCdrsFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetCdrsFromDataOwner(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetCdrsFromDataOwnerParams + + // ------------- Optional query parameter "date_from" ------------- + + err = runtime.BindQueryParameter("form", true, false, "date_from", r.URL.Query(), ¶ms.DateFrom) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "date_from", Err: err}) + return + } + + // ------------- Optional query parameter "date_to" ------------- + + err = runtime.BindQueryParameter("form", true, false, "date_to", r.URL.Query(), ¶ms.DateTo) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "date_to", Err: err}) + return + } + + // ------------- 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 + } + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetCdrsFromDataOwner(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetCdrPageFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetCdrPageFromDataOwner(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "uid" ------------- + var uid string + + err = runtime.BindStyledParameterWithLocation("simple", false, "uid", runtime.ParamLocationPath, chi.URLParam(r, "uid"), &uid) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "uid", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetCdrPageFromDataOwnerParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetCdrPageFromDataOwner(w, r, uid, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PostAsyncResponse operation middleware +func (siw *ServerInterfaceWrapper) PostAsyncResponse(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "command" ------------- + var command PostAsyncResponseParamsCommand + + err = runtime.BindStyledParameterWithLocation("simple", false, "command", runtime.ParamLocationPath, chi.URLParam(r, "command"), &command) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "command", Err: err}) + return + } + + // ------------- Path parameter "uid" ------------- + var uid string + + err = runtime.BindStyledParameterWithLocation("simple", false, "uid", runtime.ParamLocationPath, chi.URLParam(r, "uid"), &uid) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "uid", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PostAsyncResponseParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostAsyncResponse(w, r, command, uid, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetLocationListFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetLocationListFromDataOwner(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetLocationListFromDataOwnerParams + + // ------------- Optional query parameter "date_from" ------------- + + err = runtime.BindQueryParameter("form", true, false, "date_from", r.URL.Query(), ¶ms.DateFrom) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "date_from", Err: err}) + return + } + + // ------------- Optional query parameter "date_to" ------------- + + err = runtime.BindQueryParameter("form", true, false, "date_to", r.URL.Query(), ¶ms.DateTo) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "date_to", Err: err}) + return + } + + // ------------- 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 + } + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetLocationListFromDataOwner(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetLocationPageFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetLocationPageFromDataOwner(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "uid" ------------- + var uid string + + err = runtime.BindStyledParameterWithLocation("simple", false, "uid", runtime.ParamLocationPath, chi.URLParam(r, "uid"), &uid) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "uid", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetLocationPageFromDataOwnerParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetLocationPageFromDataOwner(w, r, uid, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetLocationObjectFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetLocationObjectFromDataOwner(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 + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetLocationObjectFromDataOwnerParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetLocationObjectFromDataOwner(w, r, locationID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetEvseObjectFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetEvseObjectFromDataOwner(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 + } + + // ------------- Path parameter "evseUID" ------------- + var evseUID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "evseUID", runtime.ParamLocationPath, chi.URLParam(r, "evseUID"), &evseUID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "evseUID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetEvseObjectFromDataOwnerParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetEvseObjectFromDataOwner(w, r, locationID, evseUID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetConnectorObjectFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetConnectorObjectFromDataOwner(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 + } + + // ------------- Path parameter "evseUID" ------------- + var evseUID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "evseUID", runtime.ParamLocationPath, chi.URLParam(r, "evseUID"), &evseUID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "evseUID", Err: err}) + return + } + + // ------------- Path parameter "connectorID" ------------- + var connectorID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "connectorID", runtime.ParamLocationPath, chi.URLParam(r, "connectorID"), &connectorID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "connectorID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetConnectorObjectFromDataOwnerParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetConnectorObjectFromDataOwner(w, r, locationID, evseUID, connectorID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetSessionsFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetSessionsFromDataOwner(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetSessionsFromDataOwnerParams + + // ------------- Optional query parameter "date_from" ------------- + + err = runtime.BindQueryParameter("form", true, false, "date_from", r.URL.Query(), ¶ms.DateFrom) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "date_from", Err: err}) + return + } + + // ------------- Optional query parameter "date_to" ------------- + + err = runtime.BindQueryParameter("form", true, false, "date_to", r.URL.Query(), ¶ms.DateTo) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "date_to", Err: err}) + return + } + + // ------------- 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 + } + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetSessionsFromDataOwner(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetSessionsPageFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetSessionsPageFromDataOwner(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "uid" ------------- + var uid string + + err = runtime.BindStyledParameterWithLocation("simple", false, "uid", runtime.ParamLocationPath, chi.URLParam(r, "uid"), &uid) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "uid", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetSessionsPageFromDataOwnerParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetSessionsPageFromDataOwner(w, r, uid, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PutChargingPreferences operation middleware +func (siw *ServerInterfaceWrapper) PutChargingPreferences(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "sessionID" ------------- + var sessionID string + + err = runtime.BindStyledParameterWithLocation("simple", false, "sessionID", runtime.ParamLocationPath, chi.URLParam(r, "sessionID"), &sessionID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sessionID", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PutChargingPreferencesParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PutChargingPreferences(w, r, sessionID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetTariffsFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetTariffsFromDataOwner(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetTariffsFromDataOwnerParams + + // ------------- Optional query parameter "date_from" ------------- + + err = runtime.BindQueryParameter("form", true, false, "date_from", r.URL.Query(), ¶ms.DateFrom) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "date_from", Err: err}) + return + } + + // ------------- Optional query parameter "date_to" ------------- + + err = runtime.BindQueryParameter("form", true, false, "date_to", r.URL.Query(), ¶ms.DateTo) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "date_to", Err: err}) + return + } + + // ------------- 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 + } + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetTariffsFromDataOwner(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetTariffsPageFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetTariffsPageFromDataOwner(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "uid" ------------- + var uid string + + err = runtime.BindStyledParameterWithLocation("simple", false, "uid", runtime.ParamLocationPath, chi.URLParam(r, "uid"), &uid) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "uid", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetTariffsPageFromDataOwnerParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetTariffsPageFromDataOwner(w, r, uid, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetTokensFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetTokensFromDataOwner(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetTokensFromDataOwnerParams + + // ------------- Optional query parameter "date_from" ------------- + + err = runtime.BindQueryParameter("form", true, false, "date_from", r.URL.Query(), ¶ms.DateFrom) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "date_from", Err: err}) + return + } + + // ------------- Optional query parameter "date_to" ------------- + + err = runtime.BindQueryParameter("form", true, false, "date_to", r.URL.Query(), ¶ms.DateTo) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "date_to", Err: err}) + return + } + + // ------------- 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 + } + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetTokensFromDataOwner(w, r, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetTokensPageFromDataOwner operation middleware +func (siw *ServerInterfaceWrapper) GetTokensPageFromDataOwner(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + // ------------- Path parameter "uid" ------------- + var uid string + + err = runtime.BindStyledParameterWithLocation("simple", false, "uid", runtime.ParamLocationPath, chi.URLParam(r, "uid"), &uid) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "uid", Err: err}) + return + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetTokensPageFromDataOwnerParams + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetTokensPageFromDataOwner(w, r, uid, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// PostRealTimeTokenAuthorization operation middleware +func (siw *ServerInterfaceWrapper) PostRealTimeTokenAuthorization(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 + } + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params PostRealTimeTokenAuthorizationParams + + // ------------- Optional query parameter "type" ------------- + + err = runtime.BindQueryParameter("form", true, false, "type", r.URL.Query(), ¶ms.Type) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "type", Err: err}) + return + } + + headers := r.Header + + // ------------- Required header parameter "authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "authorization", Err: err}) + return + } + + // ------------- Required header parameter "X-Request-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { + var XRequestID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + return + } + + params.XRequestID = XRequestID + + } else { + err := fmt.Errorf("Header parameter X-Request-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Request-ID", Err: err}) + return + } + + // ------------- Required header parameter "X-Correlation-ID" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Correlation-ID")]; found { + var XCorrelationID string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Correlation-ID", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Correlation-ID", runtime.ParamLocationHeader, valueList[0], &XCorrelationID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + params.XCorrelationID = XCorrelationID + + } else { + err := fmt.Errorf("Header parameter X-Correlation-ID is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "X-Correlation-ID", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-country-code")]; found { + var OCPIFromCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIFromCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + params.OCPIFromCountryCode = OCPIFromCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-from-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-from-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-from-party-id")]; found { + var OCPIFromPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-from-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-from-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIFromPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + params.OCPIFromPartyId = OCPIFromPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-from-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-from-party-id", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-country-code" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-country-code")]; found { + var OCPIToCountryCode string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-country-code", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-country-code", runtime.ParamLocationHeader, valueList[0], &OCPIToCountryCode) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + params.OCPIToCountryCode = OCPIToCountryCode + + } else { + err := fmt.Errorf("Header parameter OCPI-to-country-code is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-country-code", Err: err}) + return + } + + // ------------- Required header parameter "OCPI-to-party-id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("OCPI-to-party-id")]; found { + var OCPIToPartyId string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "OCPI-to-party-id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "OCPI-to-party-id", runtime.ParamLocationHeader, valueList[0], &OCPIToPartyId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + params.OCPIToPartyId = OCPIToPartyId + + } else { + err := fmt.Errorf("Header parameter OCPI-to-party-id is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "OCPI-to-party-id", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostRealTimeTokenAuthorization(w, r, tokenUID, params) + }) + + for i := len(siw.HandlerMiddlewares) - 1; i >= 0; i-- { + handler = siw.HandlerMiddlewares[i](handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + +// GetVersions operation middleware +func (siw *ServerInterfaceWrapper) GetVersions(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var err error + + ctx = context.WithValue(ctx, TokenScopes, []string{}) + + // Parameter object where we will unmarshal all parameters from the context + var params GetVersionsParams + + headers := r.Header + + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "Authorization", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "Authorization", runtime.ParamLocationHeader, valueList[0], &Authorization) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "Authorization", Err: err}) + return + } + + params.Authorization = Authorization + + } else { + err := fmt.Errorf("Header parameter Authorization is required, but not found") + siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "Authorization", Err: err}) + return + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetVersions(w, r, params) + }) + + 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.Get(options.BaseURL+"/ocpi/2.2", wrapper.GetVersion) + }) + r.Group(func(r chi.Router) { + r.Delete(options.BaseURL+"/ocpi/2.2/credentials", wrapper.DeleteCredentials) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/2.2/credentials", wrapper.GetCredentials) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/ocpi/2.2/credentials", wrapper.PostCredentials) + }) + r.Group(func(r chi.Router) { + r.Put(options.BaseURL+"/ocpi/2.2/credentials", wrapper.PutCredentials) + }) + r.Group(func(r chi.Router) { + r.Delete(options.BaseURL+"/ocpi/2.2/receiver/chargingprofiles/{sessionId}", wrapper.DeleteReceiverChargingProfile) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/2.2/receiver/chargingprofiles/{sessionId}", wrapper.GetReceiverChargingProfile) + }) + r.Group(func(r chi.Router) { + r.Put(options.BaseURL+"/ocpi/2.2/receiver/chargingprofiles/{sessionId}", wrapper.PutReceiverChargingProfile) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/ocpi/2.2/sender/chargingprofiles/result/{uid}", wrapper.PostGenericChargingProfileResult) + }) + r.Group(func(r chi.Router) { + r.Put(options.BaseURL+"/ocpi/2.2/sender/chargingprofiles/{sessionId}", wrapper.PutSenderChargingProfile) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/ocpi/receiver/2.2/cdrs", wrapper.PostClientOwnedCdr) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/receiver/2.2/cdrs/{cdrID}", wrapper.GetClientOwnedCdr) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/ocpi/receiver/2.2/commands/CANCEL_RESERVATION", wrapper.PostCancelReservation) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/ocpi/receiver/2.2/commands/RESERVE_NOW", wrapper.PostReserveNow) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/ocpi/receiver/2.2/commands/START_SESSION", wrapper.PostStartSession) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/ocpi/receiver/2.2/commands/STOP_SESSION", wrapper.PostStopSession) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/ocpi/receiver/2.2/commands/UNLOCK_CONNECTOR", wrapper.PostUnlockConnector) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}", wrapper.GetClientOwnedLocation) + }) + r.Group(func(r chi.Router) { + r.Patch(options.BaseURL+"/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}", wrapper.PatchClientOwnedLocation) + }) + r.Group(func(r chi.Router) { + r.Put(options.BaseURL+"/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}", wrapper.PutClientOwnedLocation) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}", wrapper.GetClientOwnedEvse) + }) + r.Group(func(r chi.Router) { + r.Patch(options.BaseURL+"/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}", wrapper.PatchClientOwnedEvse) + }) + r.Group(func(r chi.Router) { + r.Put(options.BaseURL+"/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}", wrapper.PutClientOwnedEvse) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}/{connectorID}", wrapper.GetClientOwnedConnector) + }) + r.Group(func(r chi.Router) { + r.Patch(options.BaseURL+"/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}/{connectorID}", wrapper.PatchClientOwnedConnector) + }) + r.Group(func(r chi.Router) { + r.Put(options.BaseURL+"/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}/{connectorID}", wrapper.PutClientOwnedConnector) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/receiver/2.2/sessions/{countryCode}/{partyID}/{sessionID}", wrapper.GetClientOwnedSession) + }) + r.Group(func(r chi.Router) { + r.Patch(options.BaseURL+"/ocpi/receiver/2.2/sessions/{countryCode}/{partyID}/{sessionID}", wrapper.PatchClientOwnedSession) + }) + r.Group(func(r chi.Router) { + r.Put(options.BaseURL+"/ocpi/receiver/2.2/sessions/{countryCode}/{partyID}/{sessionID}", wrapper.PutClientOwnedSession) + }) + r.Group(func(r chi.Router) { + r.Delete(options.BaseURL+"/ocpi/receiver/2.2/tariffs/{countryCode}/{partyID}/{tariffID}", wrapper.DeleteClientOwnedTariff) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/receiver/2.2/tariffs/{countryCode}/{partyID}/{tariffID}", wrapper.GetClientOwnedTariff) + }) + r.Group(func(r chi.Router) { + r.Put(options.BaseURL+"/ocpi/receiver/2.2/tariffs/{countryCode}/{partyID}/{tariffID}", wrapper.PutClientOwnedTariff) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/receiver/2.2/tokens/{countryCode}/{partyID}/{tokenUID}", wrapper.GetClientOwnedToken) + }) + r.Group(func(r chi.Router) { + r.Patch(options.BaseURL+"/ocpi/receiver/2.2/tokens/{countryCode}/{partyID}/{tokenUID}", wrapper.PatchClientOwnedToken) + }) + r.Group(func(r chi.Router) { + r.Put(options.BaseURL+"/ocpi/receiver/2.2/tokens/{countryCode}/{partyID}/{tokenUID}", wrapper.PutClientOwnedToken) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/cdrs", wrapper.GetCdrsFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/cdrs/page/{uid}", wrapper.GetCdrPageFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/ocpi/sender/2.2/commands/{command}/{uid}", wrapper.PostAsyncResponse) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/locations", wrapper.GetLocationListFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/locations/page/{uid}", wrapper.GetLocationPageFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/locations/{locationID}", wrapper.GetLocationObjectFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/locations/{locationID}/{evseUID}", wrapper.GetEvseObjectFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/locations/{locationID}/{evseUID}/{connectorID}", wrapper.GetConnectorObjectFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/sessions", wrapper.GetSessionsFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/sessions/page/{uid}", wrapper.GetSessionsPageFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Put(options.BaseURL+"/ocpi/sender/2.2/sessions/{sessionID}/charging_preferences", wrapper.PutChargingPreferences) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/tariffs", wrapper.GetTariffsFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/tariffs/page/{uid}", wrapper.GetTariffsPageFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/tokens", wrapper.GetTokensFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/sender/2.2/tokens/page/{uid}", wrapper.GetTokensPageFromDataOwner) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/ocpi/sender/2.2/tokens/{tokenUID}/authorize", wrapper.PostRealTimeTokenAuthorization) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/ocpi/versions", wrapper.GetVersions) + }) + + return r +} + +// Base64 encoded, gzipped, json marshaled Swagger object +var swaggerSpec = []string{ + + "H4sIAAAAAAAC/+x9b3OjOBL3V6H8PC/urpzxzOze1l3eMZgk3DjGD8bJTO1OUQootm4weIVwJjeV7/6U", + "hMACxB87yUyc1ZsEDBKtlvqn7lar9X3gx+tNHMGIJIPT74PEX8E1YJe6T9AWGiuAlyhaznB8i0JIH2xw", + "vIGYIMhe8/kL3mb3xv/F8HZwOvg/o13lI17zqFrhw3CQEICJFwACPYLWrAZyv4GD00FCMIqWg4eH4QDD", + "P1OEYTA4/b3+zXodX4Z5HfHNf6FP6Hf0IEAExREIz2E8iX1Ab+otCgFBJA1kdAwHYRwtm59GYN3JgDFK", + "NiG4d+E3UmtY8WnxQ9KmpGQVY/Q/1gQruo3rzQBhGN/Rar8PYJSuafX6ZGJfm+PBcPBhYhsf2ZX5aWY5", + "7Gpqe4Zjji2XXbte/vbu+7uGAvH7Hoa3EMPIlzMFcfJ6M4U2ftc5bcXyTnRyAhJamsRfYWdRl71U7YCc", + "aXklMt5/SBMUwSQZQwJQmEgGULzsbLC1BksoDpka2+7gTYJID2lgNcgINcaOZFikZOWtIVnF5aGxcC88", + "x/x/C3NO+9+wLy/1KR0V1xeWa06sufvoceAH2OvbsUaACwHlRXv1qhFg3rFDASUgRnHAWo8IXCe9IYqV", + "YyMqawvAGNyzquM0Ivje8+MGIPAxDBARHt3EcQhBtHu2Y5aHAnkdKabP76UPYRS0IuZw0FArirYx8mH3", + "50OQEC/d0I/IX1hDAnFT6Q3A5L7pIYZrgL9KHyUwSehQaiiZoGUEWctBVy/O2atj+mavOWY4IACj29v+", + "48Rl78vGB4kJCD0/TkhXHTOMfLgrAiOIl6zHb2O8BmRwOrgNY0AGxTeidH0DcbXEId+6Rd9gcEjBDcBf", + "qVw9omjeB31biWEC8TZDmQM+u+/n6Pv7fKc6iwgYW8E9EcskEFWBFgEEqiLPBLwipYLY1Ud8aVRWxluJ", + "T9KpBEQ+DJ1dL9QnFrGLGuU+2cRRAr0Uh93zWqXCSnEplQEeozWMEimB2eu7Kc9YOI45pbOdOTWd88/F", + "hWd+mtnO7oFnXfL7S/2Ttyt2aU3FO/2TN7OvTYc/ya9nuvPRmp57rnVp0lv+s2POTedKdy17mj+au7pr", + "evaZZ1zozjn9hT2QzbvbOEz7DekKU9nTonwDE5t1YxAEGCaJfL5CRD5X+XEUQZ/E2MuJ3XXCnOqhTOPQ", + "P0zkbd0Vb5ooixc28R3EXrWjdcN7580u9DllqW54vxQ3Y6PjiwkBUQBwSVUyLvSxeWnT4valOXctw9PF", + "mw/ijSHejMUbU7w5E2/OxZsL8cYSb/4j3nwUbyaD4cAyDe+3t7+8/bf33ktQtAyh9+63yu9khWHjz7+8", + "l/7826/5z+/f/fs3z31XufUM+/KDXf7xfeVW9s4veuXeYLIzde1zR59deB9s17UvvcWs/LNrz7yxfT2l", + "wmLOJ7rnFFfzhr6NcYAiQGDn/C5aiTulT66ObZNGRYo9S5vUsaDVkKzrVXGSgXjQwzLIpZXLpkQSK9LV", + "IEtSiSizcseeHTOEpvPZSqS+AXvcXM2vuBniiGDgkyYm12R+7F3YhreYM7DVZ7P80nYvMvw9s+Smrbyn", + "qh4IgZxhDqq0pLRVZXui1rYgn7P2MFHEmU6igPZXd70+zRUo7Odq2Xl5dpZ5vd2QqispbqExQAnTkaAn", + "uDPqJhVXgiOYvdCt5nHHUW2qMC5MnSLMmc7M4HPHNKdssj5fTHRHMl4qjCrV286Ynv40rhrub7xmxVts", + "2PxDmPZkGqHSvHxNpUYqH0GKC+WgYDSKCJsv+NsoInCZcXqNIq/0qX4ddLhPcNecHvxvEskQrTN+9KV0", + "10udPKn6/NinKvX0IN3h2rBUE09DUtaADHPmci+f680XM6rQsnvH/I9pZJeubXv2mctG/GL6cWpfT725", + "OZ9b9lQ6EmjHxCk5pNGcxF0d0gbH6zWIguaGrmGSgCXc07lYZ08LTwTOvSyW8CY8D0OEVhv61DAn5tgT", + "DBZqGV3NTc82jMXMytzI9N6a2jPT0V3rymQYak06h5x1adoLV+Cu+JlOuOWUyznFNZY6lw6yQg72koFv", + "HlhvIOb90gcywTcPhtAnGPmZGrZHwW0ckv6feiKDqd1MMi50+z/WC7eXzj+4nm7wi7HxWiyoqXmpe//0", + "3r/Nr3/zfhGu/1lcv3srPHj3Vnzyq/jk1+zJIy2zQt7lKJprpmWFuEHpF9yuEK8TD0SB58dRttaXdGsO", + "hSkkc6iVxLcsYSXpEWRAikYYBjAiCMjWi3Acwj1U/11VTpwtoNbdz9yGqhs3vRxvjJ68mqxQR6MYJbWG", + "3fCVMi/YLZW1Na26stZnpaV9oYGTVWDSjMqMeTmnY/ViQZFnyvT9Kfsltw3nxnzWPfnUWldz3greWEaJ", + "jIniXCxZio6WKUfz+ujnRdqpLKrgBWQ0mFGwiVEkIQCxDr5F2RTUyd+5OR1z76ZhWlemI7ew+wxC4cv8", + "O80D0WTmn8Ft8v2dB0m62YQIYq/B7VIhrfx6M0GX6FudFm6qbnAcpD7xGh09/L0kTrG/BzpkX56zUjJo", + "gNEW4Tjy0HrDWdWzWlZsDSMCQisrK6kdJd4SQxgJ61h1Y31PblfrbOY3b3WN5RuIfUr4sq/tWdRTGAgL", + "Y2LqdGCfm1PT0SfemT2fWxO2Uq4z9UGfC09zv8HcnrBS11a2lq67Zh8nwo7eghh5q+udUvfYrykm9Wu4", + "DwhcxpmLs9J071qfuybTkJ0P9tQbW/Yna2x2N4Z/X6hc2pStzL7zwQbcoBAVaJQPVUHHdM6t6bk3c+wz", + "a2J6hj5jGvxQfGSemY45Ncx56bE18wzdGeeWCevKqasb7sScz2uPWGBM9utM/8wrGZsf6j/OzLHnms6l", + "NWUDwzEvbdf05q7uuN6cKkU7Iritw2/OLGpk6RmAuvZHc+qdO/ZCLLCYTmzjY/GDVHeqhSpwO2gPDaMw", + "naT1Heo/DxCGPtnLzVkxVGtgtvO6R2kYghs6GxGcQglfbsM4xl4ItzCUO+LXYLkHzhbxO1WaOg3CfAkc", + "Q/qbhCH54DavPHs6+UyH1GRxfs7s5bE1pz3PDPPF3LUvTYfizqXt2o7x2ZiY816DYrO6T5DP1tXbInYS", + "Akhaokm/0q0JH4y7GLJc1qj9UXIB2AvXPrOdbEjPJvp0yh0Al/YVv6ISILpXmuxLkiYeZX6QZipHr16a", + "s3LzvJiEE9zbH8DEx2iT+TUHiwj9mcLwXiuUkEQjK6iZV3NTu0NkhSJ2b8zsRNuEgFBo1f4GouCPKElv", + "KIQBEuPiUfL3N4MunEzzRXvK8ZLYVsaUFD6/+XCThTY2eTQzx6J3A5dIbhrwF2DUYz2gVFmpqIy6czpz", + "I7/uv5T6sHrGkcrDU7u8WYLrqXm89XcyPU8c6aFBoRdxiiXmJdwNDs8P4wRFy259rzagKNwKFcUbGB1c", + "EYbLNATYW+UEt9XgZC9njaMSfAcjcn9Lb+G2ZOYWOmY15qFSQsa7DM8lGkhdI8qiMxwWHuI6+tSgSDex", + "jdw1OjXda9v5SOGPQaEtLjva19MGq2gF0XIl9xw3TG6CH4+s0vVNBFBYKp9i1Fy6vnbaZKhV6qtHqqKA", + "rA4ivIqBOBQVRf6+rLsOjFDJ14juVjBistAwR7eEsjxH9ECnk+MZVKfMvFxnJmq3RUltWa5x7WGMUq1e", + "8vFb4Ldp9Re2a2aq89zVF44+zTzzZyaLsprQR/PFzHQudSfz2s+5lu6YhmNmIVW6Y+rMu+MuHFZuMTcX", + "l1RrsT6a3vxCdzJ95cNizrRyqnLrnyyqpzNTzXX0y/zBpek6Nn3CBdx1dGsq3OuWwwnIY70mdkayM7Pt", + "icd/HQwHZwtzIhS8ts6sXvpaU/DIj9JZc0u9E0r4tMDWbDvpKSA9V5gO8A/GdxE8pFwRiFpd+pjY03OP", + "6dPX+mehS891R2cxeeU+pqawY12Z2cs2HRaOaWYLWmPToQbcdJwX/tIDjFv9mZXon+7K0psQJSu5H4Y/", + "zCMrPBL3HkmzrCiL1XFpxZJBhWFIx1MR+tp/nMr36cijXEg/Rgha+QGDhYUD/y+O+oQhNHqAswAo3iFD", + "WWxWHj9VjqvqVP4lm2BkHtAiymvPRZU8hmvPYnm394ovEl+WNdH2N6g5DCDfDVArxs3GXFx6rIfyEsI6", + "unSJPyFgvenhKBa+LxbsamKP3V19dkDUqzlinkg3M/XhAi143O2eoIQ0t72fSy9jggxAj5Ip9fDCbniQ", + "uAPG5kx3qIbItr7xfZA86H9qsqCX4uep7Xozez63uJuXe5zdzzPTK0e4tHiwjpjTHUFnvUSxobJj5k9X", + "jFovvlQqOWp+NIZd9eOEsPRwtDxoC/boxQWhgiPmg3xRrw8DcsfBsbaczthXEMv3oe01cee1vKLJu9l3", + "12doiPbgsXPgCRS7LvP4GNkzz/aAHzY+8sLH3/4nGB0CM17L4OCb7g8aG7sN+8fd+icYGc25C46WNfKN", + "g73GRZ4y5Kjb/hSjImfEaxkUC76tbf8xwUoeccu54ph5sQ9jQbmKI+NFlplDFgwRelvQMyASRf3frtBa", + "fEiopZFOI2e+LByGt6PPTkS48RL0v76dU137KtJgnE10t565ojkZxUEMyhomUt2y3l9bcKrxaYnjdOOh", + "QJOvlCZJ2hDD/tw7x4eDLUpSEHqcD9JRXmtwKerliYO5hoM7CL8G4P6QbYrNoV+7ar9IG5RAvIXT+E6e", + "k6xvFrHWbArw2wbhe7ZtuCHqyu9KUPPIHDaPyj4nkl8mdtiRDactX12jOfVzU8G9rHxunSlmuhK+PS5Z", + "2yE5Qr7erfrNC53hHV1icXimtz55KCRRxgaPHzbsy9nEzNZqrOmVPrHGLMJ+Os7iado3Cx+Qh60zkVeR", + "uauaNqUxa1clBQrttdouw7Kotybx4tySCzr5Eela98viJcnV2pnHS0jdJ9k/5ccBrW8HXBJ5K73jbXeu", + "2D57oqmu4Xtf4X1bCsItCNM9Yq+yJl3RQtIw9D6srDa9SkvzBjnx6zWORoCkuGFzZQhQ5FXiKxqzMXal", + "KWWfKVVarkJKORWA1hnsSRSHHorBs836tXm+57Re3tvw5DriC9n80a5+tqEhiTeNA6ezP1vzkNY3CIhd", + "JhSV0dXkwHykihHCdZ7Eew8HoJkVk0cIdyoth8UQPyaTRmEN90r+uUbRniUerczw1AUgJF6+P/spwrWF", + "ahsRSG7HzvTPl1mCymKPJM9xld/zXFf57d45r1p0n3xQdiQrbRaTfHzK3SJeOXl9v9DVsr9FGrha3pjX", + "LUWOWELq5xApbW6tU/ly1WV378W3HjWypWHzl/Z0zKKQ3YU5z66uzfE0v3YvFg6/PHOs7GKuuwuHXy5Y", + "6T7R6DkyNNo6jdJBRTgbHz0dcLTAvgnHwDevt2nEMKWWYaf5dRTtST/VdPZPmNaffopw/enH5QS++cgp", + "p3YSM9NmpwPMm0LaOBy2oGVz8ra6DByW+bF78wy8BWlIvCfL+VfMfL6QcaJ7+ivyUzwMC2/lvs7K1oQg", + "fbYeN89uP8APCkLUkMCxy0U6HNytEIEhX+La7da41j/PKXnFyRb8yrPPzibW1GT78a7MXtOYmNKzMqnx", + "LmnLty0kAc2bKlItQ/18dar8YDj4dgK/gfUmzJcs2PXJu8Hp94cHViyM/a8tkXad7qzntIXqbBUdJYI7", + "pMXukTGrMZ6qSSESrP6OrddMbc9fb/l202Ia5Plz9knTwjPuSKbX3nTvPttCfdtoEgn/vZzsJ/9mnuNn", + "l9qHsbsg6YtA747OB2ZB+SlG5J5aqHwzWGEkMzYwCIAAM7niRK8I2QxY8fzUmPLOfHcFNXsDI435paA2", + "o9RrVkQgvgU+1P5mGzPr7xqMwE0IEw1oiQ/YzqChBlISr6nYauaVhmOwRtFSSyBJN9oNJHewWqnN9wsl", + "GogCDV7GLBPJvTaHeIt8qM1wvEUBxMkbzSJakm42MSaJVnJJDLUse63GuKzRNtEpGsWRBr/5KxAtofY3", + "FPlhGlBqQrSFWmbSahnGsI//QYEpSoCfFdzSkfT3ouos+5SGoR/joKh2qGG4jgksE+BngcZZk8gK7qiI", + "b7VkDTA5yf11Gt+/9UckUp1ziuIegsmbP6I/IneFEi3ZQB/dokyitSD2U6q3ayjRYoyWKAJheK/dgAQG", + "WhxptJuT09HoBpGb1P8KyZsYL0fJCmAIoiAjeRT70UkUB3CUYH+0BgmBeJSP5FG8gRHYoBP63Tf/TeJI", + "037XN8BfQW2CfBglcKhxqdXev3n75Y3Gho4xsyqkIpLA8JYSGmblAg0kmoEhILQ3jHi9jqNE0wnB6Cal", + "RU6m8RhitGUvJNqvb95mAzAC2aa1onU+r8TP6mBt5B9JRjf3J1Ew+vXN21EIlyDk8wx/nLnlmIQ8hpJC", + "Wg+miK3PEwYAPcTu/Zv3AxEP6D3fFAo2aHA6+OXN2zfv2LRJVgwRRrG/QSP63un3wRKy2TDbqIfiyAoG", + "p4NzWETSsukWsMUIDlj0IysIAgYhnGGlXU8DETGzvYEZBMvQ9ctuFmLEvX/7NldAucL/j9E/BAyt4+k2", + "97Du9pw8C8BWQjHe1gMtdtUL8RUCQIt8aJuomkNKWCVldLY/Zpo9WNL25nQnJ0y1isMQ4sEX+kLR63RA", + "iqHyAQxhZk6UB8GY/S6Gxb+YsbA/G3twTmBLmXnDRiF5JcwpbX14DJ82fNGvzKhZnPx4Tv2ZwoR8iIP7", + "CpPAZhPyaWhEp7D+HKtxqUzRwzH0TyrrnlT1zgvonRJEY+hDtIV4lGuG3I+SjL7zlQ4reOgGb4dXU11Q", + "fu4+HjbU+OnEybr+hMUUPEWFRoyZ0kw1syeqlOpVJ7c4Xp9wh8QJVxSfsmrmxDjhVviTVEviZ6KXxI+j", + "liqeuyqL8XtQXX+mkKVr4JVVVgFfxmzatOG2Gxt4yZNc2vvqIUrOlZy/ajkvlnPa6uoRVatQpEULVCii", + "UOR1oMgz2RiSWM8fbGo8FyiUjI8ERoHM9Mhyso6+pyizPZqt/dbkswpOFJz8LDhJ0YsAklb5+LGQkm25", + "/CH4UXFdNKkhc1ZcKSEKNZQS0j8H+zGDRuHtZKtTAd982byWECIYEfsugoER4J7IABQyKGR4BDI817LF", + "2Hmhshvg3uI6+u4H2Bo/tMUTKKFVQvtCpnM2WF+Mny8HgKeRRh5rNspOEC4d7Ns+p4LIh6EjhKorCVUS", + "erzTam04/2BHXTW5bLeEc8ndS8r5Zk5val+3i7eQCETJtZLro5VrYRy/SoHmJ1aa83nnjF3apK+EWgn1", + "0Qp1aSS/UrG2Z32lepdAQQm1EuojFurdQH6VMp0fC21Pp6bh2k67XFe3jyrZVrJ9tLJdHcyvSb6Lk/NG", + "33lfGnEAH0bfWQdY44fR9/yV/h7v4sAAJfZK7H+a23s3nJ+gNi4OT1DTTpxeik9+d75HJ7QUcFELsgXE", + "X0l0AfqzQgaFDAoZnhcZDtN6QHEK7qyUbKSWnKTyw0tcwW+GpqZdoAqWFCwpWHqBsNTvMLIjAqGnsL1G", + "3+E2gYv+Vhg74FABmgI0BWhPAmjyyrhQvhRbLjvV9NntOIUtClsUtrxYbFHW4GOsQQVuCtwUuL0ycOs+", + "Cv4va0/S1/na5h67WtTavkJKhZQvFSmb2FXI+YvZEFQOq3hWq1VhlsIshVl/JcxShvBjDGGFlwovFV4q", + "vHzU1tSfFDb7HAY2T4zTYl/nqXN6m9Fq84sCWAWw7XmoXoytWtrg0worOVIcaKgqVFCooFDhyVFBWYON", + "uNRtDCpMUpikMOmFYFJ72u6fsQ35UQAkN7eyA+lbrK3sBW5sdZzrtgOy7Bx0hWMKxxSOVWrKBeqlGFw9", + "QYUDRe9jDBUWKCxQWHBkWMBF9WA06GHiKDRQaKDQ4InR4OkNHBEJXpp9IwWfBvMm/grb1pLY8z32+7n0", + "fQVeCrwUeFXBi0vSUxzNyF4TywXwFqQhGZwOnDP2CRilawoF+ti7sA1vMWcn7uuzWX5puxfsP3v/y/CH", + "KlEMI3rAGMOmA1evFBApIFJA9FqASC2aNYBhD3tSAaECQgWEf2kgbDVkd9rYMWBeYcbyEy/F4+sa7dMA", + "J2c4Xo8BARQTVSi5gsMfCYfVg/UBgR7lweDQwiQ+pGh8e5tAMniS4/tDtEb7VvW8J3pNUPLIM/YqiDLa", + "gCXcnbzdAi4zsIQKXxS+HPF520cilvlBAN/51UOfk/H15D7yi9TlSjSVaP48S4iN2taacjtBcprkcCAe", + "PjcclE+uovfCkTfDQe20DIlR8aKP7N+dOvByz+hvP+ZAwK5ik1ebMpEnFqWoqTQKBVvKYnmtFoso6U+w", + "RVQGND0NmJwSZcUozFFWzE8S1b4HHOW02GypSomrEteXIa6v8UCh/hLbLy2+uU2gklslt69Abv8CaegP", + "kf49kpjm7ylAUICgAOEvmjRUhjH55uQ29OC7q1VQg4IN5SJ8tS5CLuU93Q4dSQ0kCNPTP5iDjfIPKsBR", + "/sGfIadCRseRvwJ4iaKlt8HwFmIY+Vl7GiPB+fsz4XUlt0puf5bcvqgsRTLh+LFhBhIKikilp8QSviW4", + "bZ7PdjQrm0JBhbIpXq1NkQl5T1WlPY9AHV16GhQcaJQ9ocBG2RM/TkbZZqpWuWRvKJFUIqnm/1c7/1MZ", + "7wstPbdf8hxCPSd/9rKa+xXQqLn/x8rnLpfXKBcj2L5xyoEgdNE6I0qviJ4SVyWuP0dcVd4Gihp5fKNT", + "cl0+o6uyBABWdBs/FqK2EFcjHcqVuSuUaDAKNjGKiBaihCQaCEONrKAGtgCF4CaEGh1hWl6XBqKAPfep", + "VFPCAxQttYUzSTQSa3criGH+spZsoI9uka8FkAAUJlqS+isNJKyCJN1sYkxgUFCQaD6ItBuo3cZpFLwZ", + "DOvazVXepH74qB+Mj88ZOIuSvB09ejhnfKWPH4aDBPopRuSeNZ8NhMHp718o5QnE25wv5crPYUQ5CgMt", + "e0dLcTgYDujf08GKkM3piAXhhas4Iaf/evuvt4OHLw//PwAA//9RQVUN3TsBAA==", +} + +// 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 +} diff --git a/manager/ocpi/ocpi.go b/manager/ocpi/ocpi.go new file mode 100644 index 0000000..3f599db --- /dev/null +++ b/manager/ocpi/ocpi.go @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: Apache-2.0 + +package ocpi + +import ( + "context" + "fmt" + "github.com/thoughtworks/maeve-csms/manager/store" + "net/http" +) + +//go:generate oapi-codegen -config cfg.yaml ocpi22-spec.yaml + +type Api interface { + SetExternalUrl(serverUrl string) + RegisterNewParty(ctx context.Context, url, token string) error + GetVersions(ctx context.Context) ([]Version, error) + GetVersion(ctx context.Context) (VersionDetail, error) + SetCredentials(ctx context.Context, token string, credentials Credentials) error +} + +type OCPI struct { + store store.Engine + httpClient *http.Client + externalUrl string + countryCode string + partyId string +} + +func NewOCPI(store store.Engine, httpClient *http.Client, countryCode, partyId string) *OCPI { + return &OCPI{ + store: store, + httpClient: httpClient, + countryCode: countryCode, + partyId: partyId, + } +} + +func (o *OCPI) SetExternalUrl(externalUrl string) { + o.externalUrl = externalUrl +} + +func (o *OCPI) GetVersions(context.Context) ([]Version, error) { + return []Version{ + { + Url: fmt.Sprintf("%s/ocpi/2.2", o.externalUrl), + Version: "2.2", + }, + }, nil +} + +func (o *OCPI) GetVersion(context.Context) (VersionDetail, error) { + return VersionDetail{ + Endpoints: []Endpoint{ + { + Identifier: "credentials", + Role: RECEIVER, + Url: fmt.Sprintf("%s/ocpi/2.2/credentials", o.externalUrl), + }, + }, + Version: "2.2", + }, nil +} + +func (o *OCPI) SetCredentials(ctx context.Context, token string, credentials Credentials) error { + for _, role := range credentials.Roles { + err := o.store.SetPartyDetails(ctx, &store.OcpiParty{ + Role: string(role.Role), + CountryCode: role.CountryCode, + PartyId: role.PartyId, + Url: credentials.Url, + Token: credentials.Token, + }) + if err != nil { + return err + } + } + + reg, err := o.store.GetRegistrationDetails(ctx, token) + if err != nil { + return err + } + + if reg != nil && reg.Status == store.OcpiRegistrationStatusPending { + // delete old token + err := o.store.DeleteRegistrationDetails(ctx, token) + if err != nil { + return err + } + // store new token + err = o.store.SetRegistrationDetails(ctx, credentials.Token, &store.OcpiRegistration{ + Status: store.OcpiRegistrationStatusRegistered, + }) + if err != nil { + return err + } + // register new party + err = o.RegisterNewParty(ctx, credentials.Url, credentials.Token) + if err != nil { + return err + } + } + + return nil +} diff --git a/manager/ocpi/ocpi22-spec.yaml b/manager/ocpi/ocpi22-spec.yaml new file mode 100644 index 0000000..1b4d2e1 --- /dev/null +++ b/manager/ocpi/ocpi22-spec.yaml @@ -0,0 +1,4807 @@ +# SPDX-License-Identifier: CC-BY-ND-4.0 + +# OCPI 2.2 Specification from https://raw.githubusercontent.com/openchargemap/ocm-docs/master/Model/schema/ocpi-2.2-openapi-spec.yaml + +openapi: 3.0.1 +info: + title: Open Charge Point Interface (OCPI) 2.2 + version: '2.2' + description: |- + The Open Charge Point Interface (OCPI) enables a scalable, automated EV roaming setup between Charge Point Operators and eMobility Service Providers. It supports authorization, charge point information exchange (including live status updates and + transaction events), charge detail record exchange, remote charge point commands and the exchange of smart-charging related + information between parties. + + This specification document is originally based on https://bitbucket.org/shareandcharge/ocn-node/src/master/examples/openapi-spec.json [Apache License, Version 2.0]. The OCPI specification itself is licensed as Creative Commons Attribution-NoDerivatives 4.0 International https://creativecommons.org/licenses/by-nd/4.0/legalcode + license: + url: 'https://creativecommons.org/licenses/by-nd/4.0/legalcode' + name: Creative Commons Attribution-NoDerivatives 4.0 International +servers: + - url: 'http://localhost:8080' + description: Generated server url +paths: + /ocpi/2.2: + get: + tags: + - versions-controller + operationId: getVersion + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseVersionDetail' + examples: + example-1: + value: + status_code: 0 + status_message: string + data: + version: string + endpoints: + - identifier: string + role: SENDER + url: string + timestamp: string + /ocpi/versions: + get: + tags: + - versions-controller + operationId: getVersions + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseListVersion' + description: This endpoint lists all the available OCPI versions and the corresponding URLs to where version specific details such as the supported endpoints can be found. + /ocpi/sender/2.2/cdrs: + get: + tags: + - cdrs-controller + operationId: getCdrsFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: date_from + in: query + required: false + schema: + type: string + - name: date_to + in: query + required: false + schema: + type: string + - name: offset + in: query + required: false + schema: + type: integer + format: int32 + - name: limit + in: query + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCDRList' + '/ocpi/sender/2.2/cdrs/page/{uid}': + get: + tags: + - cdrs-controller + operationId: getCdrPageFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: uid + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCDRList' + '/ocpi/receiver/2.2/cdrs/{cdrID}': + get: + tags: + - cdrs-controller + operationId: getClientOwnedCdr + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: cdrID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCDR' + /ocpi/receiver/2.2/cdrs: + post: + tags: + - cdrs-controller + operationId: postClientOwnedCdr + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CDR' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + '/ocpi/2.2/sender/chargingprofiles/result/{uid}': + post: + tags: + - charging-profiles-controller + operationId: postGenericChargingProfileResult + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: uid + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GenericChargingProfileResult' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + '/ocpi/2.2/sender/chargingprofiles/{sessionId}': + put: + tags: + - charging-profiles-controller + operationId: putSenderChargingProfile + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: sessionId + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ActiveChargingProfile' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + '/ocpi/2.2/receiver/chargingprofiles/{sessionId}': + get: + tags: + - charging-profiles-controller + operationId: getReceiverChargingProfile + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: sessionId + in: path + required: true + schema: + type: string + - name: duration + in: query + required: true + schema: + type: integer + format: int32 + - name: response_url + in: query + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseChargingProfileResponse' + put: + tags: + - charging-profiles-controller + operationId: putReceiverChargingProfile + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: sessionId + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SetChargingProfile' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseChargingProfileResponse' + delete: + tags: + - charging-profiles-controller + operationId: deleteReceiverChargingProfile + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: sessionId + in: path + required: true + schema: + type: string + - name: response_url + in: query + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseChargingProfileResponse' + '/ocpi/sender/2.2/commands/{command}/{uid}': + post: + tags: + - commands-controller + operationId: postAsyncResponse + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: command + in: path + required: true + schema: + type: string + enum: + - CANCEL_RESERVATION + - RESERVE_NOW + - START_SESSION + - STOP_SESSION + - UNLOCK_CONNECTOR + - name: uid + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CommandResult' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + /ocpi/receiver/2.2/commands/CANCEL_RESERVATION: + post: + tags: + - commands-controller + operationId: postCancelReservation + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CancelReservation' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCommandResponse' + /ocpi/receiver/2.2/commands/RESERVE_NOW: + post: + tags: + - commands-controller + operationId: postReserveNow + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ReserveNow' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCommandResponse' + /ocpi/receiver/2.2/commands/START_SESSION: + post: + tags: + - commands-controller + operationId: postStartSession + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/StartSession' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCommandResponse' + /ocpi/receiver/2.2/commands/STOP_SESSION: + post: + tags: + - commands-controller + operationId: postStopSession + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/StopSession' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCommandResponse' + /ocpi/receiver/2.2/commands/UNLOCK_CONNECTOR: + post: + tags: + - commands-controller + operationId: postUnlockConnector + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UnlockConnector' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCommandResponse' + /ocpi/2.2/credentials: + get: + tags: + - credentials-controller + operationId: getCredentials + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCredentials' + put: + tags: + - credentials-controller + operationId: putCredentials + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Credentials' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCredentials' + post: + tags: + - credentials-controller + operationId: postCredentials + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Credentials' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseCredentials' + delete: + tags: + - credentials-controller + operationId: deleteCredentials + parameters: + - name: Authorization + in: header + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponse' + /ocpi/sender/2.2/locations: + get: + tags: + - locations-controller + operationId: getLocationListFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: date_from + in: query + required: false + schema: + type: string + - name: date_to + in: query + required: false + schema: + type: string + - name: offset + in: query + required: false + schema: + type: integer + format: int32 + - name: limit + in: query + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseLocationList' + '/ocpi/sender/2.2/locations/page/{uid}': + get: + tags: + - locations-controller + operationId: getLocationPageFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: uid + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseLocationList' + '/ocpi/sender/2.2/locations/{locationID}': + get: + tags: + - locations-controller + operationId: getLocationObjectFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseLocation' + '/ocpi/sender/2.2/locations/{locationID}/{evseUID}': + get: + tags: + - locations-controller + operationId: getEvseObjectFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + - name: evseUID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseEvse' + '/ocpi/sender/2.2/locations/{locationID}/{evseUID}/{connectorID}': + get: + tags: + - locations-controller + operationId: getConnectorObjectFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + - name: evseUID + in: path + required: true + schema: + type: string + - name: connectorID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseConnector' + '/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}': + get: + tags: + - locations-controller + operationId: getClientOwnedLocation + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseLocation' + put: + tags: + - locations-controller + operationId: putClientOwnedLocation + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Location' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + patch: + tags: + - locations-controller + operationId: patchClientOwnedLocation + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: object + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + '/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}': + get: + tags: + - locations-controller + operationId: getClientOwnedEvse + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + - name: evseUID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseEvse' + put: + tags: + - locations-controller + operationId: putClientOwnedEvse + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + - name: evseUID + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Evse' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + patch: + tags: + - locations-controller + operationId: patchClientOwnedEvse + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + - name: evseUID + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: object + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + '/ocpi/receiver/2.2/locations/{countryCode}/{partyID}/{locationID}/{evseUID}/{connectorID}': + get: + tags: + - locations-controller + operationId: getClientOwnedConnector + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + - name: evseUID + in: path + required: true + schema: + type: string + - name: connectorID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseConnector' + put: + tags: + - locations-controller + operationId: putClientOwnedConnector + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + - name: evseUID + in: path + required: true + schema: + type: string + - name: connectorID + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Connector' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + patch: + tags: + - locations-controller + operationId: patchClientOwnedConnector + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: locationID + in: path + required: true + schema: + type: string + - name: evseUID + in: path + required: true + schema: + type: string + - name: connectorID + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: object + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + /ocpi/sender/2.2/sessions: + get: + tags: + - sessions-controller + operationId: getSessionsFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: date_from + in: query + required: false + schema: + type: string + - name: date_to + in: query + required: false + schema: + type: string + - name: offset + in: query + required: false + schema: + type: integer + format: int32 + - name: limit + in: query + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseSessionList' + '/ocpi/sender/2.2/sessions/page/{uid}': + get: + tags: + - sessions-controller + operationId: getSessionsPageFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: uid + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseSessionList' + '/ocpi/sender/2.2/sessions/{sessionID}/charging_preferences': + put: + tags: + - sessions-controller + operationId: putChargingPreferences + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: sessionID + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChargingPreferences' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseChargingPreferencesResponse' + '/ocpi/receiver/2.2/sessions/{countryCode}/{partyID}/{sessionID}': + get: + tags: + - sessions-controller + operationId: getClientOwnedSession + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: sessionID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseSession' + put: + tags: + - sessions-controller + operationId: putClientOwnedSession + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: sessionID + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Session' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + patch: + tags: + - sessions-controller + operationId: patchClientOwnedSession + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: sessionID + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: object + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + '/ocpi/receiver/2.2/tariffs/{countryCode}/{partyID}/{tariffID}': + get: + tags: + - tariffs-controller + operationId: getClientOwnedTariff + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: tariffID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseTariff' + put: + tags: + - tariffs-controller + operationId: putClientOwnedTariff + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: tariffID + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Tariff' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + delete: + tags: + - tariffs-controller + operationId: deleteClientOwnedTariff + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: tariffID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + /ocpi/sender/2.2/tariffs: + get: + tags: + - tariffs-controller + operationId: getTariffsFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: date_from + in: query + required: false + schema: + type: string + - name: date_to + in: query + required: false + schema: + type: string + - name: offset + in: query + required: false + schema: + type: integer + format: int32 + - name: limit + in: query + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseTariffList' + '/ocpi/sender/2.2/tariffs/page/{uid}': + get: + tags: + - tariffs-controller + operationId: getTariffsPageFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: uid + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseTariffList' + /ocpi/sender/2.2/tokens: + get: + tags: + - tokens-controller + operationId: getTokensFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: date_from + in: query + required: false + schema: + type: string + - name: date_to + in: query + required: false + schema: + type: string + - name: offset + in: query + required: false + schema: + type: integer + format: int32 + - name: limit + in: query + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseTokenList' + '/ocpi/sender/2.2/tokens/page/{uid}': + get: + tags: + - tokens-controller + operationId: getTokensPageFromDataOwner + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: uid + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseTokenList' + '/ocpi/sender/2.2/tokens/{tokenUID}/authorize': + post: + tags: + - tokens-controller + operationId: postRealTimeTokenAuthorization + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: tokenUID + in: path + required: true + schema: + type: string + - name: type + in: query + required: false + schema: + type: string + enum: + - AD_HOC_USER + - APP_USER + - OTHER + - RFID + default: RFID + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/LocationReferences' + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseAuthorizationInfo' + '/ocpi/receiver/2.2/tokens/{countryCode}/{partyID}/{tokenUID}': + get: + tags: + - tokens-controller + operationId: getClientOwnedToken + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: tokenUID + in: path + required: true + schema: + type: string + - name: type + in: query + required: false + schema: + type: string + enum: + - AD_HOC_USER + - APP_USER + - OTHER + - RFID + default: RFID + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseToken' + put: + tags: + - tokens-controller + operationId: putClientOwnedToken + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: tokenUID + in: path + required: true + schema: + type: string + - name: type + in: query + required: false + schema: + type: string + enum: + - AD_HOC_USER + - APP_USER + - OTHER + - RFID + default: RFID + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Token' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' + patch: + tags: + - tokens-controller + operationId: patchClientOwnedToken + parameters: + - name: authorization + in: header + required: true + schema: + type: string + - name: X-Request-ID + in: header + required: true + schema: + type: string + - name: X-Correlation-ID + in: header + required: true + schema: + type: string + - name: OCPI-from-country-code + in: header + required: true + schema: + type: string + - name: OCPI-from-party-id + in: header + required: true + schema: + type: string + - name: OCPI-to-country-code + in: header + required: true + schema: + type: string + - name: OCPI-to-party-id + in: header + required: true + schema: + type: string + - name: countryCode + in: path + required: true + schema: + type: string + - name: partyID + in: path + required: true + schema: + type: string + - name: tokenUID + in: path + required: true + schema: + type: string + - name: type + in: query + required: false + schema: + type: string + enum: + - AD_HOC_USER + - APP_USER + - OTHER + - RFID + default: RFID + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: object + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/OcpiResponseUnit' +components: + schemas: + BasicRole: + required: + - country_code + - party_id + type: object + properties: + party_id: + type: string + country_code: + type: string + x-examples: + example-1: + party_id: string + country_code: string + OcpiResponseObject: + type: object + properties: + data: + type: object + status_code: + type: integer + format: int32 + status_message: + type: string + timestamp: + type: string + required: + - status_code + - timestamp + Endpoint: + required: + - identifier + - role + - url + type: object + properties: + identifier: + type: string + role: + type: string + enum: + - SENDER + - RECEIVER + url: + type: string + OcpiResponseVersionDetail: + required: + - status_code + - timestamp + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/VersionDetail' + timestamp: + type: string + VersionDetail: + required: + - endpoints + - version + type: object + properties: + version: + type: string + endpoints: + type: array + items: + $ref: '#/components/schemas/Endpoint' + x-examples: + example-1: + version: string + endpoints: + - identifier: string + role: SENDER + url: string + OcpiResponseListVersion: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + type: array + items: + $ref: '#/components/schemas/Version' + timestamp: + type: string + required: + - status_code + - timestamp + Version: + required: + - url + - version + type: object + properties: + version: + type: string + url: + type: string + CDR: + required: + - auth_method + - cdr_location + - cdr_token + - charging_periods + - country_code + - currency + - end_date_time + - id + - last_updated + - party_id + - start_date_time + - total_cost + - total_energy + - total_time + type: object + properties: + country_code: + type: string + party_id: + type: string + id: + type: string + start_date_time: + type: string + end_date_time: + type: string + session_id: + type: string + cdr_token: + $ref: '#/components/schemas/CdrToken' + auth_method: + type: string + enum: + - AUTH_REQUEST + - COMMAND + - WHITELIST + authorization_reference: + type: string + cdr_location: + $ref: '#/components/schemas/CdrLocation' + meter_id: + type: string + currency: + type: string + tariffs: + type: array + items: + $ref: '#/components/schemas/Tariff' + charging_periods: + type: array + items: + $ref: '#/components/schemas/ChargingPeriod' + signed_data: + $ref: '#/components/schemas/SignedData' + total_cost: + $ref: '#/components/schemas/Price' + total_fixed_cost: + $ref: '#/components/schemas/Price' + total_energy: + type: number + format: float + total_energy_cost: + $ref: '#/components/schemas/Price' + total_time: + type: number + format: float + total_time_cost: + $ref: '#/components/schemas/Price' + total_parking_time: + type: number + format: float + total_parking_cost: + $ref: '#/components/schemas/Price' + total_reservation_cost: + $ref: '#/components/schemas/Price' + remark: + type: string + invoice_reference_id: + type: string + credit: + type: boolean + credit_reference_id: + type: string + last_updated: + type: string + CdrDimension: + required: + - type + - volume + type: object + properties: + type: + type: string + enum: + - CURRENT + - ENERGY + - ENERGY_EXPORT + - ENERGY_IMPORT + - MAX_CURRENT + - MIN_CURRENT + - MAX_POWER + - MIN_POWER + - PARKING_TIME + - POWER + - RESERVATION_TIME + - STATE_OF_CHARGE + - TIME + volume: + type: number + format: float + CdrLocation: + required: + - address + - city + - connector_format + - connector_id + - connector_power_type + - connector_standard + - coordinates + - country + - evse_id + - evse_uid + - id + - postal_code + type: object + properties: + id: + type: string + name: + type: string + address: + type: string + city: + type: string + postal_code: + type: string + country: + type: string + coordinates: + $ref: '#/components/schemas/GeoLocation' + evse_uid: + type: string + evse_id: + type: string + connector_id: + type: string + connector_standard: + type: string + enum: + - CHADEMO + - DOMESTIC_A + - DOMESTIC_B + - DOMESTIC_C + - DOMESTIC_D + - DOMESTIC_E + - DOMESTIC_F + - DOMESTIC_G + - DOMESTIC_H + - DOMESTIC_I + - DOMESTIC_J + - DOMESTIC_K + - DOMESTIC_L + - IEC_60309_2_single_16 + - IEC_60309_2_three_16 + - IEC_60309_2_three_32 + - IEC_60309_2_three_64 + - IEC_62196_T1 + - IEC_62196_T1_COMBO + - IEC_62196_T2 + - IEC_62196_T2_COMBO + - IEC_62196_T3A + - IEC_62196_T3C + - PANTOGRAPH_BOTTOM_UP + - PANTOGRAPH_TOP_DOWN + - TESLA_R + - TESLA_S + connector_format: + type: string + enum: + - SOCKET + - CABLE + connector_power_type: + type: string + enum: + - AC_1_PHASE + - AC_3_PHASE + - DC + CdrToken: + required: + - contract_id + - type + - uid + type: object + properties: + uid: + type: string + type: + type: string + enum: + - AD_HOC_USER + - APP_USER + - OTHER + - RFID + contract_id: + type: string + ChargingPeriod: + required: + - dimensions + - start_date_time + type: object + properties: + start_date_time: + type: string + dimensions: + type: array + items: + $ref: '#/components/schemas/CdrDimension' + tariff_id: + type: string + DisplayText: + required: + - language + - text + type: object + properties: + language: + type: string + text: + type: string + EnergyMix: + required: + - is_green_energy + type: object + properties: + is_green_energy: + type: boolean + energy_sources: + type: array + items: + $ref: '#/components/schemas/EnergySource' + environ_impact: + type: array + items: + $ref: '#/components/schemas/EnvironmentalImpact' + supplier_name: + type: string + energy_product_name: + type: string + EnergySource: + required: + - percentage + - source + type: object + properties: + source: + type: string + enum: + - NUCLEAR + - GENERAL_FOSSIL + - COAL + - GAS + - GENERAL_GREEN + - SOLAR + - WIND + - WATER + percentage: + type: number + format: float + EnvironmentalImpact: + required: + - amount + - category + type: object + properties: + category: + type: string + enum: + - NUCLEAR_WASTE + - CARBON_DIOXIDE + amount: + type: number + format: float + GeoLocation: + required: + - latitude + - longitude + type: object + properties: + latitude: + type: string + longitude: + type: string + OcpiResponseCDRList: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + type: array + items: + $ref: '#/components/schemas/CDR' + timestamp: + type: string + required: + - status_code + - timestamp + Price: + required: + - excl_vat + - incl_vat + type: object + properties: + excl_vat: + type: number + format: float + incl_vat: + type: number + format: float + PriceComponent: + required: + - price + - step_size + - type + type: object + properties: + type: + type: string + enum: + - ENERGY + - FLAT + - PARKING_TIME + - TIME + price: + type: number + format: float + vat: + type: number + format: float + step_size: + type: integer + format: int32 + SignedData: + required: + - encoding_method + - signed_values + - url + type: object + properties: + encoding_method: + type: string + encoding_method_version: + type: integer + format: int32 + public_key: + type: string + signed_values: + type: array + items: + $ref: '#/components/schemas/SignedValue' + url: + type: string + SignedValue: + required: + - nature + - plain_data + - signed_data + type: object + properties: + nature: + type: string + plain_data: + type: string + signed_data: + type: string + Tariff: + required: + - country_code + - currency + - elements + - id + - last_updated + - party_id + type: object + properties: + country_code: + type: string + party_id: + type: string + id: + type: string + currency: + type: string + type: + type: string + enum: + - AD_HOC_PAYMENT + - PROFILE_CHEAP + - PROFILE_FAST + - PROFILE_GREEN + - REGULAR + tariff_alt_text: + type: array + items: + $ref: '#/components/schemas/DisplayText' + tariff_alt_url: + type: string + min_price: + $ref: '#/components/schemas/Price' + max_price: + $ref: '#/components/schemas/Price' + elements: + type: array + items: + $ref: '#/components/schemas/TariffElement' + start_date_time: + type: string + end_date_time: + type: string + energy_mix: + $ref: '#/components/schemas/EnergyMix' + last_updated: + type: string + TariffElement: + required: + - price_components + type: object + properties: + price_components: + type: array + items: + $ref: '#/components/schemas/PriceComponent' + restrictions: + $ref: '#/components/schemas/TariffRestrictions' + TariffRestrictions: + type: object + properties: + start_time: + type: string + end_time: + type: string + start_date: + type: string + end_date: + type: string + min_kwh: + type: number + format: float + max_kwh: + type: number + format: float + min_current: + type: number + format: float + max_current: + type: number + format: float + min_power: + type: number + format: float + max_power: + type: number + format: float + min_duration: + type: integer + format: int32 + max_duration: + type: integer + format: int32 + day_of_week: + type: array + items: + type: string + enum: + - MONDAY + - TUESDAY + - WEDNESDAY + - THURSDAY + - FRIDAY + - SATURDAY + - SUNDAY + reservation: + type: string + enum: + - RESERVATION + - RESERVATION_EXPIRES + OcpiResponseCDR: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/CDR' + timestamp: + type: string + required: + - status_code + - timestamp + OcpiResponseUnit: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/Unit' + timestamp: + type: string + required: + - status_code + - timestamp + Unit: + type: object + x-examples: + example-1: {} + ActiveChargingProfile: + required: + - charging_profile + - start_date_time + type: object + properties: + start_date_time: + type: string + charging_profile: + $ref: '#/components/schemas/ChargingProfile' + ChargingProfile: + required: + - charging_rate_unit + type: object + properties: + start_date_time: + type: string + duration: + type: integer + format: int32 + charging_rate_unit: + type: string + enum: + - W + - A + min_charging_rate: + type: number + format: float + charging_profile_period: + type: array + items: + $ref: '#/components/schemas/ChargingProfilePeriod' + ChargingProfilePeriod: + required: + - limit + - start_period + type: object + properties: + start_period: + type: integer + format: int32 + limit: + type: number + format: float + GenericChargingProfileResult: + required: + - result + type: object + properties: + result: + type: string + enum: + - ACCEPTED + - REJECTED + - UNKNOWN + profile: + $ref: '#/components/schemas/ActiveChargingProfile' + ChargingProfileResponse: + required: + - result + - timeout + type: object + properties: + result: + type: string + enum: + - ACCEPTED + - NOT_SUPPORTED + - REJECTED + - TOO_OFTEN + - UNKNOWN_SESSION + timeout: + type: integer + format: int32 + OcpiResponseChargingProfileResponse: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/ChargingProfileResponse' + timestamp: + type: string + required: + - status_code + - timestamp + SetChargingProfile: + required: + - charging_profile + - response_url + type: object + properties: + charging_profile: + $ref: '#/components/schemas/ChargingProfile' + response_url: + type: string + CommandResult: + required: + - result + type: object + properties: + result: + type: string + enum: + - ACCEPTED + - CANCELED_RESERVATION + - EVSE_OCCUPIED + - EVSE_INOPERATIVE + - FAILED + - NOT_SUPPORTED + - REJECTED + - TIMEOUT + - UNKNOWN_RESERVATION + message: + $ref: '#/components/schemas/DisplayText' + CancelReservation: + required: + - reservation_id + - response_url + type: object + properties: + response_url: + type: string + reservation_id: + type: string + CommandResponse: + required: + - result + - timeout + type: object + properties: + result: + type: string + enum: + - NOT_SUPPORTED + - REJECTED + - ACCEPTED + - UNKNOWN_SESSION + timeout: + type: integer + format: int32 + message: + $ref: '#/components/schemas/DisplayText' + OcpiResponseCommandResponse: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/CommandResponse' + timestamp: + type: string + required: + - status_code + - timestamp + EnergyContract: + required: + - supplier_name + type: object + properties: + supplier_name: + type: string + contract_id: + type: string + ReserveNow: + required: + - expiry_date + - location_id + - reservation_id + - response_url + - token + type: object + properties: + response_url: + type: string + token: + $ref: '#/components/schemas/Token' + expiry_date: + type: string + reservation_id: + type: string + location_id: + type: string + evse_uid: + type: string + authorization_reference: + type: string + Token: + required: + - contract_id + - country_code + - issuer + - last_updated + - party_id + - type + - uid + - valid + - whitelist + type: object + properties: + country_code: + type: string + party_id: + type: string + uid: + type: string + type: + type: string + enum: + - AD_HOC_USER + - APP_USER + - OTHER + - RFID + contract_id: + type: string + visual_number: + type: string + issuer: + type: string + group_id: + type: string + valid: + type: boolean + whitelist: + type: string + enum: + - ALWAYS + - ALLOWED + - ALLOWED_OFFLINE + - NEVER + language: + type: string + default_profile_type: + type: string + enum: + - CHEAP + - FAST + - GREEN + - REGULAR + energy_contract: + $ref: '#/components/schemas/EnergyContract' + last_updated: + type: string + StartSession: + required: + - location_id + - response_url + - token + type: object + properties: + response_url: + type: string + token: + $ref: '#/components/schemas/Token' + location_id: + type: string + evse_uid: + type: string + authorization_reference: + type: string + StopSession: + required: + - response_url + - session_id + type: object + properties: + response_url: + type: string + session_id: + type: string + UnlockConnector: + required: + - connector_id + - evse_uid + - location_id + - response_url + type: object + properties: + response_url: + type: string + location_id: + type: string + evse_uid: + type: string + connector_id: + type: string + BusinessDetails: + required: + - name + type: object + properties: + name: + type: string + website: + type: string + logo: + $ref: '#/components/schemas/Image' + Credentials: + required: + - roles + - token + - url + type: object + properties: + token: + type: string + url: + type: string + roles: + type: array + items: + $ref: '#/components/schemas/CredentialsRole' + CredentialsRole: + required: + - business_details + - country_code + - party_id + - role + type: object + properties: + role: + type: string + enum: + - CPO + - EMSP + - HUB + - NAP + - NSP + - OTHER + - SCSP + business_details: + $ref: '#/components/schemas/BusinessDetails' + party_id: + type: string + country_code: + type: string + Image: + type: object + properties: + url: + type: string + format: uri + thumbnail: + type: string + format: uri + nullable: true + category: + type: string + enum: + - CHARGER + - ENTRANCE + - LOCATION + - NETWORK + - OPERATOR + - OTHER + - OWNER + type: + type: string + width: + type: integer + format: int32 + nullable: true + height: + type: integer + format: int32 + nullable: true + required: + - url + - category + - type + OcpiResponseCredentials: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/Credentials' + timestamp: + type: string + required: + - status_code + - timestamp + OcpiResponse: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + type: object + timestamp: + type: string + required: + - status_code + - timestamp + AdditionalGeoLocation: + required: + - latitude + - longitude + type: object + properties: + latitude: + type: string + longitude: + type: string + name: + $ref: '#/components/schemas/DisplayText' + Connector: + required: + - format + - id + - last_updated + - max_amperage + - max_voltage + - power_type + - standard + type: object + properties: + id: + type: string + standard: + type: string + enum: + - CHADEMO + - CHAOJI + - DOMESTIC_A + - DOMESTIC_B + - DOMESTIC_C + - DOMESTIC_D + - DOMESTIC_E + - DOMESTIC_F + - DOMESTIC_G + - DOMESTIC_H + - DOMESTIC_I + - DOMESTIC_J + - DOMESTIC_K + - DOMESTIC_L + - GBT_AC + - GBT_DC + - IEC_60309_2_single_16 + - IEC_60309_2_three_16 + - IEC_60309_2_three_32 + - IEC_60309_2_three_64 + - IEC_62196_T1 + - IEC_62196_T1_COMBO + - IEC_62196_T2 + - IEC_62196_T2_COMBO + - IEC_62196_T3A + - IEC_62196_T3C + - NEMA_5_20 + - NEMA_6_30 + - NEMA_6_50 + - NEMA_10_30 + - NEMA_10_50 + - NEMA_14_30 + - NEMA_14_50 + - PANTOGRAPH_BOTTOM_UP + - PANTOGRAPH_TOP_DOWN + - TESLA_R + - TESLA_S + - UNKNOWN + format: + type: string + enum: + - SOCKET + - CABLE + power_type: + type: string + enum: + - AC_1_PHASE + - AC_3_PHASE + - DC + max_voltage: + type: integer + format: int32 + max_amperage: + type: integer + format: int32 + max_electric_power: + type: integer + format: int32 + tariff_ids: + type: array + items: + type: string + terms_and_conditions: + type: string + last_updated: + type: string + Evse: + type: object + properties: + uid: + type: string + description: |- + Uniquely identifies the EVSE within the CPOs platform (and + suboperator platforms). + evse_id: + type: string + nullable: true + status: + type: string + enum: + - AVAILABLE + - BLOCKED + - CHARGING + - INOPERATIVE + - OUTOFORDER + - PLANNED + - REMOVED + - RESERVED + - UNKNOWN + status_schedule: + type: array + items: + $ref: '#/components/schemas/StatusSchedule' + capabilities: + type: array + items: + type: string + enum: + - CHARGING_PROFILE_CAPABLE + - CHARGING_PREFERENCES_CAPABLE + - CHIP_CARD_SUPPORT + - CONTACTLESS_CARD_SUPPORT + - CREDIT_CARD_PAYABLE + - DEBIT_CARD_PAYABLE + - PED_TERMINAL + - REMOTE_START_STOP_CAPABLE + - RESERVABLE + - RFID_READER + - TOKEN_GROUP_CAPABLE + - UNLOCK_CAPABLE + connectors: + type: array + items: + $ref: '#/components/schemas/Connector' + floor_level: + type: string + coordinates: + $ref: '#/components/schemas/GeoLocation' + physical_reference: + type: string + directions: + type: array + items: + $ref: '#/components/schemas/DisplayText' + parking_restrictions: + type: array + items: + type: string + enum: + - EV_ONLY + - PLUGGED + - DISABLED + - CUSTOMERS + - MOTORCYCLES + images: + type: array + items: + $ref: '#/components/schemas/Image' + last_updated: + type: string + required: + - uid + - status + - connectors + - last_updated + ExceptionalPeriod: + required: + - period_begin + - period_end + type: object + properties: + period_begin: + type: string + period_end: + type: string + Hours: + required: + - twentyfourseven + type: object + properties: + twentyfourseven: + type: boolean + regular_hours: + $ref: '#/components/schemas/RegularHours' + exceptional_openings: + $ref: '#/components/schemas/ExceptionalPeriod' + exceptional_closings: + $ref: '#/components/schemas/ExceptionalPeriod' + Location: + type: object + properties: + country_code: + type: string + party_id: + type: string + id: + type: string + publish: + type: boolean + publish_allowed_to: + type: array + items: + $ref: '#/components/schemas/PublishTokenType' + name: + type: string + nullable: true + address: + type: string + city: + type: string + postal_code: + type: string + nullable: true + state: + type: string + nullable: true + country: + type: string + coordinates: + $ref: '#/components/schemas/GeoLocation' + related_locations: + type: array + items: + $ref: '#/components/schemas/AdditionalGeoLocation' + parking_type: + type: string + enum: + - ALONG_MOTORWAY + - PARKING_GARAGE + - PARKING_LOT + - ON_DRIVEWAY + - ON_STREET + - UNDERGROUND_GARAGE + nullable: true + evses: + type: array + items: + $ref: '#/components/schemas/Evse' + directions: + type: array + items: + $ref: '#/components/schemas/DisplayText' + operator: + $ref: '#/components/schemas/BusinessDetails' + suboperator: + $ref: '#/components/schemas/BusinessDetails' + owner: + $ref: '#/components/schemas/BusinessDetails' + facilities: + type: array + items: + type: string + enum: + - HOTEL + - RESTAURANT + - CAFE + - MALL + - SUPERMARKET + - SPORT + - RECREATION_AREA + - NATURE + - MUSEUM + - BIKE_SHARING + - BUS_STOP + - TAXI_STAND + - TRAM_STOP + - METRO_STATION + - TRAIN_STATION + - AIRPORT + - PARKING_LOT + - CARPOOL_PARKING + - FUEL_STATION + - WIFI + time_zone: + type: string + opening_times: + $ref: '#/components/schemas/Hours' + charging_when_closed: + type: string + images: + type: array + items: + $ref: '#/components/schemas/Image' + energy_mix: + $ref: '#/components/schemas/EnergyMix' + last_updated: + type: string + required: + - country_code + - party_id + - id + - publish + - address + - city + - country + - coordinates + - last_updated + OcpiResponseLocationList: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + type: array + items: + $ref: '#/components/schemas/Location' + timestamp: + type: string + required: + - status_code + - timestamp + PublishTokenType: + type: object + properties: + uid: + type: string + type: + type: string + enum: + - AD_HOC_USER + - APP_USER + - OTHER + - RFID + visual_number: + type: string + issuer: + type: string + 'group_id ': + type: string + RegularHours: + required: + - period_begin + - period_end + - weekday + type: object + properties: + weekday: + type: integer + format: int32 + period_begin: + type: string + period_end: + type: string + StatusSchedule: + required: + - period_begin + - status + type: object + properties: + period_begin: + type: string + period_end: + type: string + status: + type: string + enum: + - AVAILABLE + - BLOCKED + - CHARGING + - INOPERATIVE + - OUTOFORDER + - PLANNED + - REMOVED + - RESERVED + - UNKNOWN + OcpiResponseLocation: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/Location' + timestamp: + type: string + required: + - status_code + - timestamp + OcpiResponseEvse: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/Evse' + timestamp: + type: string + required: + - status_code + - timestamp + OcpiResponseConnector: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/Connector' + timestamp: + type: string + required: + - status_code + - timestamp + OcpiResponseSessionList: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + type: array + items: + $ref: '#/components/schemas/Session' + timestamp: + type: string + required: + - status_code + - timestamp + Session: + required: + - auth_method + - cdr_token + - connector_id + - country_code + - currency + - evse_uid + - id + - kwh + - last_updated + - location_id + - party_id + - start_date_time + - status + type: object + properties: + country_code: + type: string + party_id: + type: string + id: + type: string + start_date_time: + type: string + end_date_time: + type: string + kwh: + type: number + format: float + cdr_token: + $ref: '#/components/schemas/CdrToken' + auth_method: + type: string + enum: + - AUTH_REQUEST + - COMMAND + - WHITELIST + authorization_reference: + type: string + location_id: + type: string + evse_uid: + type: string + connector_id: + type: string + meter_id: + type: string + currency: + type: string + charging_periods: + type: array + items: + $ref: '#/components/schemas/ChargingPeriod' + total_cost: + $ref: '#/components/schemas/Price' + status: + type: string + enum: + - ACTIVE + - COMPLETED + - INVALID + - PENDING + - RESERVATION + last_updated: + type: string + ChargingPreferences: + required: + - profile_type + type: object + properties: + profile_type: + type: string + enum: + - CHEAP + - FAST + - GREEN + - REGULAR + departure_time: + type: string + energy_need: + type: number + format: float + discharge_allowed: + type: boolean + OcpiResponseChargingPreferencesResponse: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + type: string + enum: + - ACCEPTED + - DEPARTURE_REQUIRED + - ENERGY_NEED_REQUIRED + - NOT_POSSIBLE + - PROFILE_TYPE_NOT_SUPPORTED + timestamp: + type: string + required: + - status_code + - timestamp + OcpiResponseSession: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/Session' + timestamp: + type: string + required: + - status_code + - timestamp + OcpiResponseTariffList: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + type: array + items: + $ref: '#/components/schemas/Tariff' + timestamp: + type: string + required: + - status_code + - timestamp + OcpiResponseTariff: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/Tariff' + timestamp: + type: string + required: + - status_code + - timestamp + OcpiResponseTokenList: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + type: array + items: + $ref: '#/components/schemas/Token' + timestamp: + type: string + required: + - status_code + - timestamp + LocationReferences: + required: + - location_id + type: object + properties: + location_id: + type: string + evse_uids: + type: array + items: + type: string + connector_ids: + type: array + items: + type: string + AuthorizationInfo: + required: + - allowed + - token + type: object + properties: + allowed: + type: string + enum: + - ALLOWED + - BLOCKED + - EXPIRED + - NO_CREDIT + - NOT_ALLOWED + token: + $ref: '#/components/schemas/Token' + location: + $ref: '#/components/schemas/LocationReferences' + authorization_reference: + type: string + info: + $ref: '#/components/schemas/DisplayText' + OcpiResponseAuthorizationInfo: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/AuthorizationInfo' + timestamp: + type: string + required: + - status_code + - timestamp + OcpiResponseToken: + type: object + properties: + status_code: + type: integer + format: int32 + status_message: + type: string + data: + $ref: '#/components/schemas/Token' + timestamp: + type: string + required: + - status_code + - timestamp + securitySchemes: + token: + type: http + scheme: bearer +security: + - token: [] \ No newline at end of file diff --git a/manager/ocpi/register.go b/manager/ocpi/register.go new file mode 100644 index 0000000..656794f --- /dev/null +++ b/manager/ocpi/register.go @@ -0,0 +1,207 @@ +package ocpi + +import ( + "bytes" + "context" + "crypto/rand" + "encoding/json" + "errors" + "fmt" + "github.com/thoughtworks/maeve-csms/manager/store" + "io" + "math/big" + "net/http" +) + +func (o *OCPI) RegisterNewParty(ctx context.Context, url, token string) error { + versions, err := o.getVersions(ctx, url, token) + if err != nil { + return err + } + + endpointUrl, err := getEndpointUrl(versions) + if err != nil { + return err + } + endpoints, err := o.getEndpoints(ctx, endpointUrl, token) + if err != nil { + return err + } + + newToken, err := generateRandomString() + if err != nil { + return err + } + + err = o.store.SetRegistrationDetails(ctx, newToken, &store.OcpiRegistration{ + Status: store.OcpiRegistrationStatusRegistered, + }) + if err != nil { + return err + } + + credentialsUrl, err := getCredentialsUrl(endpoints) + if err != nil { + return err + } + + err = o.postCredentials(ctx, credentialsUrl, token, newToken) + if err != nil { + return err + } + + return nil +} + +func (o *OCPI) getVersions(ctx context.Context, url, token string) ([]Version, error) { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + if err != nil { + return nil, err + } + req.Header.Set("Accept", "application/json") + req.Header.Set("Authorization", fmt.Sprintf("Token %s", token)) + + resp, err := o.httpClient.Do(req) + if err != nil { + return nil, err + } + defer func() { + _ = resp.Body.Close() + }() + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("status code: %d", resp.StatusCode) + } + + b, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + var versionList OcpiResponseListVersion + err = json.Unmarshal(b, &versionList) + if err != nil { + return nil, err + } + if versionList.StatusCode != StatusSuccess { + return nil, fmt.Errorf("status code: %d", versionList.StatusCode) + } + return *versionList.Data, nil +} + +func getEndpointUrl(versions []Version) (string, error) { + var endpointUrl string + + for _, version := range versions { + if version.Version == "2.2" { + endpointUrl = version.Url + break + } + } + + if endpointUrl == "" { + return "", fmt.Errorf("no version 2.2 endpoint found") + } + + return endpointUrl, nil +} + +func (o *OCPI) getEndpoints(ctx context.Context, url, token string) ([]Endpoint, error) { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + if err != nil { + return nil, err + } + req.Header.Set("Accept", "application/json") + req.Header.Set("Authorization", fmt.Sprintf("Token %s", token)) + + resp, err := o.httpClient.Do(req) + if err != nil { + return nil, err + } + defer func() { + _ = resp.Body.Close() + }() + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("status code: %d", resp.StatusCode) + } + + b, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + var versionDetail OcpiResponseVersionDetail + err = json.Unmarshal(b, &versionDetail) + if err != nil { + return nil, err + } + if versionDetail.StatusCode != StatusSuccess { + return nil, fmt.Errorf("status code: %d", versionDetail.StatusCode) + } + + return versionDetail.Data.Endpoints, nil +} + +func generateRandomString() (string, error) { + const letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-" + ret := make([]byte, 64) + for i := 0; i < 64; i++ { + num, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters)))) + if err != nil { + return "", err + } + ret[i] = letters[num.Int64()] + } + + return string(ret), nil +} + +func getCredentialsUrl(endpoints []Endpoint) (string, error) { + for _, endpoint := range endpoints { + if endpoint.Identifier == "credentials" && endpoint.Role == RECEIVER { + return endpoint.Url, nil + } + } + return "", errors.New("no credentials endpoint for receiver found") +} + +func (o *OCPI) postCredentials(ctx context.Context, url, token, newToken string) error { + creds := Credentials{ + Roles: []CredentialsRole{ + { + CountryCode: o.countryCode, + PartyId: o.partyId, + Role: "CPO", + }, + }, + Token: newToken, + Url: o.externalUrl + "/ocpi/versions", + } + + b, err := json.Marshal(creds) + if err != nil { + return err + } + + req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(b)) + if err != nil { + return err + } + req.Header.Set("Content-Type", "application/json") + req.Header.Set("Authorization", fmt.Sprintf("Token %s", token)) + + resp, err := o.httpClient.Do(req) + if err != nil { + return err + } + defer func() { + _ = resp.Body.Close() + }() + + if resp.StatusCode != http.StatusCreated { + return fmt.Errorf("status code: %d", resp.StatusCode) + } + + return nil +} diff --git a/manager/ocpi/register_test.go b/manager/ocpi/register_test.go new file mode 100644 index 0000000..be597c0 --- /dev/null +++ b/manager/ocpi/register_test.go @@ -0,0 +1,62 @@ +package ocpi_test + +import ( + "context" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/thoughtworks/maeve-csms/manager/ocpi" + "github.com/thoughtworks/maeve-csms/manager/server" + "github.com/thoughtworks/maeve-csms/manager/store" + "github.com/thoughtworks/maeve-csms/manager/store/inmemory" + "k8s.io/utils/clock" + "net/http" + "net/http/httptest" + "testing" +) + +func TestRegistration(t *testing.T) { + tokenA := "abcdef123456" + + // setup sender + senderStore := inmemory.NewStore() + senderOcpiApi := ocpi.NewOCPI(senderStore, http.DefaultClient, "GB", "TWK") + senderHandler := server.NewOcpiHandler(senderStore, clock.RealClock{}, senderOcpiApi) + senderServer := httptest.NewServer(senderHandler) + senderOcpiApi.SetExternalUrl(senderServer.URL) + defer senderServer.Close() + + // setup receiver + receiverStore := inmemory.NewStore() + err := receiverStore.SetRegistrationDetails(context.Background(), tokenA, &store.OcpiRegistration{ + Status: store.OcpiRegistrationStatusPending, + }) + require.NoError(t, err) + receiverOcpiApi := ocpi.NewOCPI(receiverStore, http.DefaultClient, "GB", "TWS") + receiverHandler := server.NewOcpiHandler(receiverStore, clock.RealClock{}, receiverOcpiApi) + receiverServer := httptest.NewServer(receiverHandler) + receiverOcpiApi.SetExternalUrl(receiverServer.URL) + defer receiverServer.Close() + + // registration + err = senderOcpiApi.RegisterNewParty(context.Background(), receiverServer.URL+"/ocpi/versions", tokenA) + require.NoError(t, err) + + // check registration status + senderPartyDetails, err := receiverStore.GetPartyDetails(context.Background(), "CPO", "GB", "TWK") + require.NoError(t, err) + + assert.Equal(t, "CPO", senderPartyDetails.Role) + assert.Equal(t, "GB", senderPartyDetails.CountryCode) + assert.Equal(t, "TWK", senderPartyDetails.PartyId) + assert.Equal(t, senderServer.URL+"/ocpi/versions", senderPartyDetails.Url) + assert.Len(t, senderPartyDetails.Token, 64) + + receiverPartyDetails, err := senderStore.GetPartyDetails(context.Background(), "CPO", "GB", "TWS") + require.NoError(t, err) + + assert.Equal(t, "CPO", receiverPartyDetails.Role) + assert.Equal(t, "GB", receiverPartyDetails.CountryCode) + assert.Equal(t, "TWS", receiverPartyDetails.PartyId) + assert.Equal(t, receiverServer.URL+"/ocpi/versions", receiverPartyDetails.Url) + assert.Len(t, receiverPartyDetails.Token, 64) +} diff --git a/manager/ocpi/render.go b/manager/ocpi/render.go new file mode 100644 index 0000000..eb59a7a --- /dev/null +++ b/manager/ocpi/render.go @@ -0,0 +1,15 @@ +package ocpi + +import "net/http" + +func (OcpiResponseListVersion) Render(http.ResponseWriter, *http.Request) error { + return nil +} + +func (OcpiResponseVersionDetail) Render(http.ResponseWriter, *http.Request) error { + return nil +} + +func (Credentials) Bind(r *http.Request) error { + return nil +} diff --git a/manager/ocpi/server.go b/manager/ocpi/server.go new file mode 100644 index 0000000..97c3d4c --- /dev/null +++ b/manager/ocpi/server.go @@ -0,0 +1,276 @@ +package ocpi + +import ( + "fmt" + "github.com/go-chi/render" + "k8s.io/utils/clock" + "net/http" + "time" +) + +type Server struct { + ocpi Api + clock clock.PassiveClock +} + +func NewServer(ocpi Api, clock clock.PassiveClock) (*Server, error) { + return &Server{ + ocpi: ocpi, + clock: clock, + }, nil +} + +func (s *Server) GetVersions(w http.ResponseWriter, r *http.Request, params GetVersionsParams) { + versions, err := s.ocpi.GetVersions(r.Context()) + if err != nil { + _ = render.Render(w, r, OcpiResponseListVersion{ + StatusCode: StatusGenericServerFailure, + Timestamp: s.clock.Now().Format(time.RFC3339), + }) + return + } + + _ = render.Render(w, r, OcpiResponseListVersion{ + Data: &versions, + StatusCode: StatusSuccess, + StatusMessage: &StatusSuccessMessage, + Timestamp: s.clock.Now().Format(time.RFC3339), + }) +} + +func (s *Server) GetVersion(w http.ResponseWriter, r *http.Request, params GetVersionParams) { + version, err := s.ocpi.GetVersion(r.Context()) + if err != nil { + if err != nil { + _ = render.Render(w, r, OcpiResponseListVersion{ + StatusCode: StatusGenericServerFailure, + Timestamp: s.clock.Now().Format(time.RFC3339), + }) + return + } + } + _ = render.Render(w, r, OcpiResponseVersionDetail{ + StatusCode: StatusSuccess, + Data: &version, + Timestamp: s.clock.Now().Format(time.RFC3339), + StatusMessage: &StatusSuccessMessage, + }) +} + +func (s *Server) PostCredentials(w http.ResponseWriter, r *http.Request, params PostCredentialsParams) { + creds := new(Credentials) + if err := render.Bind(r, creds); err != nil { + _ = render.Render(w, r, ErrInvalidRequest(err)) + return + } + + matches := authzHeaderRegexp.FindStringSubmatch(params.Authorization) + if len(matches) != 2 { + _ = render.Render(w, r, ErrInvalidRequest(fmt.Errorf("invalid authorization header"))) + return + } + + err := s.ocpi.SetCredentials(r.Context(), matches[1], *creds) + if err != nil { + _ = render.Render(w, r, ErrInternalError(err)) + return + } + + w.WriteHeader(http.StatusCreated) +} + +func (s *Server) DeleteCredentials(w http.ResponseWriter, r *http.Request, params DeleteCredentialsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetCredentials(w http.ResponseWriter, r *http.Request, params GetCredentialsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PutCredentials(w http.ResponseWriter, r *http.Request, params PutCredentialsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) DeleteReceiverChargingProfile(w http.ResponseWriter, r *http.Request, sessionId string, params DeleteReceiverChargingProfileParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetReceiverChargingProfile(w http.ResponseWriter, r *http.Request, sessionId string, params GetReceiverChargingProfileParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PutReceiverChargingProfile(w http.ResponseWriter, r *http.Request, sessionId string, params PutReceiverChargingProfileParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PostGenericChargingProfileResult(w http.ResponseWriter, r *http.Request, uid string, params PostGenericChargingProfileResultParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PutSenderChargingProfile(w http.ResponseWriter, r *http.Request, sessionId string, params PutSenderChargingProfileParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PostClientOwnedCdr(w http.ResponseWriter, r *http.Request, params PostClientOwnedCdrParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetClientOwnedCdr(w http.ResponseWriter, r *http.Request, cdrID string, params GetClientOwnedCdrParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PostCancelReservation(w http.ResponseWriter, r *http.Request, params PostCancelReservationParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PostReserveNow(w http.ResponseWriter, r *http.Request, params PostReserveNowParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PostStartSession(w http.ResponseWriter, r *http.Request, params PostStartSessionParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PostStopSession(w http.ResponseWriter, r *http.Request, params PostStopSessionParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PostUnlockConnector(w http.ResponseWriter, r *http.Request, params PostUnlockConnectorParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetClientOwnedLocation(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, params GetClientOwnedLocationParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PatchClientOwnedLocation(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, params PatchClientOwnedLocationParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PutClientOwnedLocation(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, params PutClientOwnedLocationParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetClientOwnedEvse(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, params GetClientOwnedEvseParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PatchClientOwnedEvse(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, params PatchClientOwnedEvseParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PutClientOwnedEvse(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, params PutClientOwnedEvseParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetClientOwnedConnector(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, connectorID string, params GetClientOwnedConnectorParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PatchClientOwnedConnector(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, connectorID string, params PatchClientOwnedConnectorParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PutClientOwnedConnector(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, locationID string, evseUID string, connectorID string, params PutClientOwnedConnectorParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetClientOwnedSession(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, sessionID string, params GetClientOwnedSessionParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PatchClientOwnedSession(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, sessionID string, params PatchClientOwnedSessionParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PutClientOwnedSession(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, sessionID string, params PutClientOwnedSessionParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) DeleteClientOwnedTariff(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tariffID string, params DeleteClientOwnedTariffParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetClientOwnedTariff(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tariffID string, params GetClientOwnedTariffParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PutClientOwnedTariff(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tariffID string, params PutClientOwnedTariffParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params GetClientOwnedTokenParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PatchClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params PatchClientOwnedTokenParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PutClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params PutClientOwnedTokenParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetCdrsFromDataOwner(w http.ResponseWriter, r *http.Request, params GetCdrsFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetCdrPageFromDataOwner(w http.ResponseWriter, r *http.Request, uid string, params GetCdrPageFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PostAsyncResponse(w http.ResponseWriter, r *http.Request, command PostAsyncResponseParamsCommand, uid string, params PostAsyncResponseParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetLocationListFromDataOwner(w http.ResponseWriter, r *http.Request, params GetLocationListFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetLocationPageFromDataOwner(w http.ResponseWriter, r *http.Request, uid string, params GetLocationPageFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetLocationObjectFromDataOwner(w http.ResponseWriter, r *http.Request, locationID string, params GetLocationObjectFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetEvseObjectFromDataOwner(w http.ResponseWriter, r *http.Request, locationID string, evseUID string, params GetEvseObjectFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetConnectorObjectFromDataOwner(w http.ResponseWriter, r *http.Request, locationID string, evseUID string, connectorID string, params GetConnectorObjectFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetSessionsFromDataOwner(w http.ResponseWriter, r *http.Request, params GetSessionsFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetSessionsPageFromDataOwner(w http.ResponseWriter, r *http.Request, uid string, params GetSessionsPageFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PutChargingPreferences(w http.ResponseWriter, r *http.Request, sessionID string, params PutChargingPreferencesParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetTariffsFromDataOwner(w http.ResponseWriter, r *http.Request, params GetTariffsFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetTariffsPageFromDataOwner(w http.ResponseWriter, r *http.Request, uid string, params GetTariffsPageFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetTokensFromDataOwner(w http.ResponseWriter, r *http.Request, params GetTokensFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) GetTokensPageFromDataOwner(w http.ResponseWriter, r *http.Request, uid string, params GetTokensPageFromDataOwnerParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +func (s *Server) PostRealTimeTokenAuthorization(w http.ResponseWriter, r *http.Request, tokenUID string, params PostRealTimeTokenAuthorizationParams) { + w.WriteHeader(http.StatusNotImplemented) +} diff --git a/manager/ocpi/status.go b/manager/ocpi/status.go new file mode 100644 index 0000000..6ab7026 --- /dev/null +++ b/manager/ocpi/status.go @@ -0,0 +1,43 @@ +package ocpi + +var ( + // success + StatusSuccess = int32(1000) + // client errors + StatusGenericClientError = int32(2000) + StatusInvalidParameters = int32(2001) + StatusNotEnoughInformation = int32(2002) + StatusUnknownLocation = int32(2003) + StatusUnknownToken = int32(2004) + // server errors + StatusGenericServerFailure = int32(3000) + StatusUnableToUseClientApi = int32(3001) + StatusUnsupportedVersion = int32(3002) + StatusNoMatchingEndpoints = int32(3003) + // hub errors + StatusUnknownReceiver = int32(4001) + StatusTimeout = int32(4002) + StatusConnectionError = int32(4003) +) + +var ( + // success + StatusSuccessMessage = "Success" + // client errors + StatusGenericClientErrorMessage = "Generic client error" + StatusInvalidParametersMessage = "Invalid parameters" + StatusNotEnoughInformationMessage = "Not enough information" + StatusUnknownLocationMessage = "Unknown location" + StatusUnknownTokenMessage = "Unknown token" + // server errors + StatusGenericServerFailureMessage = "Generic server failure" + StatusUnableToUseClientApiMessage = "Unable to use client API" + StatusUnsupportedVersionMessage = "Unsupported version" + StatusNoMatchingEndpointsMessage = "No matching endpoints" + // hub errors + StatusUnknownReceiverMessage = "Unknown receiver" + StatusTimeoutMessage = "Timeout" + StatusConnectionErrorMessage = "Connection error" + // other + StatusOtherMessage = "Other" +) diff --git a/manager/server/api.go b/manager/server/api.go index eac75d2..d11f432 100644 --- a/manager/server/api.go +++ b/manager/server/api.go @@ -3,18 +3,15 @@ package server import ( - "fmt" - "golang.org/x/exp/slog" - "net/http" - "os" - "text/template" - "time" - "github.com/rs/cors" "github.com/thoughtworks/maeve-csms/manager/api" + "github.com/thoughtworks/maeve-csms/manager/ocpi" "github.com/thoughtworks/maeve-csms/manager/store" "github.com/unrolled/secure" "k8s.io/utils/clock" + "net/http" + "os" + "text/template" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" @@ -22,32 +19,8 @@ import ( "github.com/thoughtworks/maeve-csms/manager/templates" ) -type logEntry struct { - method string - path string - remoteAddr string -} - -func (l logEntry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{}) { - slog.Info(fmt.Sprintf("%s %s", l.method, l.path), slog.String("remote_addr", l.remoteAddr), slog.Int("status", status), slog.Int("bytes", bytes), slog.Duration("duration", elapsed)) -} - -func (l logEntry) Panic(v interface{}, stack []byte) { - slog.Info(fmt.Sprintf("%s %s", l.method, l.path), slog.String("remote_addr", l.remoteAddr), slog.Any("panic", v), slog.String("stack", string(stack))) -} - -type logFormatter struct{} - -func (l logFormatter) NewLogEntry(r *http.Request) middleware.LogEntry { - return logEntry{ - method: r.Method, - path: r.URL.Path, - remoteAddr: r.RemoteAddr, - } -} - -func NewApiHandler(engine store.Engine) http.Handler { - apiServer, err := api.NewServer(engine, clock.RealClock{}) +func NewApiHandler(engine store.Engine, ocpi ocpi.Api) http.Handler { + apiServer, err := api.NewServer(engine, clock.RealClock{}, ocpi) if err != nil { panic(err) } @@ -72,12 +45,12 @@ func NewApiHandler(engine store.Engine) http.Handler { r.Get("/health", health) r.Get("/transactions", transactions(engine)) r.Handle("/metrics", promhttp.Handler()) - r.Get("/api/openapi.json", getSwaggerJson) + r.Get("/api/openapi.json", getApiSwaggerJson) r.With(logger).Mount("/api/v0", api.Handler(apiServer)) return r } -func getSwaggerJson(w http.ResponseWriter, r *http.Request) { +func getApiSwaggerJson(w http.ResponseWriter, r *http.Request) { swagger, err := api.GetSwagger() if err != nil { http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) diff --git a/manager/server/api_test.go b/manager/server/api_test.go index 76c05f7..07ed9c2 100644 --- a/manager/server/api_test.go +++ b/manager/server/api_test.go @@ -3,6 +3,11 @@ package server_test import ( + "encoding/json" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/thoughtworks/maeve-csms/manager/store/inmemory" + "io" "net/http" "net/http/httptest" "testing" @@ -11,7 +16,7 @@ import ( ) func TestHealthHandler(t *testing.T) { - handler := server.NewApiHandler(nil) + handler := server.NewApiHandler(inmemory.NewStore(), nil) req := httptest.NewRequest(http.MethodGet, "/health", nil) w := httptest.NewRecorder() @@ -28,3 +33,54 @@ func TestHealthHandler(t *testing.T) { t.Errorf("status code: want %d, got %d", http.StatusOK, res.StatusCode) } } + +func TestMetricsHandler(t *testing.T) { + handler := server.NewApiHandler(inmemory.NewStore(), nil) + + req := httptest.NewRequest(http.MethodGet, "/metrics", nil) + w := httptest.NewRecorder() + handler.ServeHTTP(w, req) + res := w.Result() + defer func() { + err := res.Body.Close() + if err != nil { + t.Errorf("closing body: %v", err) + } + }() + + b, err := io.ReadAll(res.Body) + require.NoError(t, err) + + if res.StatusCode != http.StatusOK { + t.Errorf("status code: want %d, got %d", http.StatusOK, res.StatusCode) + } + + assert.Contains(t, string(b), "go_goroutines", "metrics should contain go_goroutines") +} + +func TestSwaggerHandler(t *testing.T) { + handler := server.NewApiHandler(inmemory.NewStore(), nil) + + req := httptest.NewRequest(http.MethodGet, "/api/openapi.json", nil) + w := httptest.NewRecorder() + handler.ServeHTTP(w, req) + res := w.Result() + defer func() { + err := res.Body.Close() + if err != nil { + t.Errorf("closing body: %v", err) + } + }() + + b, err := io.ReadAll(res.Body) + require.NoError(t, err) + + if res.StatusCode != http.StatusOK { + t.Errorf("status code: want %d, got %d", http.StatusOK, res.StatusCode) + } + + var jsonData map[string]interface{} + err = json.Unmarshal(b, &jsonData) + require.NoError(t, err) + require.Equal(t, jsonData["info"].(map[string]any)["title"], "MaEVe CSMS") +} diff --git a/manager/server/log.go b/manager/server/log.go new file mode 100644 index 0000000..f7aba57 --- /dev/null +++ b/manager/server/log.go @@ -0,0 +1,33 @@ +package server + +import ( + "fmt" + "github.com/go-chi/chi/v5/middleware" + "golang.org/x/exp/slog" + "net/http" + "time" +) + +type logEntry struct { + method string + path string + remoteAddr string +} + +func (l logEntry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{}) { + slog.Info(fmt.Sprintf("%s %s", l.method, l.path), slog.String("remote_addr", l.remoteAddr), slog.Int("status", status), slog.Int("bytes", bytes), slog.Duration("duration", elapsed)) +} + +func (l logEntry) Panic(v interface{}, stack []byte) { + slog.Info(fmt.Sprintf("%s %s", l.method, l.path), slog.String("remote_addr", l.remoteAddr), slog.Any("panic", v), slog.String("stack", string(stack))) +} + +type logFormatter struct{} + +func (l logFormatter) NewLogEntry(r *http.Request) middleware.LogEntry { + return logEntry{ + method: r.Method, + path: r.URL.Path, + remoteAddr: r.RemoteAddr, + } +} diff --git a/manager/server/ocpi.go b/manager/server/ocpi.go new file mode 100644 index 0000000..8daad33 --- /dev/null +++ b/manager/server/ocpi.go @@ -0,0 +1,67 @@ +package server + +import ( + oapimiddleware "github.com/deepmap/oapi-codegen/pkg/chi-middleware" + "github.com/getkin/kin-openapi/openapi3filter" + "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" + "github.com/rs/cors" + "github.com/thoughtworks/maeve-csms/manager/ocpi" + "github.com/thoughtworks/maeve-csms/manager/store" + "github.com/unrolled/secure" + "k8s.io/utils/clock" + "net/http" + "os" +) + +func NewOcpiHandler(engine store.Engine, clock clock.PassiveClock, ocpiApi ocpi.Api) http.Handler { + ocpiServer, err := ocpi.NewServer(ocpiApi, clock) + if err != nil { + panic(err) + } + + var isDevelopment bool + if os.Getenv("ENVIRONMENT") == "dev" { + isDevelopment = true + } + secureMiddleware := secure.New(secure.Options{ + IsDevelopment: isDevelopment, + BrowserXssFilter: true, + ContentTypeNosniff: true, + FrameDeny: true, + ContentSecurityPolicy: "frame-ancestors: 'none'", + }) + + r := chi.NewRouter() + + logger := middleware.RequestLogger(logFormatter{}) + + swagger, err := ocpi.GetSwagger() + if err != nil { + panic(err) + } + swagger.Servers = nil + r.Use(middleware.Recoverer, secureMiddleware.Handler, cors.Default().Handler, logger) + r.Get("/openapi.json", getOcpiSwaggerJson) + r.With(oapimiddleware.OapiRequestValidatorWithOptions(swagger, &oapimiddleware.Options{ + Options: openapi3filter.Options{ + AuthenticationFunc: ocpi.NewTokenAuthenticationFunc(engine), + }, + })).Mount("/", ocpi.Handler(ocpiServer)) + + return r +} + +func getOcpiSwaggerJson(w http.ResponseWriter, r *http.Request) { + swagger, err := ocpi.GetSwagger() + if err != nil { + http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) + return + } + json, err := swagger.MarshalJSON() + if err != nil { + http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) + return + } + _, _ = w.Write(json) +} diff --git a/manager/server/ocpi_test.go b/manager/server/ocpi_test.go new file mode 100644 index 0000000..25a4ae2 --- /dev/null +++ b/manager/server/ocpi_test.go @@ -0,0 +1,105 @@ +package server + +import ( + "context" + "encoding/json" + "fmt" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/thoughtworks/maeve-csms/manager/ocpi" + "github.com/thoughtworks/maeve-csms/manager/store" + "github.com/thoughtworks/maeve-csms/manager/store/inmemory" + "io" + "k8s.io/utils/clock" + clockTest "k8s.io/utils/clock/testing" + "net/http" + "net/http/httptest" + "testing" + "time" +) + +func TestSwaggerHandler(t *testing.T) { + engine := inmemory.NewStore() + ocpiApi := ocpi.NewOCPI(engine, http.DefaultClient, "GB", "TWK") + handler := NewOcpiHandler(engine, clock.RealClock{}, ocpiApi) + + req := httptest.NewRequest(http.MethodGet, "/openapi.json", nil) + w := httptest.NewRecorder() + handler.ServeHTTP(w, req) + res := w.Result() + defer func() { + err := res.Body.Close() + if err != nil { + t.Errorf("closing body: %v", err) + } + }() + + b, err := io.ReadAll(res.Body) + require.NoError(t, err) + + if res.StatusCode != http.StatusOK { + t.Errorf("status code: want %d, got %d", http.StatusOK, res.StatusCode) + } + + var jsonData map[string]interface{} + err = json.Unmarshal(b, &jsonData) + require.NoError(t, err) + require.Equal(t, jsonData["info"].(map[string]any)["title"], "Open Charge Point Interface (OCPI) 2.2") + +} + +func TestAPIRequestWithValidToken(t *testing.T) { + token := "abcdef123456" + engine := inmemory.NewStore() + err := engine.SetRegistrationDetails(context.Background(), token, &store.OcpiRegistration{Status: store.OcpiRegistrationStatusPending}) + require.NoError(t, err) + now, err := time.Parse(time.RFC3339, "2023-06-15T15:05:00Z") + require.NoError(t, err) + clock := clockTest.NewFakePassiveClock(now) + ocpiApi := ocpi.NewOCPI(engine, http.DefaultClient, "GB", "TWK") + handler := NewOcpiHandler(engine, clock, ocpiApi) + + req := httptest.NewRequest(http.MethodGet, "/ocpi/versions", nil) + req.Header.Add("Authorization", fmt.Sprintf("Token %s", token)) + w := httptest.NewRecorder() + handler.ServeHTTP(w, req) + res := w.Result() + defer func() { + err := res.Body.Close() + if err != nil { + t.Errorf("closing body: %v", err) + } + }() + + b, err := io.ReadAll(res.Body) + require.NoError(t, err) + + if res.StatusCode != http.StatusOK { + t.Errorf("status code: want %d, got %d", http.StatusOK, res.StatusCode) + } + + assert.JSONEq(t, `{"status_code":1000,"status_message":"Success","timestamp":"2023-06-15T15:05:00Z","data":[{"url":"/ocpi/2.2","version":"2.2"}]}`, string(b)) +} + +func TestAPIRequestWithInvalidToken(t *testing.T) { + token := "abcdef123456" + engine := inmemory.NewStore() + ocpiApi := ocpi.NewOCPI(engine, http.DefaultClient, "GB", "TWK") + handler := NewOcpiHandler(engine, clock.RealClock{}, ocpiApi) + + req := httptest.NewRequest(http.MethodGet, "/ocpi/versions", nil) + req.Header.Add("Authorization", fmt.Sprintf("Token %s", token)) + w := httptest.NewRecorder() + handler.ServeHTTP(w, req) + res := w.Result() + defer func() { + err := res.Body.Close() + if err != nil { + t.Errorf("closing body: %v", err) + } + }() + + if res.StatusCode != http.StatusUnauthorized { + t.Errorf("status code: want %d, got %d", http.StatusOK, res.StatusCode) + } +} diff --git a/manager/store/engine.go b/manager/store/engine.go index 259fd03..93ee658 100644 --- a/manager/store/engine.go +++ b/manager/store/engine.go @@ -7,4 +7,5 @@ type Engine interface { TokenStore TransactionStore CertificateStore + OcpiStore } diff --git a/manager/store/firestore/cs.go b/manager/store/firestore/cs.go index 81f33fa..9ff80f0 100644 --- a/manager/store/firestore/cs.go +++ b/manager/store/firestore/cs.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package firestore import ( diff --git a/manager/store/firestore/ocpi.go b/manager/store/firestore/ocpi.go new file mode 100644 index 0000000..feb2a8c --- /dev/null +++ b/manager/store/firestore/ocpi.go @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: Apache-2.0 + +package firestore + +import ( + "context" + "fmt" + "github.com/thoughtworks/maeve-csms/manager/store" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (s *Store) SetRegistrationDetails(ctx context.Context, token string, registration *store.OcpiRegistration) error { + regRef := s.client.Doc(fmt.Sprintf("OcpiRegistration/%s", token)) + _, err := regRef.Set(ctx, registration) + if err != nil { + return fmt.Errorf("setting registration: %s: %w", token, err) + } + return nil +} + +func (s *Store) GetRegistrationDetails(ctx context.Context, token string) (*store.OcpiRegistration, error) { + regRef := s.client.Doc(fmt.Sprintf("OcpiRegistration/%s", token)) + snap, err := regRef.Get(ctx) + if err != nil { + if status.Code(err) == codes.NotFound { + return nil, nil + } + return nil, fmt.Errorf("lookup registration %s: %w", token, err) + } + var registration store.OcpiRegistration + err = snap.DataTo(®istration) + if err != nil { + return nil, fmt.Errorf("map registration %s: %w", token, err) + } + return ®istration, nil +} + +func (s *Store) DeleteRegistrationDetails(ctx context.Context, token string) error { + regRef := s.client.Doc(fmt.Sprintf("OcpiRegistration/%s", token)) + _, err := regRef.Delete(ctx) + if err != nil { + return fmt.Errorf("delete registration %s: %w", token, err) + } + return nil +} + +func (s *Store) SetPartyDetails(ctx context.Context, partyDetails *store.OcpiParty) error { + partyRef := s.client.Doc(fmt.Sprintf("OcpiParty/%s/Id/%s:%s", partyDetails.Role, partyDetails.CountryCode, partyDetails.PartyId)) + _, err := partyRef.Set(ctx, partyDetails) + if err != nil { + return fmt.Errorf("setting party %s/%s:%s: %w", partyDetails.Role, partyDetails.CountryCode, partyDetails.PartyId, err) + } + return nil +} + +func (s *Store) GetPartyDetails(ctx context.Context, role, countryCode, partyId string) (*store.OcpiParty, error) { + partyRef := s.client.Doc(fmt.Sprintf("OcpiParty/%s/Id/%s:%s", role, countryCode, partyId)) + snap, err := partyRef.Get(ctx) + if err != nil { + if status.Code(err) == codes.NotFound { + return nil, nil + } + return nil, fmt.Errorf("lookup party details %s/%s:%s: %w", role, countryCode, partyId, err) + } + var registration store.OcpiParty + err = snap.DataTo(®istration) + if err != nil { + return nil, fmt.Errorf("map party details %s/%s:%s: %w", role, countryCode, partyId, err) + } + return ®istration, nil +} diff --git a/manager/store/firestore/ocpi_test.go b/manager/store/firestore/ocpi_test.go new file mode 100644 index 0000000..fe42a14 --- /dev/null +++ b/manager/store/firestore/ocpi_test.go @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: Apache-2.0 + +//go:build integration + +package firestore_test + +import ( + "context" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/thoughtworks/maeve-csms/manager/store" + "github.com/thoughtworks/maeve-csms/manager/store/firestore" + "testing" +) + +func TestSetAndLookupRegistrationDetails(t *testing.T) { + ctx := context.Background() + + engine, err := firestore.NewStore(ctx, "myproject") + require.NoError(t, err) + + token := "abcdef123456" + want := &store.OcpiRegistration{ + Status: store.OcpiRegistrationStatusRegistered, + } + + err = engine.SetRegistrationDetails(ctx, token, want) + require.NoError(t, err) + + got, err := engine.GetRegistrationDetails(ctx, token) + require.NoError(t, err) + + assert.Equal(t, want, got) +} + +func TestDeleteRegistrationDetails(t *testing.T) { + ctx := context.Background() + + engine, err := firestore.NewStore(ctx, "myproject") + require.NoError(t, err) + + token := "abcdef123456" + stored := &store.OcpiRegistration{ + Status: store.OcpiRegistrationStatusRegistered, + } + + err = engine.SetRegistrationDetails(ctx, token, stored) + require.NoError(t, err) + + err = engine.DeleteRegistrationDetails(ctx, token) + require.NoError(t, err) + + got, err := engine.GetRegistrationDetails(ctx, token) + require.NoError(t, err) + assert.Nil(t, got) +} + +func TestSetAndLookupPartyDetails(t *testing.T) { + ctx := context.Background() + + engine, err := firestore.NewStore(ctx, "myproject") + require.NoError(t, err) + + want := &store.OcpiParty{ + Role: "CPO", + CountryCode: "GB", + PartyId: "TWK", + Url: "https://example.com/ocpi/versions", + Token: "abcdef123456", + } + + err = engine.SetPartyDetails(ctx, want) + require.NoError(t, err) + + got, err := engine.GetPartyDetails(ctx, want.Role, want.CountryCode, want.PartyId) + require.NoError(t, err) + + assert.Equal(t, want, got) +} diff --git a/manager/store/firestore/store.go b/manager/store/firestore/store.go index 4e32d62..56d4a57 100644 --- a/manager/store/firestore/store.go +++ b/manager/store/firestore/store.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package firestore import ( diff --git a/manager/store/firestore/token.go b/manager/store/firestore/token.go index 77fa30e..0e94445 100644 --- a/manager/store/firestore/token.go +++ b/manager/store/firestore/token.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package firestore import ( diff --git a/manager/store/inmemory/store.go b/manager/store/inmemory/store.go index 7a4806c..f0c4f23 100644 --- a/manager/store/inmemory/store.go +++ b/manager/store/inmemory/store.go @@ -24,6 +24,8 @@ type Store struct { tokens map[string]*store.Token transactions map[string]*store.Transaction certificates map[string]string + registrations map[string]*store.OcpiRegistration + partyDetails map[string]*store.OcpiParty } func NewStore() *Store { @@ -32,6 +34,8 @@ func NewStore() *Store { tokens: make(map[string]*store.Token), transactions: make(map[string]*store.Transaction), certificates: make(map[string]string), + registrations: make(map[string]*store.OcpiRegistration), + partyDetails: make(map[string]*store.OcpiParty), } } @@ -231,3 +235,47 @@ func (s *Store) DeleteCertificate(_ context.Context, certificateHash string) err return nil } + +func (s *Store) SetRegistrationDetails(_ context.Context, token string, registration *store.OcpiRegistration) error { + s.Lock() + defer s.Unlock() + + s.registrations[token] = registration + + return nil +} + +func (s *Store) GetRegistrationDetails(_ context.Context, token string) (*store.OcpiRegistration, error) { + s.Lock() + defer s.Unlock() + return s.registrations[token], nil +} + +func (s *Store) DeleteRegistrationDetails(_ context.Context, token string) error { + s.Lock() + defer s.Unlock() + + delete(s.registrations, token) + + return nil +} + +func (s *Store) SetPartyDetails(_ context.Context, partyDetails *store.OcpiParty) error { + s.Lock() + defer s.Unlock() + + recordId := fmt.Sprintf("%s:%s:%s", partyDetails.Role, partyDetails.CountryCode, partyDetails.PartyId) + + s.partyDetails[recordId] = partyDetails + + return nil +} + +func (s *Store) GetPartyDetails(_ context.Context, role, countryCode, partyId string) (*store.OcpiParty, error) { + s.Lock() + defer s.Unlock() + + recordId := fmt.Sprintf("%s:%s:%s", role, countryCode, partyId) + + return s.partyDetails[recordId], nil +} diff --git a/manager/store/ocpi.go b/manager/store/ocpi.go new file mode 100644 index 0000000..a568bad --- /dev/null +++ b/manager/store/ocpi.go @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: Apache-2.0 + +package store + +import ( + "context" +) + +type OcpiRegistrationStatusType string + +var ( + OcpiRegistrationStatusRegistered OcpiRegistrationStatusType = "registered" + OcpiRegistrationStatusPending OcpiRegistrationStatusType = "pending" +) + +type OcpiRegistration struct { + Status OcpiRegistrationStatusType +} + +type OcpiParty struct { + CountryCode string + PartyId string + Role string + Url string + Token string +} + +type OcpiStore interface { + SetRegistrationDetails(ctx context.Context, token string, registration *OcpiRegistration) error + GetRegistrationDetails(ctx context.Context, token string) (*OcpiRegistration, error) + DeleteRegistrationDetails(ctx context.Context, token string) error + + SetPartyDetails(ctx context.Context, partyDetails *OcpiParty) error + GetPartyDetails(ctx context.Context, role, countryCode, partyId string) (*OcpiParty, error) +} From 85077513b60d87f20a08d03440ac5554322688ea Mon Sep 17 00:00:00 2001 From: Dale Peakall Date: Fri, 11 Aug 2023 17:25:01 +0100 Subject: [PATCH 02/15] feat: ocpi token receiver module All very rough and ready - but should give an idea of how to go about implementing an OCPI module --- .talismanrc | 2 +- manager/api/api-spec.yaml | 10 +++ manager/api/api.gen.go | 94 ++++++++++++-------- manager/api/server.go | 7 +- manager/ocpi/auth.go | 2 + manager/ocpi/auth_test.go | 2 + manager/ocpi/ocpi.go | 72 +++++++++++++--- manager/ocpi/ocpi_test.go | 122 ++++++++++++++++++++++++++ manager/ocpi/register.go | 10 +++ manager/ocpi/register_test.go | 22 +++++ manager/ocpi/render.go | 10 +++ manager/ocpi/server.go | 121 +++++++++++++++++++++++--- manager/ocpi/server_test.go | 158 ++++++++++++++++++++++++++++++++++ manager/ocpi/status.go | 2 + 14 files changed, 571 insertions(+), 63 deletions(-) create mode 100644 manager/ocpi/ocpi_test.go create mode 100644 manager/ocpi/server_test.go diff --git a/.talismanrc b/.talismanrc index d091999..d307b42 100644 --- a/.talismanrc +++ b/.talismanrc @@ -26,7 +26,7 @@ fileignoreconfig: - filename: manager/api/API.md checksum: c111751da44c7310d6b77b76e1a5826c44cce62e47a32eaec564e86064bb1de2 - filename: manager/api/api.gen.go - checksum: 5b1dc3f6049e2267fef0f73cabb9dd1f3df82da4dcb4ad55eaa76c9b89f58cde + checksum: fb9c6cf09f7864a32c38e40fb8a8598d3c6bd5c406245c6b31666c2ccb1f9e24 - filename: manager/api/server.go checksum: 98cbd1df522ea428f7e669c01721f3070133062378a4f2e4b167d55eaa8d079b - filename: manager/api/server_test.go diff --git a/manager/api/api-spec.yaml b/manager/api/api-spec.yaml index b8d2922..ab40d91 100644 --- a/manager/api/api-spec.yaml +++ b/manager/api/api-spec.yaml @@ -389,6 +389,16 @@ components: type: "string" format: "uri" description: "The URL of the eMSP versions endpoint. If provided the CSMS will act as the sender of the versions request." + status: + type: "string" + enum: + - "PENDING" + - "REGISTERED" + description: | + 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. required: - token diff --git a/manager/api/api.gen.go b/manager/api/api.gen.go index 9d50f78..7fac6dc 100644 --- a/manager/api/api.gen.go +++ b/manager/api/api.gen.go @@ -19,6 +19,12 @@ import ( "github.com/go-chi/chi/v5" ) +// Defines values for RegistrationStatus. +const ( + PENDING RegistrationStatus = "PENDING" + REGISTERED RegistrationStatus = "REGISTERED" +) + // Defines values for TokenCacheMode. const ( ALLOWED TokenCacheMode = "ALLOWED" @@ -52,6 +58,11 @@ type ChargeStationAuth struct { // 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. 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"` @@ -59,6 +70,11 @@ type Registration struct { 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. 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 @@ -529,44 +545,46 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xaX3PbuBH/KjtoH+yObMl2zjPRy1W1lbGm/qOx7Ltp40wCkSsRFxJgANCKzqPv3lmA", - "FEURinO9us2k92SRWALY3d/+sLvwE4tUliuJ0hrWf2ImSjDj7ucZaitmIuIW6TFGE2mRW6Ek67MBRKlA", - "aSHakOqwXKucXqCbIfrSDHcJwnh4BSgjFWO8OREshE1A4iIVEg1ozFMeYQzTJXx4eJAfWIfZZY6sz4zV", - "Qs7ZatVhGj8VQmPM+m8bC79bC6vpLxhZtuqws4TrOU4sp70MCpu0t3empMSIHiBGy0VqYKY0cIjct2D8", - "xy2dp9zg6avJxeD4h9MxN2ahdBxW3ktW+ndgcjE4OP7hFBJuElAzsAluLQZ5NWGHZfzzJco5bf30Vcse", - "HWYwKrSwy7FWM5HusH8lBLmXAqugMOg0bS/fh7/Ah94HOIBCui8xBqu5NLnS1vtsyo2IgBc2Idkjkr27", - "nITGjhtjbTA9yNrLQlqco265eVvHkKtvcS6M1d5ZLSOc48xBjJQVUljBU4jCnieRm7PxCPTGjGS4CI1p", - "wcCqjyjDRndDm5aOVJYVkrQWcu7tQYvh1WQMe2e3w/Ph9d1ocDl5f3fz9+H1+8H+4Vf4v9BpePn728sK", - "XW6FR9RGKGkAZZwrIe0hjGak16OgsCS5s8kV+SlNgUcWuDeXQRmjrqZaz0L+QWNpizOlM25ZnxVaPBuy", - "3mAhD1KYFqatzMXd3dhBs2ibH7VWOqy/G6o8y0KRs2M9FzBuDDYHnlOsnC6k2V0YJAPpokRp8asHmbdN", - "i115lOCVigOxPZKxCyIDi4RboIWdoxzy6DsCmjDA01QtkOgEZZHRbgeXPw/+MWEdNri8vPl5eF7/en/z", - "5s3l6HrIOux6+NPwdkOj2naRklbzyI52cF41DqNz2MOrweh8H7gxKhLcYlxj3+90zz0rN4ELzPKkAoM5", - "19wqbfbJLNxa1LTE3tvBwT/5wa/vno5X+3sHP+7XL06aL3oHr989vW6/2/+RBdUqpNXLs6CxvV5OAIjK", - "q5AQxhRkZ4qyZsAed1gm5MZTa8G5VkUeNqIwIGJwAoaOI1Xkae1dQ8SS8Y8IdqFAaciUxmpoofRHCl8l", - "sbmhk9PAHmj/GAiiUakXuYPLZQcyZWyltBVZSaeSZ2tTlKKQa6LyGAjTCcLtm9E5RFzHHZDKgkSiUq5F", - "ulzTU8gbKZfzgs9xtztyjTPUdD5VshXfVtkGNzCa3MDpyeuDo1qIxn6rq1Ju7H0eE37Dm6Ehp4/GSOkY", - "FtwAfQSF/wr2xFwq7c0SaeQWu35of5NE6cUBmTdkkpxru9wVdG6QQPMsME8a2p4EFvIvgsfaJslsMsr5", - "+4ubs/f3k+Etkcl4XP28ubtwfwkFQTIpxA6FCik+FRVJiPgrsPzI09BkI4KqMOVMXmj99VSpFLl0nwtT", - "8PS6yKa441TxEl2NPObTFEE62a6IUZYZjc8W1vjnsob/8/nsBv/Uzi6/8oZqcO86eCvNOxunRfskouWE", - "nCl3qihpeWTdIZpxkbI+yzg+4oFFnv3VJqqYJ5aIxBxGKmMdRnHO+uyKD39CICEy2PZxRPzMUxiMRxSI", - "ZAR3Cqz53n9NeUYH8HMp7ZNCAyZRRRq78KUEjFKLVEQojUNiuf4gJwXh+LDnYCpsWu+K5iVT+ByF9Vnv", - "sOflVI6S54L12Yl75Q6TxB2v3a3qJVfGtn1/n6eKx46IWyksqVqlT4dwVyVSEZdOF0eMTWk69gkwPgEO", - "FACFocDNClvw1GfPCXoupQfKDpycAa4RpkjCajajLVIqp4AD/T6Y8pTLCPWhy7LXnxGBlBqdNcq6Mqn7", - "m4qXFUZQOmvwPE9LdHd/MT7F9jUk/fqzxhnrsz916yKzW1aY3c0VVk3AW12ge2FyJY3Pdo57R4EizbFl", - "7BE340Vq/2PbK7NOt7Mtl0v8nGNEcezTTBIxRZZxvVzbjwDRULDTAFT3aePhgptk5ZVLMVQqn7v3u0BG", - "GV7CDUwRJRR57ex16u5Rw7cqzkbB+SDLw+F8eAvTpUUTwobfSBMblIllaFEb1n/7xARtmIKopoYtVdm2", - "qzsbLvlyWbN610LFq7a5rhVUEFh12Csv8sKguFYWZqqQ3xYWvb+2sdhhcwxQ2aVSH4v8fw8yv49vCmS9", - "l2O9LULbsHlVov6fY7iGZYtPTfcpMqN4tft49t0f1MSdEhdbx6k/lM3SWMzK/oYxRVbCvX38PkgKASpV", - "lmh9KLg+CWUVVFPI2M/i2pWh/p2Q7gzOUcYULPQaH6RRIKxLC9yUkZIzMXfdNXe6C+t6LaTCVFGZpOqM", - "MhQ/lc6NJmc7hgJF7NZmy9zVpZGhiDMu0/xtYfUCeUSrl/s9ZROVM4P43QqDLi872UF6v0VbaOlr86qv", - "WRkJpsuayOfc4oIvidxjgksmJEKiFl+ToO6m85aXvhFAvhTPh1G5Bbimfq41Xu3ov0f79/KjVAvZwtY3", - "FQU1djcguNGi96Ggy2j5qgNB+na+746sK1FfrJ1jxdFlq6oi5XXXP9Adf5AobIK6vElwiVfjsmC9iF+z", - "vFSoNpCmsODCri8b/HtXLpfTPchdE7pdf+EsGNNcL1TINW5Yvkfu/SJWPPDW1z3hzFoY65rt6x4t5Rf+", - "wIfClKV52fLH9R1jiEyFse7WwOxIij8VqJc1JarZzKBtkqKQIisy1u+F7tfC06QiE3abWv0sR71ep57z", - "KDDn76VZYTEzzznZX6WsG5SMa82XIZ+TBetu+beV6dLWAjc/bpdhOvNhY4hKfMuYssTygvHfxdgEPcRe", - "iC5KT31HPHG22bMnrgjd3tU00X1yf+6FL1y+XIv/Tl/6eSp3Pl9FVzv72vI50Gx/0bRqAzxbd6Ztk/9R", - "QDcL6F24dP8soh93p+GpingKMT5iqvLM37+SPCv/y4Al1ub9btfJJcrY/utXR70uz0X3scdW71b/CgAA", - "//+e5cY/ZSQAAA==", + "H4sIAAAAAAAC/+xab3PbuNH/Kjt4nhd2h7ZkO+eZ6M1VtZSzpv43ln03bZyJIXIl4UwCDABa0Xn83TsL", + "kCIlQnGuV7eZtK8sEksAu/vb3+4CfmKxynIlUVrDek/MxHPMuPt5gtqKqYi5RXpM0MRa5FYoyXqsD3Eq", + "UFqIG1IRy7XK6QW6GeIvzXAzR7gangPKWCWYNCeChbBzkLhIhUQDGvOUx5jAZAn3d3fynkXMLnNkPWas", + "FnLGnp8jpvFTITQmrPd+beEPK2E1+RVjy54jdjLneoZjy2kv/cLO29s7UVJiTA+QoOUiNTBVGjjE7lsw", + "/uOWzhNu8PjN+LR/+MPxFTdmoXQSVt5LVvpHMD7t7x3+cAxzbuagpmDnuLEY5NWEEcv45zOUM9r68ZuW", + "PSJmMC60sMsrraYi3WL/SghyLwVWQWHQadpevgd/gvvuPexBId2XmIDVXJpcaet9NuFGxMALOyfZA5K9", + "ORuHxg7XxtpgupO1l4W0OEPdcvOmjiFXX+NMGKu9s1pGGODUQYyUFVJYwVOIw54nkcuTqxHoxoxkuBiN", + "acGATFaYLVZ3Y5WL16Yj7dDYfRhVg+4ZhIGM6wdMgBu4vx7+NBrfDK+Hg3uSkk7UqgeUsBBpChMEnqZq", + "Qf5Rd3KC5FT6DTym3dIooExyJaQ1Lyx2NbwYjC5+Cq+kZLpcX65c4k6S5H1HxbnoPKI2QklzH1VvDvcP", + "74HLpPHciTUmKMkF5r6xOwcElEVGHi83wyJW26Dh9hr+bo9h8/vtN5AeqywrJKFOyJnHI20ez8dXsHNy", + "PRwML25G/bPxx5vLvw4vPvZ3978i/gqdhpe/vT6rXO9WqIyzUtn5I9fqURAtktzJ+Hzs7c1jS06xLnZl", + "grqaajVLhSAWsanSGbesxwotXqRMb7BQBI23QPn05uaqxHIL/qi10mH93VAVWSzEXC+HTnPgJcXK6UKa", + "3YRB0peOpZQWv/mo9LZpZTcez/FcJQFuHcnEkZiBxZxboIWdoxzy6DsCmjBV2DQA3j/7pf+3MYtY/+zs", + "8pfhoP718fLdu7PRxZBF7GL48/A6CPtYSat5bEdbck41DqMB7OB5fzTYBW6MigW3mNTY9zvdcc/KTeCI", + "sawUwGDONbdKm10yC7cWNS2x876/93e+99uHp8Pn3Z29H3frF0frL7p7bz88vW2/2/2RBdUqpNXLk6Cx", + "vV5OACiVViEhjCnIzhRl6wF7GLFMyMZTa8GZVkUeNqIwIBJwAobKAVXkae1dQ8SS8QcEu1CgNGRKYzW0", + "UPqBwldJXN/Q0XFgD7R/DATRqNSL3MHlMoJMGVspbUVWpjPJs5UpSlHINaXSBJQn8ut3owHEXCcRSGVB", + "IjE31yJdrugp5I2Uy1nBZ7jdHbnGKWqqDyrZim+rao8bGI0v4fjo7d5BLURjv9dVKTf2Nk8Iv+HN0FCZ", + "32KlE1hwA/QRFP4r2BEzqbQ3S6yRW+z4od0midKLPTJvyCQ513a5LejcIIHmRWAerWl7FMpr7kUwrTVJ", + "pskog4+nlycfb8fDayKTq6vq5+XNqftLKAiSSSG2KFRI8amoSEIkX4HlR56GJhsRVIUpZ/JCq68nSqXI", + "pftcmIKnF0U2wS1ZxUt0NPKET1IE6WQ7wlUUrqL01doK/1zW8H+5n2jwT+3s8itvqDXuXQVvpXnUyBbt", + "TETLCTlVLqsoaXlsXRLNuEhZj2UcH3HPIs/+bOeqmM0tEYnZj1XGIkZxznrsnA9/RiAhMthmOiJ+5in0", + "r0YUiGQElwVWfO+/pjojAvxcSvui3ICZqyJNXPhSAUylRSpilMYhsVy/n5OCcLjfdTAVNq13RfOSKXyN", + "wnqsu9/1cipHyXPBeuzIvXLJZO7Sa2eje8yVsW3f3+ap4okj4lYLQapW5dM+3FSFVMyl08UR47o0pX0C", + "jG9AAg1YYShws8IWPPXdS1UU0wNVB07OANcIEyRhNZ3SFsviGOj33oSnXMaofXG7+owIpNToZK2tLou6", + "v6hkWWEEpbMGz/O0RHfnV+NbHN/D06//1zhlPfZ/nbrJ75Qdfqe5wvM64K0u0L0wuZLGVzuH3YNAk+zY", + "MvGIm/Iitf+y7ZVVp9vZhsslfs4xpjj2ZSaJmCLLuF6u7EeAWFMwWgNU56nxcMrN/Nkrl2LoqGLg3m8D", + "GVV4c25ggiihyGtnr0p3jxq+0fGvNfx3skwOg+E1TJYWTQgbfiPr2KBKLEOL2rDe+ycmaMMURDU1bKjK", + "Nl0dNVzy5bbm+UMLFW/a5rpQUEHgOWJvvMgrg+JCWZiqQn5bWPT+2sRixGYYoLIzpR6K/D8PMr+Pbwpk", + "3ddjvQ1Ca9i8alH/yzFcw7LFp6bzFJtR8rw9PfvTN9TEnRIXG+nUJ2WzNBaz8nzDmCIr4d5Ov3eSQoBa", + "lSVaHwrunISqCuopZOJnccfFofNTIV0OzlEmFCz0Gu+kUSCsKwvclLGSUzFzp5suuwvrzlpIhYmiNknV", + "FWUofiqd1w6Z2zEUaGI3NlvWrq6MDEWccZXm7wurV6gjWmfp31M1UTkziN+NMOjw8iYhSO/XaAstfW9e", + "nStXRoLJsibyGbe44Esi94TgkgmJMFeLrylQt9N5y0vfCCBfi+fDqNwA3Lp+7mqi2tG/j/Zv5YNUC9nC", + "1jcVBTV2GxBsXJH4UNBltHxVQpD+OsWfjqw6Ud+sDbDi6PKoqiLl1a1L4HT8TqKwc9TlTY4rvNZuV1aL", + "+DXLS51qA2kKCy7s6rLHv3ftcjndndw2odv1F3LBFc31So3c2g3X98i9X8SKB97quidcWQtj/aVXdUZL", + "9YVP+PXVWHnkj6s73hCZCmPdrYHZUhR/KlAva0pU06lBu06KQoqsyFivG7rfDE+TikzYTWr1sxx0u1E9", + "50Fgzj9Ks8JiZl5ysr9KWR1QMq41X4Z8ThasT8u/rUqXtha4+XG7DNOZDxtDVOKPjKlKLC8Y/1mMjdFD", + "7JXoovTUd8QTJ80ze+KK0O1dTROdJ/fnVvjG5cu9+B/0pZ+ncufLXXS1s69tnwOH7a9aVjXAs3Fn2jb5", + "/xro9QZ6Gy7dP+vox+1leKpinkKCj5iqPPP3ryTPyv8yYHNr816n4+Tmytje2zcH3Q7PReexy54/PP8j", + "AAD//4F6Pa3lJQAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/manager/api/server.go b/manager/api/server.go index 64d1566..2a4f976 100644 --- a/manager/api/server.go +++ b/manager/api/server.go @@ -249,8 +249,13 @@ func (s *Server) RegisterParty(w http.ResponseWriter, r *http.Request) { } } else { // store credentials in database + status := store.OcpiRegistrationStatusPending + if req.Status != nil && *req.Status == "REGISTERED" { + status = store.OcpiRegistrationStatusRegistered + } + err := s.store.SetRegistrationDetails(r.Context(), req.Token, &store.OcpiRegistration{ - Status: store.OcpiRegistrationStatusPending, + Status: status, }) if err != nil { _ = render.Render(w, r, ErrInternalError(err)) diff --git a/manager/ocpi/auth.go b/manager/ocpi/auth.go index 0045687..28e6820 100644 --- a/manager/ocpi/auth.go +++ b/manager/ocpi/auth.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package ocpi import ( diff --git a/manager/ocpi/auth_test.go b/manager/ocpi/auth_test.go index bc3f76f..d825a07 100644 --- a/manager/ocpi/auth_test.go +++ b/manager/ocpi/auth_test.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package ocpi_test import ( diff --git a/manager/ocpi/ocpi.go b/manager/ocpi/ocpi.go index 3f599db..b8dce41 100644 --- a/manager/ocpi/ocpi.go +++ b/manager/ocpi/ocpi.go @@ -17,6 +17,8 @@ type Api interface { GetVersions(ctx context.Context) ([]Version, error) GetVersion(ctx context.Context) (VersionDetail, error) SetCredentials(ctx context.Context, token string, credentials Credentials) error + SetToken(ctx context.Context, token Token) error + GetToken(ctx context.Context, countryCode string, partyID string, tokenUID string) (*Token, error) } type OCPI struct { @@ -57,6 +59,11 @@ func (o *OCPI) GetVersion(context.Context) (VersionDetail, error) { Role: RECEIVER, Url: fmt.Sprintf("%s/ocpi/2.2/credentials", o.externalUrl), }, + { + Identifier: "tokens", + Role: RECEIVER, + Url: fmt.Sprintf("%s/ocpi/receiver/2.2/tokens/", o.externalUrl), + }, }, Version: "2.2", }, nil @@ -82,24 +89,67 @@ func (o *OCPI) SetCredentials(ctx context.Context, token string, credentials Cre } if reg != nil && reg.Status == store.OcpiRegistrationStatusPending { - // delete old token - err := o.store.DeleteRegistrationDetails(ctx, token) - if err != nil { - return err - } - // store new token - err = o.store.SetRegistrationDetails(ctx, credentials.Token, &store.OcpiRegistration{ - Status: store.OcpiRegistrationStatusRegistered, - }) + // register new party + err = o.RegisterNewParty(ctx, credentials.Url, credentials.Token) if err != nil { return err } - // register new party - err = o.RegisterNewParty(ctx, credentials.Url, credentials.Token) + // delete old token + err := o.store.DeleteRegistrationDetails(ctx, token) if err != nil { return err } } + // store new token + err = o.store.SetRegistrationDetails(ctx, credentials.Token, &store.OcpiRegistration{ + Status: store.OcpiRegistrationStatusRegistered, + }) + if err != nil { + return err + } + return nil } + +func (o *OCPI) GetToken(ctx context.Context, countryCode string, partyID string, tokenUID string) (*Token, error) { + tok, err := o.store.LookupToken(ctx, tokenUID) + if err != nil { + return nil, err + } + if tok.CountryCode != countryCode || tok.PartyId != partyID { + return nil, nil + } + return &Token{ + ContractId: tok.ContractId, + CountryCode: tok.CountryCode, + GroupId: tok.GroupId, + Issuer: tok.Issuer, + Language: tok.LanguageCode, + LastUpdated: tok.LastUpdated, + PartyId: tok.PartyId, + Type: TokenType(tok.Type), + Uid: tok.Uid, + Valid: tok.Valid, + VisualNumber: tok.VisualNumber, + Whitelist: TokenWhitelist(tok.CacheMode), + }, nil +} + +func (o *OCPI) SetToken(ctx context.Context, token Token) error { + tok := &store.Token{ + CountryCode: token.CountryCode, + PartyId: token.PartyId, + Type: string(token.Type), + Uid: token.Uid, + ContractId: token.ContractId, + VisualNumber: token.VisualNumber, + Issuer: token.Issuer, + GroupId: token.GroupId, + Valid: token.Valid, + LanguageCode: token.Language, + CacheMode: string(token.Whitelist), + } + + return o.store.SetToken(ctx, tok) +} diff --git a/manager/ocpi/ocpi_test.go b/manager/ocpi/ocpi_test.go new file mode 100644 index 0000000..96e2627 --- /dev/null +++ b/manager/ocpi/ocpi_test.go @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: Apache-2.0 + +package ocpi_test + +import ( + "context" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/thoughtworks/maeve-csms/manager/ocpi" + "github.com/thoughtworks/maeve-csms/manager/store" + "github.com/thoughtworks/maeve-csms/manager/store/inmemory" + "net/http" + "testing" +) + +func TestGetVersions(t *testing.T) { + engine := inmemory.NewStore() + ocpiApi := ocpi.NewOCPI(engine, http.DefaultClient, "GB", "TWK") + + want := []ocpi.Version{ + { + Version: "2.2", + Url: "/ocpi/2.2", + }, + } + + got, err := ocpiApi.GetVersions(context.Background()) + require.NoError(t, err) + assert.Equal(t, want, got) +} + +func TestGetVersionDetails(t *testing.T) { + engine := inmemory.NewStore() + ocpiApi := ocpi.NewOCPI(engine, http.DefaultClient, "GB", "TWK") + + want := ocpi.VersionDetail{ + Version: "2.2", + Endpoints: []ocpi.Endpoint{ + { + Identifier: "credentials", + Role: ocpi.RECEIVER, + Url: "/ocpi/2.2/credentials", + }, + { + Identifier: "tokens", + Role: ocpi.RECEIVER, + Url: "/ocpi/receiver/2.2/tokens/", + }, + }, + } + + got, err := ocpiApi.GetVersion(context.Background()) + require.NoError(t, err) + assert.Equal(t, want, got) +} + +func TestGetToken(t *testing.T) { + engine := inmemory.NewStore() + ocpiApi := ocpi.NewOCPI(engine, http.DefaultClient, "GB", "TWK") + err := engine.SetToken(context.Background(), &store.Token{ + CountryCode: "GB", + PartyId: "TWK", + Type: "RFID", + Uid: "DEADBEEF", + ContractId: "GBTWKTWTW000018", + Issuer: "Thoughtworks", + Valid: true, + CacheMode: "ALWAYS", + }) + require.NoError(t, err) + + want := &ocpi.Token{ + ContractId: "GBTWKTWTW000018", + CountryCode: "GB", + Issuer: "Thoughtworks", + PartyId: "TWK", + Type: "RFID", + Uid: "DEADBEEF", + Valid: true, + Whitelist: "ALWAYS", + } + + got, err := ocpiApi.GetToken(context.Background(), "GB", "TWK", "DEADBEEF") + require.NoError(t, err) + + assert.Regexp(t, `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$`, got.LastUpdated) + got.LastUpdated = "" + assert.Equal(t, want, got) +} + +func TestSetToken(t *testing.T) { + engine := inmemory.NewStore() + ocpiApi := ocpi.NewOCPI(engine, http.DefaultClient, "GB", "TWK") + + err := ocpiApi.SetToken(context.Background(), ocpi.Token{ + ContractId: "GBTWKTWTW000018", + CountryCode: "GB", + Issuer: "Thoughtworks", + PartyId: "TWK", + Type: "RFID", + Uid: "DEADBEEF", + Valid: true, + Whitelist: "ALWAYS", + }) + require.NoError(t, err) + + want := &store.Token{ + CountryCode: "GB", + PartyId: "TWK", + Type: "RFID", + Uid: "DEADBEEF", + ContractId: "GBTWKTWTW000018", + Issuer: "Thoughtworks", + Valid: true, + CacheMode: "ALWAYS", + } + + got, err := engine.LookupToken(context.Background(), "DEADBEEF") + require.NoError(t, err) + got.LastUpdated = "" + assert.Equal(t, want, got) +} diff --git a/manager/ocpi/register.go b/manager/ocpi/register.go index 656794f..a2ea83c 100644 --- a/manager/ocpi/register.go +++ b/manager/ocpi/register.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package ocpi import ( @@ -14,6 +16,14 @@ import ( ) func (o *OCPI) RegisterNewParty(ctx context.Context, url, token string) error { + reg, err := o.store.GetRegistrationDetails(ctx, token) + if err != nil { + return err + } + if reg != nil && reg.Status == store.OcpiRegistrationStatusRegistered { + return errors.New("already registered") + } + versions, err := o.getVersions(ctx, url, token) if err != nil { return err diff --git a/manager/ocpi/register_test.go b/manager/ocpi/register_test.go index be597c0..70e33f3 100644 --- a/manager/ocpi/register_test.go +++ b/manager/ocpi/register_test.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package ocpi_test import ( @@ -59,4 +61,24 @@ func TestRegistration(t *testing.T) { assert.Equal(t, "TWS", receiverPartyDetails.PartyId) assert.Equal(t, receiverServer.URL+"/ocpi/versions", receiverPartyDetails.Url) assert.Len(t, receiverPartyDetails.Token, 64) + + // check initial registration details have been removed + senderTokenAReg, err := senderStore.GetRegistrationDetails(context.Background(), tokenA) + require.NoError(t, err) + assert.Nil(t, senderTokenAReg) + + receiverTokenAReg, err := receiverStore.GetRegistrationDetails(context.Background(), tokenA) + require.NoError(t, err) + assert.Nil(t, receiverTokenAReg) + + // token status + receiverTokenBReg, err := receiverStore.GetRegistrationDetails(context.Background(), senderPartyDetails.Token) + require.NoError(t, err) + require.NotNil(t, receiverTokenBReg) + assert.Equal(t, store.OcpiRegistrationStatusRegistered, receiverTokenBReg.Status) + + senderTokenCReg, err := senderStore.GetRegistrationDetails(context.Background(), receiverPartyDetails.Token) + require.NoError(t, err) + require.NotNil(t, senderTokenCReg) + assert.Equal(t, store.OcpiRegistrationStatusRegistered, senderTokenCReg.Status) } diff --git a/manager/ocpi/render.go b/manager/ocpi/render.go index eb59a7a..320092d 100644 --- a/manager/ocpi/render.go +++ b/manager/ocpi/render.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package ocpi import "net/http" @@ -10,6 +12,14 @@ func (OcpiResponseVersionDetail) Render(http.ResponseWriter, *http.Request) erro return nil } +func (OcpiResponseToken) Render(http.ResponseWriter, *http.Request) error { + return nil +} + func (Credentials) Bind(r *http.Request) error { return nil } + +func (Token) Bind(r *http.Request) error { + return nil +} diff --git a/manager/ocpi/server.go b/manager/ocpi/server.go index 97c3d4c..92cba94 100644 --- a/manager/ocpi/server.go +++ b/manager/ocpi/server.go @@ -1,6 +1,9 @@ +// SPDX-License-Identifier: Apache-2.0 + package ocpi import ( + "encoding/json" "fmt" "github.com/go-chi/render" "k8s.io/utils/clock" @@ -20,6 +23,8 @@ func NewServer(ocpi Api, clock clock.PassiveClock) (*Server, error) { }, nil } +// VERSIONS + func (s *Server) GetVersions(w http.ResponseWriter, r *http.Request, params GetVersionsParams) { versions, err := s.ocpi.GetVersions(r.Context()) if err != nil { @@ -57,6 +62,8 @@ func (s *Server) GetVersion(w http.ResponseWriter, r *http.Request, params GetVe }) } +// CREDENTIALS + func (s *Server) PostCredentials(w http.ResponseWriter, r *http.Request, params PostCredentialsParams) { creds := new(Credentials) if err := render.Bind(r, creds); err != nil { @@ -79,6 +86,108 @@ func (s *Server) PostCredentials(w http.ResponseWriter, r *http.Request, params w.WriteHeader(http.StatusCreated) } +// TOKEN RECEIVER + +func (s *Server) GetClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params GetClientOwnedTokenParams) { + token, err := s.ocpi.GetToken(r.Context(), countryCode, partyID, tokenUID) + if err != nil { + _ = render.Render(w, r, ErrInternalError(err)) + return + } + + _ = render.Render(w, r, OcpiResponseToken{ + StatusCode: StatusSuccess, + StatusMessage: &StatusSuccessMessage, + Timestamp: s.clock.Now().Format(time.RFC3339), + Data: token, + }) +} + +func (s *Server) PutClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params PutClientOwnedTokenParams) { + tok := new(Token) + if err := render.Bind(r, tok); err != nil { + _ = render.Render(w, r, ErrInvalidRequest(err)) + return + } + + if tok.CountryCode != countryCode { + _ = render.Render(w, r, ErrInvalidRequest(fmt.Errorf("token country code mismatch"))) + return + } + if tok.PartyId != partyID { + _ = render.Render(w, r, ErrInvalidRequest(fmt.Errorf("token party id mismatch"))) + return + } + if tok.Uid != tokenUID { + _ = render.Render(w, r, ErrInvalidRequest(fmt.Errorf("token uid mismatch"))) + return + } + + err := s.ocpi.SetToken(r.Context(), *tok) + if err != nil { + _ = render.Render(w, r, OcpiResponseListVersion{ + StatusCode: StatusGenericServerFailure, + Timestamp: s.clock.Now().Format(time.RFC3339), + }) + } +} + +func (s *Server) PatchClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params PatchClientOwnedTokenParams) { + var patch map[string]any + err := json.NewDecoder(r.Body).Decode(&patch) + if err != nil { + _ = render.Render(w, r, ErrInvalidRequest(err)) + return + } + + tok, err := s.ocpi.GetToken(r.Context(), countryCode, partyID, tokenUID) + if err != nil { + _ = render.Render(w, r, ErrInternalError(err)) + return + } + if tok == nil { + _ = render.Render(w, r, ErrNotFound) + return + } + + for k, v := range patch { + switch k { + case "contract_id": + contractID := v.(string) + tok.ContractId = contractID + case "group_id": + groupID := v.(string) + tok.GroupId = &groupID + case "issuer": + issuer := v.(string) + tok.Issuer = issuer + case "language": + language := v.(string) + tok.Language = &language + case "type": + typ := v.(TokenType) + tok.Type = typ + case "valid": + valid := v.(bool) + tok.Valid = valid + case "visual_number": + visualNumber := v.(string) + tok.VisualNumber = &visualNumber + case "whitelist": + whitelist := v.(TokenWhitelist) + tok.Whitelist = whitelist + default: + _ = render.Render(w, r, ErrInvalidRequest(fmt.Errorf("unknown field %s", k))) + } + } + + err = s.ocpi.SetToken(r.Context(), *tok) + if err != nil { + _ = render.Render(w, r, ErrInternalError(err)) + return + } +} + func (s *Server) DeleteCredentials(w http.ResponseWriter, r *http.Request, params DeleteCredentialsParams) { w.WriteHeader(http.StatusNotImplemented) } @@ -199,18 +308,6 @@ func (s *Server) PutClientOwnedTariff(w http.ResponseWriter, r *http.Request, co w.WriteHeader(http.StatusNotImplemented) } -func (s *Server) GetClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params GetClientOwnedTokenParams) { - w.WriteHeader(http.StatusNotImplemented) -} - -func (s *Server) PatchClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params PatchClientOwnedTokenParams) { - w.WriteHeader(http.StatusNotImplemented) -} - -func (s *Server) PutClientOwnedToken(w http.ResponseWriter, r *http.Request, countryCode string, partyID string, tokenUID string, params PutClientOwnedTokenParams) { - w.WriteHeader(http.StatusNotImplemented) -} - func (s *Server) GetCdrsFromDataOwner(w http.ResponseWriter, r *http.Request, params GetCdrsFromDataOwnerParams) { w.WriteHeader(http.StatusNotImplemented) } diff --git a/manager/ocpi/server_test.go b/manager/ocpi/server_test.go new file mode 100644 index 0000000..7f2b4d0 --- /dev/null +++ b/manager/ocpi/server_test.go @@ -0,0 +1,158 @@ +package ocpi_test + +import ( + "context" + "encoding/json" + "github.com/go-chi/chi/v5" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/thoughtworks/maeve-csms/manager/ocpi" + "github.com/thoughtworks/maeve-csms/manager/store" + "github.com/thoughtworks/maeve-csms/manager/store/inmemory" + "io" + fakeclock "k8s.io/utils/clock/testing" + "net/http" + "net/http/httptest" + "testing" + "time" +) + +func setupHandler(t *testing.T) (http.Handler, store.Engine, time.Time) { + engine := inmemory.NewStore() + err := engine.SetRegistrationDetails(context.Background(), "123", &store.OcpiRegistration{ + Status: store.OcpiRegistrationStatusRegistered, + }) + require.NoError(t, err) + ocpiApi := ocpi.NewOCPI(engine, http.DefaultClient, "GB", "TWK") + now := time.Now().UTC() + server, err := ocpi.NewServer(ocpiApi, fakeclock.NewFakePassiveClock(now)) + require.NoError(t, err) + + r := chi.NewRouter() + r.Mount("/", ocpi.Handler(server)) + return r, engine, now +} + +func TestServerGetVersions(t *testing.T) { + handler, _, now := setupHandler(t) + req := httptest.NewRequest(http.MethodGet, "/ocpi/versions", nil) + req.Header.Set("Authorization", "Token 123") + w := httptest.NewRecorder() + handler.ServeHTTP(w, req) + resp := w.Result() + require.Equal(t, http.StatusOK, resp.StatusCode) + b, err := io.ReadAll(resp.Body) + require.NoError(t, err) + + want := ocpi.OcpiResponseListVersion{ + Data: &[]ocpi.Version{ + { + Version: "2.2", + Url: "/ocpi/2.2", + }, + }, + StatusCode: ocpi.StatusSuccess, + StatusMessage: &ocpi.StatusSuccessMessage, + Timestamp: now.Format(time.RFC3339), + } + + var got ocpi.OcpiResponseListVersion + err = json.Unmarshal(b, &got) + require.NoError(t, err) + + assert.Equal(t, want, got) +} + +func TestServerGetVersion(t *testing.T) { + handler, _, now := setupHandler(t) + req := httptest.NewRequest(http.MethodGet, "/ocpi/2.2", nil) + req.Header.Set("Authorization", "Token 123") + w := httptest.NewRecorder() + handler.ServeHTTP(w, req) + resp := w.Result() + require.Equal(t, http.StatusOK, resp.StatusCode) + b, err := io.ReadAll(resp.Body) + require.NoError(t, err) + + want := ocpi.OcpiResponseVersionDetail{ + Data: &ocpi.VersionDetail{ + Endpoints: []ocpi.Endpoint{ + { + Identifier: "credentials", + Url: "/ocpi/2.2/credentials", + Role: ocpi.RECEIVER, + }, + { + Identifier: "tokens", + Url: "/ocpi/receiver/2.2/tokens/", + Role: ocpi.RECEIVER, + }, + }, + Version: "2.2", + }, + StatusCode: ocpi.StatusSuccess, + StatusMessage: &ocpi.StatusSuccessMessage, + Timestamp: now.Format(time.RFC3339), + } + + var got ocpi.OcpiResponseVersionDetail + err = json.Unmarshal(b, &got) + require.NoError(t, err) + + assert.Equal(t, want, got) +} + +func TestServerGetClientOwnedToken(t *testing.T) { + handler, engine, now := setupHandler(t) + + err := engine.SetToken(context.Background(), &store.Token{ + CountryCode: "GB", + PartyId: "TWK", + Type: "RFID", + Uid: "DEADBEEF", + ContractId: "GBTWKTWTW000018", + Issuer: "Thoughtworks", + Valid: true, + CacheMode: "ALWAYS", + }) + require.NoError(t, err) + + req := httptest.NewRequest(http.MethodGet, "/ocpi/receiver/2.2/tokens/GB/TWK/DEADBEEF", nil) + req.Header.Set("Authorization", "Token 123") + req.Header.Set("X-Request-ID", "123") + req.Header.Set("X-Correlation-ID", "123") + req.Header.Set("OCPI-from-country-code", "GB") + req.Header.Set("OCPI-from-party-id", "TWK") + req.Header.Set("OCPI-to-country-code", "GB") + req.Header.Set("OCPI-to-party-id", "TWK") + w := httptest.NewRecorder() + handler.ServeHTTP(w, req) + resp := w.Result() + assert.Equal(t, http.StatusOK, resp.StatusCode) + b, err := io.ReadAll(resp.Body) + require.NoError(t, err) + + want := ocpi.OcpiResponseToken{ + Data: &ocpi.Token{ + ContractId: "GBTWKTWTW000018", + CountryCode: "GB", + Issuer: "Thoughtworks", + PartyId: "TWK", + Type: "RFID", + Uid: "DEADBEEF", + Valid: true, + Whitelist: "ALWAYS", + }, + StatusCode: ocpi.StatusSuccess, + StatusMessage: &ocpi.StatusSuccessMessage, + Timestamp: now.Format(time.RFC3339), + } + + var got ocpi.OcpiResponseToken + err = json.Unmarshal(b, &got) + require.NoError(t, err) + + assert.Regexp(t, `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$`, got.Data.LastUpdated) + got.Data.LastUpdated = "" + assert.Equal(t, want, got) +} diff --git a/manager/ocpi/status.go b/manager/ocpi/status.go index 6ab7026..a4824fc 100644 --- a/manager/ocpi/status.go +++ b/manager/ocpi/status.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package ocpi var ( From a7f1aaea497792f8ec650f0050592b034f752bf3 Mon Sep 17 00:00:00 2001 From: Dale Peakall Date: Fri, 11 Aug 2023 17:31:44 +0100 Subject: [PATCH 03/15] ci: exclude generated files from gosec --- .github/workflows/gateway.yml | 2 +- .github/workflows/manager.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gateway.yml b/.github/workflows/gateway.yml index d74a0b8..9087cfb 100644 --- a/.github/workflows/gateway.yml +++ b/.github/workflows/gateway.yml @@ -32,7 +32,7 @@ jobs: - name: Run Gosec Security Scanner run: | go install github.com/securego/gosec/v2/cmd/gosec@latest - gosec ./... + gosec -exclude-generated ./... - name: Test & Coverage run: | go test ./... -coverprofile=coverage.out diff --git a/.github/workflows/manager.yml b/.github/workflows/manager.yml index f7b4186..2f50129 100644 --- a/.github/workflows/manager.yml +++ b/.github/workflows/manager.yml @@ -32,7 +32,7 @@ jobs: - name: Run Gosec Security Scanner run: | go install github.com/securego/gosec/v2/cmd/gosec@latest - gosec ./... + gosec -exclude-generated ./... - name: Test & Coverage run: | go test ./... -coverprofile=coverage.out From 842bb0bc21cce69d6c316a1663c55ce00a88bc8b Mon Sep 17 00:00:00 2001 From: Dale Peakall Date: Fri, 11 Aug 2023 17:35:26 +0100 Subject: [PATCH 04/15] docs: update API documentation --- manager/api/API.md | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/manager/api/API.md b/manager/api/API.md index aa2aed4..58a835e 100644 --- a/manager/api/API.md +++ b/manager/api/API.md @@ -440,6 +440,56 @@ of the DER bytes. This operation does not require authentication +## registerParty + + + +`POST /register` + +*Registers an OCPI party with the CSMS* + +Registers an OCPI party with the CSMS. Depending on the configuration provided the CSMS will +either initiate a registration with the party or the party will wait for the party to initiate +a registration with the CSMS. + +> Body parameter + +```json +{ + "token": "string", + "url": "http://example.com", + "status": "PENDING" +} +``` + +

Parameters

+ +|Name|In|Type|Required|Description| +|---|---|---|---|---| +|body|body|[Registration](#schemaregistration)|true|none| + +> Example responses + +> default Response + +```json +{ + "status": "string", + "error": "string" +} +``` + +

Responses

+ +|Status|Meaning|Description|Schema| +|---|---|---|---| +|201|[Created](https://tools.ietf.org/html/rfc7231#section-6.3.2)|Created|None| +|default|Default|Unexpected error|[Status](#schemastatus)| + + + # Schemas

ChargeStationAuth

@@ -569,3 +619,36 @@ A client certificate |---|---|---|---|---| |certificate|string|true|none|The PEM encoded certificate with newlines replaced by `\n`| +

Registration

+ + + + + + +```json +{ + "token": "string", + "url": "http://example.com", + "status": "PENDING" +} + +``` + +Defines the initial connection details for the OCPI registration process + +### Properties + +|Name|Type|Required|Restrictions|Description| +|---|---|---|---|---| +|token|string|true|none|The token to use for communicating with the eMSP (CREDENTIALS_TOKEN_A).| +|url|string(uri)|false|none|The URL of the eMSP versions endpoint. If provided the CSMS will act as the sender of the versions request.| +|status|string|false|none|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.| + +#### Enumerated Values + +|Property|Value| +|---|---| +|status|PENDING| +|status|REGISTERED| + From 74c1f01a72d922f6f0e389a17f9fb30c06a6d25a Mon Sep 17 00:00:00 2001 From: Dale Peakall Date: Sat, 12 Aug 2023 15:20:04 +0100 Subject: [PATCH 05/15] refactor: add additional OCPI tests --- manager/ocpi/server.go | 8 +-- manager/ocpi/server_test.go | 105 ++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 4 deletions(-) diff --git a/manager/ocpi/server.go b/manager/ocpi/server.go index 92cba94..dedbb34 100644 --- a/manager/ocpi/server.go +++ b/manager/ocpi/server.go @@ -165,8 +165,8 @@ func (s *Server) PatchClientOwnedToken(w http.ResponseWriter, r *http.Request, c language := v.(string) tok.Language = &language case "type": - typ := v.(TokenType) - tok.Type = typ + typ := v.(string) + tok.Type = TokenType(typ) case "valid": valid := v.(bool) tok.Valid = valid @@ -174,8 +174,8 @@ func (s *Server) PatchClientOwnedToken(w http.ResponseWriter, r *http.Request, c visualNumber := v.(string) tok.VisualNumber = &visualNumber case "whitelist": - whitelist := v.(TokenWhitelist) - tok.Whitelist = whitelist + whitelist := v.(string) + tok.Whitelist = TokenWhitelist(whitelist) default: _ = render.Render(w, r, ErrInvalidRequest(fmt.Errorf("unknown field %s", k))) } diff --git a/manager/ocpi/server_test.go b/manager/ocpi/server_test.go index 7f2b4d0..db209ed 100644 --- a/manager/ocpi/server_test.go +++ b/manager/ocpi/server_test.go @@ -1,6 +1,7 @@ package ocpi_test import ( + "bytes" "context" "encoding/json" "github.com/go-chi/chi/v5" @@ -13,6 +14,7 @@ import ( fakeclock "k8s.io/utils/clock/testing" "net/http" "net/http/httptest" + "strings" "testing" "time" ) @@ -156,3 +158,106 @@ func TestServerGetClientOwnedToken(t *testing.T) { got.Data.LastUpdated = "" assert.Equal(t, want, got) } + +func TestServerPutClientOwnedToken(t *testing.T) { + handler, engine, _ := setupHandler(t) + + tok := ocpi.Token{ + ContractId: "GBTWKTWTW000018", + CountryCode: "GB", + Issuer: "Thoughtworks", + PartyId: "TWK", + Type: "RFID", + Uid: "DEADBEEF", + Valid: true, + Whitelist: "ALWAYS", + } + b, err := json.Marshal(tok) + require.NoError(t, err) + + req := httptest.NewRequest(http.MethodPut, "/ocpi/receiver/2.2/tokens/GB/TWK/DEADBEEF", bytes.NewReader(b)) + req.Header.Set("Authorization", "Token 123") + req.Header.Set("Content-Type", "application/json") + req.Header.Set("X-Request-ID", "123") + req.Header.Set("X-Correlation-ID", "123") + req.Header.Set("OCPI-from-country-code", "GB") + req.Header.Set("OCPI-from-party-id", "TWK") + req.Header.Set("OCPI-to-country-code", "GB") + req.Header.Set("OCPI-to-party-id", "TWK") + w := httptest.NewRecorder() + handler.ServeHTTP(w, req) + resp := w.Result() + assert.Equal(t, http.StatusOK, resp.StatusCode) + + want := &store.Token{ + CountryCode: "GB", + PartyId: "TWK", + Type: "RFID", + Uid: "DEADBEEF", + ContractId: "GBTWKTWTW000018", + Issuer: "Thoughtworks", + Valid: true, + CacheMode: "ALWAYS", + } + + got, err := engine.LookupToken(context.Background(), "DEADBEEF") + require.NoError(t, err) + got.LastUpdated = "" + assert.Equal(t, want, got) +} + +func TestServerPatchClientOwnedToken(t *testing.T) { + handler, engine, _ := setupHandler(t) + + err := engine.SetToken(context.Background(), &store.Token{ + CountryCode: "GB", + PartyId: "TWK", + Type: "RFID", + Uid: "DEADBEEF", + ContractId: "GBTWKTWTW000018", + Issuer: "Thoughtworks", + Valid: true, + CacheMode: "ALWAYS", + }) + require.NoError(t, err) + + req := httptest.NewRequest(http.MethodPatch, "/ocpi/receiver/2.2/tokens/GB/TWK/DEADBEEF", + strings.NewReader(`{ + "contract_id": "GBTWKTWTW000025", + "issuer": "TW", + "valid": false, + "whitelist": "NEVER" + }`)) + req.Header.Set("Authorization", "Token 123") + req.Header.Set("Content-Type", "application/json") + req.Header.Set("X-Request-ID", "123") + req.Header.Set("X-Correlation-ID", "123") + req.Header.Set("OCPI-from-country-code", "GB") + req.Header.Set("OCPI-from-party-id", "TWK") + req.Header.Set("OCPI-to-country-code", "GB") + req.Header.Set("OCPI-to-party-id", "TWK") + w := httptest.NewRecorder() + handler.ServeHTTP(w, req) + resp := w.Result() + assert.Equal(t, http.StatusOK, resp.StatusCode) + + want := &store.Token{ + CountryCode: "GB", + PartyId: "TWK", + Type: "RFID", + Uid: "DEADBEEF", + ContractId: "GBTWKTWTW000025", + Issuer: "TW", + Valid: false, + CacheMode: "NEVER", + } + + got, err := engine.LookupToken(context.Background(), "DEADBEEF") + require.NoError(t, err) + got.LastUpdated = "" + assert.Equal(t, want, got) + + b, err := io.ReadAll(resp.Body) + require.NoError(t, err) + t.Logf("%s", string(b)) +} From 1e0357fd08d98d2b6739189e09ca5e15e6afd1df Mon Sep 17 00:00:00 2001 From: Dale Peakall Date: Sat, 12 Aug 2023 16:25:53 +0100 Subject: [PATCH 06/15] fix: auth token type is case-sensitive --- manager/ocpi/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/ocpi/auth.go b/manager/ocpi/auth.go index 28e6820..cdeb5e4 100644 --- a/manager/ocpi/auth.go +++ b/manager/ocpi/auth.go @@ -11,7 +11,7 @@ import ( "regexp" ) -var authzHeaderRegexp = regexp.MustCompile(`^Token (.*)$`) +var authzHeaderRegexp = regexp.MustCompile(`(?i)^Token (.*)$`) func NewTokenAuthenticationFunc(engine store.Engine) openapi3filter.AuthenticationFunc { return func(ctx context.Context, input *openapi3filter.AuthenticationInput) error { From 6d5c80762b3918a99a108c6a8533c8ed3ddac65c Mon Sep 17 00:00:00 2001 From: Gesa Stupperich Date: Mon, 28 Aug 2023 14:34:25 +0100 Subject: [PATCH 07/15] fix: add content-type header to OCSP request --- manager/go.mod | 18 ++++---- manager/go.sum | 44 ++++++++++--------- manager/services/certificate_validation.go | 10 +++-- .../certificate_validation_hubject_test.go | 1 + 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/manager/go.mod b/manager/go.mod index fbc2eee..5056b5c 100644 --- a/manager/go.mod +++ b/manager/go.mod @@ -20,7 +20,7 @@ require ( github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.4 github.com/subnova/slog-exporter v0.1.0 - github.com/testcontainers/testcontainers-go v0.21.0 + github.com/testcontainers/testcontainers-go v0.23.0 github.com/unrolled/secure v1.13.0 go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 go.opentelemetry.io/contrib/detectors/gcp v1.17.0 @@ -32,7 +32,7 @@ require ( golang.org/x/crypto v0.10.0 golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691 google.golang.org/api v0.126.0 - google.golang.org/grpc v1.55.0 + google.golang.org/grpc v1.57.0 k8s.io/utils v0.0.0-20230505201702-9f6742963106 ) @@ -41,9 +41,10 @@ require ( cloud.google.com/go/compute v1.19.3 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/longrunning v0.5.0 // indirect + dario.cat/mergo v1.0.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.13.1 // indirect - github.com/Microsoft/go-winio v0.5.2 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ajg/form v1.5.1 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -51,12 +52,12 @@ require ( github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect - github.com/containerd/containerd v1.6.19 // indirect + github.com/containerd/containerd v1.7.3 // indirect github.com/cpuguy83/dockercfg v0.3.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/docker/distribution v2.8.2+incompatible // indirect - github.com/docker/docker v23.0.5+incompatible // indirect + github.com/docker/docker v24.0.5+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/felixge/httpsnoop v1.0.3 // indirect @@ -81,7 +82,6 @@ require ( github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect - github.com/imdario/mergo v0.3.15 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/invopop/yaml v0.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -109,7 +109,7 @@ require ( github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0-rc2 // indirect + github.com/opencontainers/image-spec v1.1.0-rc4 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/perimeterx/marshmallow v1.1.4 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -132,12 +132,14 @@ require ( go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/proto/otlp v0.19.0 // indirect golang.org/x/arch v0.3.0 // indirect + golang.org/x/mod v0.11.0 // indirect golang.org/x/net v0.10.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.9.0 // indirect + golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.10.0 // indirect golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.9.2 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect diff --git a/manager/go.sum b/manager/go.sum index c1b4b91..5173f38 100644 --- a/manager/go.sum +++ b/manager/go.sum @@ -40,16 +40,19 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.13.1 h1:hR+NqMEDDSR8hLc5ZybuWtPfhmFVZwd6Ft7n25XnVjk= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.13.1/go.mod h1:Xx0VKh7GJ4si3rmElbh19Mejxz68ibWg/J30ZOMrqzU= -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/hcsshim v0.9.7 h1:mKNHW/Xvv1aFH87Jb6ERDzXTJTLPlmzfZ28VBFD/bfg= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/hcsshim v0.10.0-rc.8 h1:YSZVvlIIDD1UxQpJp0h+dnpLUw+TrY0cx8obKsp3bek= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= @@ -87,9 +90,8 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= -github.com/containerd/containerd v1.6.19 h1:F0qgQPrG0P2JPgwpxWxYavrVeXAG0ezUIB9Z/4FTUAU= -github.com/containerd/containerd v1.6.19/go.mod h1:HZCDMn4v/Xl2579/MvtOC2M206i+JJ6VxFWU/NetrGY= -github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/containerd/containerd v1.7.3 h1:cKwYKkP1eTj54bP3wCdXXBymmKRQMrWjkLSWZZJDa8o= +github.com/containerd/containerd v1.7.3/go.mod h1:32FOM4/O0RkNg7AjQj3hDzN9cUGtu+HMvaKUNiqCZB8= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= @@ -98,6 +100,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI= github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -109,8 +112,8 @@ github.com/deepmap/oapi-codegen v1.13.0 h1:cnFHelhsRQbYvanCUAbRSn/ZpkUb1HPRlQcu8 github.com/deepmap/oapi-codegen v1.13.0/go.mod h1:Amy7tbubKY9qkZOXqymI3Z6xSbndmu+atMJheLdyg44= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v23.0.5+incompatible h1:DaxtlTJjFSnLOXVNUBU1+6kXGz2lpDoEAH6QoxaSg8k= -github.com/docker/docker v23.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY= +github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= @@ -250,8 +253,6 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4Zs github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= -github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/invopop/yaml v0.1.0 h1:YW3WGUoJEXYfzWBjn00zIlrw7brGVD0fUKRYDPAPhrc= @@ -338,8 +339,8 @@ github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= -github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= +github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0= +github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= @@ -380,7 +381,6 @@ github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKP github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4= github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= @@ -408,8 +408,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/subnova/slog-exporter v0.1.0 h1:5Ge+50z1wsEKnfGHPcQH9r4S+3mnEhnNn5W0p+fY9do= github.com/subnova/slog-exporter v0.1.0/go.mod h1:WQ3oicsqaGWuj6VjnflRfXRfDrx0NH4PJOxKvpQoJfM= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/testcontainers/testcontainers-go v0.21.0 h1:syePAxdeTzfkap+RrJaQZpJQ/s/fsUgn11xIvHrOE9U= -github.com/testcontainers/testcontainers-go v0.21.0/go.mod h1:c1ez3WVRHq7T/Aj+X3TIipFBwkBaNT5iNCY8+1b83Ng= +github.com/testcontainers/testcontainers-go v0.23.0 h1:ERYTSikX01QczBLPZpqsETTBO7lInqEP349phDOVJVs= +github.com/testcontainers/testcontainers-go v0.23.0/go.mod h1:3gzuZfb7T9qfcH2pHpV4RLlWrPjeWNQah6XlYQ32c4I= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= @@ -509,6 +509,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -617,8 +619,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -685,6 +687,8 @@ golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.9.2 h1:UXbndbirwCAx6TULftIfie/ygDNCwxEie+IiNP1IcNc= +golang.org/x/tools v0.9.2/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -772,8 +776,8 @@ google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= -google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -804,7 +808,7 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/manager/services/certificate_validation.go b/manager/services/certificate_validation.go index 21929d6..0d82bc2 100644 --- a/manager/services/certificate_validation.go +++ b/manager/services/certificate_validation.go @@ -11,13 +11,12 @@ import ( "encoding/hex" "errors" "fmt" - "io" - "math/big" - "net/http" - "github.com/thoughtworks/maeve-csms/manager/ocpp/ocpp201" "golang.org/x/crypto/ocsp" "golang.org/x/exp/slog" + "io" + "math/big" + "net/http" ) // OCSPError is an error returned by the OCSP server in response to a check @@ -275,6 +274,9 @@ func (o *OnlineCertificateValidationService) attemptOCSPCheck(ctx context.Contex return nil, fmt.Errorf("new request: %w", err) } + req.Header.Add("Content-Type", "application/ocsp-request") + req.Header.Add("Accept", "application/ocsp-response") + resp, err := o.HttpClient.Do(req) if err != nil { return nil, fmt.Errorf("post %s: %w", ocspResponderUrl, err) diff --git a/manager/services/certificate_validation_hubject_test.go b/manager/services/certificate_validation_hubject_test.go index e9051f7..a8f797a 100644 --- a/manager/services/certificate_validation_hubject_test.go +++ b/manager/services/certificate_validation_hubject_test.go @@ -60,6 +60,7 @@ func TestCertificateValidationServiceWithHubjectCertificateHashes(t *testing.T) httpClient), BaseURL: "https://open.plugncharge-test.hubject.com", ISOVersion: services.ISO15118V2, + HttpClient: httpClient, } csr := createCertificateSigningRequest(t) From e45ac3ce0169c7895122d425cc27e41560c16566 Mon Sep 17 00:00:00 2001 From: Gesa Stupperich Date: Thu, 10 Aug 2023 10:08:37 +0100 Subject: [PATCH 08/15] feat: implement has2be SignCertificate handler --- manager/handlers/has2be/sign_certificate.go | 40 +++++++++++++++++++ .../handlers/has2be/sign_certificate_test.go | 3 ++ manager/mqtt/router.go | 11 +++++ .../ocpp/has2be/sign_certificate_request.go | 17 ++++++++ .../ocpp/has2be/sign_certificate_response.go | 13 ++++++ 5 files changed, 84 insertions(+) create mode 100644 manager/handlers/has2be/sign_certificate.go create mode 100644 manager/handlers/has2be/sign_certificate_test.go create mode 100644 manager/ocpp/has2be/sign_certificate_request.go create mode 100644 manager/ocpp/has2be/sign_certificate_response.go diff --git a/manager/handlers/has2be/sign_certificate.go b/manager/handlers/has2be/sign_certificate.go new file mode 100644 index 0000000..14ff4db --- /dev/null +++ b/manager/handlers/has2be/sign_certificate.go @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: Apache-2.0 + +package has2be + +import ( + "context" + handlers201 "github.com/thoughtworks/maeve-csms/manager/handlers/ocpp201" + "github.com/thoughtworks/maeve-csms/manager/ocpp" + typesHasToBe "github.com/thoughtworks/maeve-csms/manager/ocpp/has2be" + types201 "github.com/thoughtworks/maeve-csms/manager/ocpp/ocpp201" +) + +type SignCertificateHandler struct { + Handler201 handlers201.SignCertificateHandler +} + +func (s SignCertificateHandler) HandleCall(ctx context.Context, chargeStationId string, request ocpp.Request) (ocpp.Response, error) { + req := request.(*typesHasToBe.SignCertificateRequestJson) + + req201 := &types201.SignCertificateRequestJson{ + Csr: req.Csr, + } + + if req.TypeOfCertificate != nil { + req201 = &types201.SignCertificateRequestJson{ + Csr: req.Csr, + CertificateType: (*types201.CertificateSigningUseEnumType)(req.TypeOfCertificate), + } + } + + res, err := s.Handler201.HandleCall(ctx, chargeStationId, req201) + if err != nil { + return nil, err + } + res201 := res.(*types201.SignCertificateResponseJson) + + return &typesHasToBe.SignCertificateResponseJson{ + Status: typesHasToBe.GenericStatusEnumType(res201.Status), + }, nil +} diff --git a/manager/handlers/has2be/sign_certificate_test.go b/manager/handlers/has2be/sign_certificate_test.go new file mode 100644 index 0000000..e7982f0 --- /dev/null +++ b/manager/handlers/has2be/sign_certificate_test.go @@ -0,0 +1,3 @@ +// SPDX-License-Identifier: Apache-2.0 + +package has2be_test diff --git a/manager/mqtt/router.go b/manager/mqtt/router.go index 3878462..b580029 100644 --- a/manager/mqtt/router.go +++ b/manager/mqtt/router.go @@ -187,6 +187,17 @@ func NewV16Router(emitter Emitter, }, }, }, + "SignCertificate": { + NewRequest: func() ocpp.Request { return new(has2be.SignCertificateRequestJson) }, + RequestSchema: "has2be/SignCertificateRequestJson.json", + ResponseSchema: "has2be/SignCertificateRequestJson.json", + Handler: handlersHasToBe.SignCertificateHandler{ + Handler201: handlers201.SignCertificateHandler{ + ChargeStationCertificateProvider: chargeStationCertProvider, + CallMaker: dataTransferCallMaker, + }, + }, + }, }, }, }, diff --git a/manager/ocpp/has2be/sign_certificate_request.go b/manager/ocpp/has2be/sign_certificate_request.go new file mode 100644 index 0000000..371629e --- /dev/null +++ b/manager/ocpp/has2be/sign_certificate_request.go @@ -0,0 +1,17 @@ +package has2be + +type CertificateSigningUseEnumType string + +const CertificateSigningUseEnumTypeChargingStationCertificate CertificateSigningUseEnumType = "ChargingStationCertificate" +const CertificateSigningUseEnumTypeV2GCertificate CertificateSigningUseEnumType = "V2GCertificate" + +type SignCertificateRequestJson struct { + // The Charging Station SHALL send the public key in form of a Certificate Signing + // Request (CSR) as described in the X.509 standard. + Csr string `json:"csr" yaml:"csr" mapstructure:"csr"` + + // TypeOfCertificate corresponds to the JSON schema field "typeOfCertificate". + TypeOfCertificate *CertificateSigningUseEnumType `json:"typeOfCertificate,omitempty" yaml:"typeOfCertificate,omitempty" mapstructure:"typeOfCertificate,omitempty"` +} + +func (*SignCertificateRequestJson) IsRequest() {} diff --git a/manager/ocpp/has2be/sign_certificate_response.go b/manager/ocpp/has2be/sign_certificate_response.go new file mode 100644 index 0000000..97afad9 --- /dev/null +++ b/manager/ocpp/has2be/sign_certificate_response.go @@ -0,0 +1,13 @@ +package has2be + +type GenericStatusEnumType string + +const GenericStatusEnumTypeAccepted GenericStatusEnumType = "Accepted" +const GenericStatusEnumTypeRejected GenericStatusEnumType = "Rejected" + +type SignCertificateResponseJson struct { + // Status corresponds to the JSON schema field "status". + Status GenericStatusEnumType `json:"status" yaml:"status" mapstructure:"status"` +} + +func (*SignCertificateResponseJson) IsResponse() {} From a9ba5fc05aa33dfd87fedbede607adaa8b254cc5 Mon Sep 17 00:00:00 2001 From: Gesa Stupperich Date: Thu, 10 Aug 2023 15:52:31 +0100 Subject: [PATCH 09/15] feat: implement has2be CertificateSigned handler --- .../has2be/certificate_signed_result.go | 21 +++++++++++++++++++ manager/mqtt/router.go | 9 ++++++++ .../ocpp/has2be/certificate_signed_request.go | 13 ++++++++++++ .../has2be/certificate_signed_response.go | 13 ++++++++++++ .../ocpp/has2be/sign_certificate_request.go | 5 ----- manager/ocpp/has2be/types.go | 5 +++++ 6 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 manager/handlers/has2be/certificate_signed_result.go create mode 100644 manager/ocpp/has2be/certificate_signed_request.go create mode 100644 manager/ocpp/has2be/certificate_signed_response.go diff --git a/manager/handlers/has2be/certificate_signed_result.go b/manager/handlers/has2be/certificate_signed_result.go new file mode 100644 index 0000000..ba56b49 --- /dev/null +++ b/manager/handlers/has2be/certificate_signed_result.go @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: Apache-2.0 + +package has2be + +import ( + "context" + + "github.com/thoughtworks/maeve-csms/manager/ocpp" + "github.com/thoughtworks/maeve-csms/manager/ocpp/has2be" + "golang.org/x/exp/slog" +) + +type CertificateSignedResultHandler struct{} + +func (c CertificateSignedResultHandler) HandleCallResult(ctx context.Context, chargeStationId string, request ocpp.Request, response ocpp.Response, state any) error { + resp := response.(*has2be.CertificateSignedResponseJson) + + slog.Info("certificate signed response", slog.Any("status", resp.Status)) + + return nil +} diff --git a/manager/mqtt/router.go b/manager/mqtt/router.go index b580029..b957724 100644 --- a/manager/mqtt/router.go +++ b/manager/mqtt/router.go @@ -221,6 +221,15 @@ func NewV16Router(emitter Emitter, Handler: handlers201.CertificateSignedResultHandler{}, }, }, + "iso15118": { // has2be extensions + "CertificateSigned": { + NewRequest: func() ocpp.Request { return new(has2be.CertificateSignedRequestJson) }, + NewResponse: func() ocpp.Response { return new(has2be.CertificateSignedResponseJson) }, + RequestSchema: "has2be/CertificateSignedRequest.json", + ResponseSchema: "has2be/CertificateSignedResponse.json", + Handler: handlersHasToBe.CertificateSignedResultHandler{}, + }, + }, }, }, }, diff --git a/manager/ocpp/has2be/certificate_signed_request.go b/manager/ocpp/has2be/certificate_signed_request.go new file mode 100644 index 0000000..c560de7 --- /dev/null +++ b/manager/ocpp/has2be/certificate_signed_request.go @@ -0,0 +1,13 @@ +package has2be + +type CertificateSignedRequestJson struct { + // The signed X.509 certificate, first DER encoded into binary, and then hex + // encoded into a case insensitive string. This can also contain the necessary sub + // CA certificates. In that case, the order should follow the certificate chain, + // starting from the leaf certificate. + + // TypeOfCertificate corresponds to the JSON schema field "typeOfCertificate". + TypeOfCertificate CertificateSigningUseEnumType `json:"typeOfCertificate" yaml:"typeOfCertificate" mapstructure:"typeOfCertificate"` +} + +func (*CertificateSignedRequestJson) IsRequest() {} diff --git a/manager/ocpp/has2be/certificate_signed_response.go b/manager/ocpp/has2be/certificate_signed_response.go new file mode 100644 index 0000000..41faa8d --- /dev/null +++ b/manager/ocpp/has2be/certificate_signed_response.go @@ -0,0 +1,13 @@ +package has2be + +type CertificateSignedStatusEnumType string + +type CertificateSignedResponseJson struct { + // Status corresponds to the JSON schema field "status". + Status CertificateSignedStatusEnumType `json:"status" yaml:"status" mapstructure:"status"` +} + +const CertificateSignedStatusEnumTypeAccepted CertificateSignedStatusEnumType = "Accepted" +const CertificateSignedStatusEnumTypeRejected CertificateSignedStatusEnumType = "Rejected" + +func (*CertificateSignedResponseJson) IsResponse() {} diff --git a/manager/ocpp/has2be/sign_certificate_request.go b/manager/ocpp/has2be/sign_certificate_request.go index 371629e..293fbfa 100644 --- a/manager/ocpp/has2be/sign_certificate_request.go +++ b/manager/ocpp/has2be/sign_certificate_request.go @@ -1,10 +1,5 @@ package has2be -type CertificateSigningUseEnumType string - -const CertificateSigningUseEnumTypeChargingStationCertificate CertificateSigningUseEnumType = "ChargingStationCertificate" -const CertificateSigningUseEnumTypeV2GCertificate CertificateSigningUseEnumType = "V2GCertificate" - type SignCertificateRequestJson struct { // The Charging Station SHALL send the public key in form of a Certificate Signing // Request (CSR) as described in the X.509 standard. diff --git a/manager/ocpp/has2be/types.go b/manager/ocpp/has2be/types.go index 3af19e2..997b5dc 100644 --- a/manager/ocpp/has2be/types.go +++ b/manager/ocpp/has2be/types.go @@ -6,6 +6,11 @@ const HashAlgorithmEnumTypeSHA256 HashAlgorithmEnumType = "SHA256" const HashAlgorithmEnumTypeSHA384 HashAlgorithmEnumType = "SHA384" const HashAlgorithmEnumTypeSHA512 HashAlgorithmEnumType = "SHA512" +type CertificateSigningUseEnumType string + +const CertificateSigningUseEnumTypeChargingStationCertificate CertificateSigningUseEnumType = "ChargingStationCertificate" +const CertificateSigningUseEnumTypeV2GCertificate CertificateSigningUseEnumType = "V2GCertificate" + type OCSPRequestDataType struct { // HashAlgorithm corresponds to the JSON schema field "hashAlgorithm". HashAlgorithm HashAlgorithmEnumType `json:"hashAlgorithm" yaml:"hashAlgorithm" mapstructure:"hashAlgorithm"` From 7de274309c7a3ac68a4d7e41153974d19ab6329e Mon Sep 17 00:00:00 2001 From: Gesa Stupperich Date: Mon, 14 Aug 2023 20:52:08 +0100 Subject: [PATCH 10/15] fix: add SPDX-License-Identifier --- manager/ocpp/has2be/authorize_request.go | 2 ++ manager/ocpp/has2be/authorize_response.go | 2 ++ manager/ocpp/has2be/certificate_signed_request.go | 2 ++ manager/ocpp/has2be/certificate_signed_response.go | 2 ++ manager/ocpp/has2be/get_15118_ev_certificate_request.go | 2 ++ manager/ocpp/has2be/get_15118_ev_certificate_response.go | 2 ++ manager/ocpp/has2be/get_certificate_status_request.go | 2 ++ manager/ocpp/has2be/get_certificate_status_response.go | 2 ++ manager/ocpp/has2be/sign_certificate_request.go | 2 ++ manager/ocpp/has2be/sign_certificate_response.go | 2 ++ manager/ocpp/has2be/types.go | 2 ++ 11 files changed, 22 insertions(+) diff --git a/manager/ocpp/has2be/authorize_request.go b/manager/ocpp/has2be/authorize_request.go index ea36e3e..7674a43 100644 --- a/manager/ocpp/has2be/authorize_request.go +++ b/manager/ocpp/has2be/authorize_request.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type IdTokenEnumType string diff --git a/manager/ocpp/has2be/authorize_response.go b/manager/ocpp/has2be/authorize_response.go index be72e5a..f5882de 100644 --- a/manager/ocpp/has2be/authorize_response.go +++ b/manager/ocpp/has2be/authorize_response.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type AuthorizationStatusEnumType string diff --git a/manager/ocpp/has2be/certificate_signed_request.go b/manager/ocpp/has2be/certificate_signed_request.go index c560de7..c965f91 100644 --- a/manager/ocpp/has2be/certificate_signed_request.go +++ b/manager/ocpp/has2be/certificate_signed_request.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type CertificateSignedRequestJson struct { diff --git a/manager/ocpp/has2be/certificate_signed_response.go b/manager/ocpp/has2be/certificate_signed_response.go index 41faa8d..cceb3eb 100644 --- a/manager/ocpp/has2be/certificate_signed_response.go +++ b/manager/ocpp/has2be/certificate_signed_response.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type CertificateSignedStatusEnumType string diff --git a/manager/ocpp/has2be/get_15118_ev_certificate_request.go b/manager/ocpp/has2be/get_15118_ev_certificate_request.go index b8c1d0c..f4692c4 100644 --- a/manager/ocpp/has2be/get_15118_ev_certificate_request.go +++ b/manager/ocpp/has2be/get_15118_ev_certificate_request.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type Get15118EVCertificateRequestJson struct { diff --git a/manager/ocpp/has2be/get_15118_ev_certificate_response.go b/manager/ocpp/has2be/get_15118_ev_certificate_response.go index a8c92bc..46dfc37 100644 --- a/manager/ocpp/has2be/get_15118_ev_certificate_response.go +++ b/manager/ocpp/has2be/get_15118_ev_certificate_response.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type Iso15118EVCertificateStatusEnumType string diff --git a/manager/ocpp/has2be/get_certificate_status_request.go b/manager/ocpp/has2be/get_certificate_status_request.go index 39dcd27..e7ad325 100644 --- a/manager/ocpp/has2be/get_certificate_status_request.go +++ b/manager/ocpp/has2be/get_certificate_status_request.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type GetCertificateStatusRequestJson struct { diff --git a/manager/ocpp/has2be/get_certificate_status_response.go b/manager/ocpp/has2be/get_certificate_status_response.go index 8e1708a..b2a601f 100644 --- a/manager/ocpp/has2be/get_certificate_status_response.go +++ b/manager/ocpp/has2be/get_certificate_status_response.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type GetCertificateStatusEnumType string diff --git a/manager/ocpp/has2be/sign_certificate_request.go b/manager/ocpp/has2be/sign_certificate_request.go index 293fbfa..f1e41d3 100644 --- a/manager/ocpp/has2be/sign_certificate_request.go +++ b/manager/ocpp/has2be/sign_certificate_request.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type SignCertificateRequestJson struct { diff --git a/manager/ocpp/has2be/sign_certificate_response.go b/manager/ocpp/has2be/sign_certificate_response.go index 97afad9..c1282b8 100644 --- a/manager/ocpp/has2be/sign_certificate_response.go +++ b/manager/ocpp/has2be/sign_certificate_response.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type GenericStatusEnumType string diff --git a/manager/ocpp/has2be/types.go b/manager/ocpp/has2be/types.go index 997b5dc..815b46a 100644 --- a/manager/ocpp/has2be/types.go +++ b/manager/ocpp/has2be/types.go @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + package has2be type HashAlgorithmEnumType string From 5d2cf38bb33a08618c093bdd3d560f697bd72bbb Mon Sep 17 00:00:00 2001 From: Gesa Stupperich Date: Mon, 14 Aug 2023 21:01:02 +0100 Subject: [PATCH 11/15] fix: instrument CertificateSigned handler with Open Telemetry instead of slog --- manager/handlers/has2be/certificate_signed_result.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/manager/handlers/has2be/certificate_signed_result.go b/manager/handlers/has2be/certificate_signed_result.go index ba56b49..cef7a27 100644 --- a/manager/handlers/has2be/certificate_signed_result.go +++ b/manager/handlers/has2be/certificate_signed_result.go @@ -4,18 +4,21 @@ package has2be import ( "context" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" "github.com/thoughtworks/maeve-csms/manager/ocpp" "github.com/thoughtworks/maeve-csms/manager/ocpp/has2be" - "golang.org/x/exp/slog" ) type CertificateSignedResultHandler struct{} func (c CertificateSignedResultHandler) HandleCallResult(ctx context.Context, chargeStationId string, request ocpp.Request, response ocpp.Response, state any) error { + span := trace.SpanFromContext(ctx) + resp := response.(*has2be.CertificateSignedResponseJson) - slog.Info("certificate signed response", slog.Any("status", resp.Status)) + span.SetAttributes(attribute.String("response.status", string(resp.Status))) return nil } From 17576e59ccce3184cff79dfea730042217692c6a Mon Sep 17 00:00:00 2001 From: Gesa Stupperich Date: Tue, 15 Aug 2023 08:26:51 +0100 Subject: [PATCH 12/15] fix: decode Csr before passing it on if it's base64-encoded --- manager/handlers/has2be/sign_certificate.go | 32 +++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/manager/handlers/has2be/sign_certificate.go b/manager/handlers/has2be/sign_certificate.go index 14ff4db..73e91db 100644 --- a/manager/handlers/has2be/sign_certificate.go +++ b/manager/handlers/has2be/sign_certificate.go @@ -4,10 +4,14 @@ package has2be import ( "context" + "encoding/base64" + "encoding/pem" handlers201 "github.com/thoughtworks/maeve-csms/manager/handlers/ocpp201" "github.com/thoughtworks/maeve-csms/manager/ocpp" typesHasToBe "github.com/thoughtworks/maeve-csms/manager/ocpp/has2be" types201 "github.com/thoughtworks/maeve-csms/manager/ocpp/ocpp201" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" ) type SignCertificateHandler struct { @@ -15,15 +19,23 @@ type SignCertificateHandler struct { } func (s SignCertificateHandler) HandleCall(ctx context.Context, chargeStationId string, request ocpp.Request) (ocpp.Response, error) { + span := trace.SpanFromContext(ctx) + req := request.(*typesHasToBe.SignCertificateRequestJson) + csr, inputFormat, err := normalizeCsrEncoding(req.Csr) + if err != nil { + return nil, err + } + span.SetAttributes(attribute.String("sign_certificate.input_format", inputFormat)) + req201 := &types201.SignCertificateRequestJson{ - Csr: req.Csr, + Csr: csr, } if req.TypeOfCertificate != nil { req201 = &types201.SignCertificateRequestJson{ - Csr: req.Csr, + Csr: csr, CertificateType: (*types201.CertificateSigningUseEnumType)(req.TypeOfCertificate), } } @@ -38,3 +50,19 @@ func (s SignCertificateHandler) HandleCall(ctx context.Context, chargeStationId Status: typesHasToBe.GenericStatusEnumType(res201.Status), }, nil } + +func normalizeCsrEncoding(csr string) (string, string, error) { + if pemDecoded, _ := pem.Decode([]byte(csr)); pemDecoded == nil { + base64Decoded, err := base64.StdEncoding.DecodeString(csr) + if err != nil { + return "", "", err + } + pemBlock := pem.Block{ + Type: "CERTIFICATE REQUEST", + Bytes: base64Decoded, + } + csr = string(pem.EncodeToMemory(&pemBlock)) + return csr, "base64", nil + } + return csr, "pem", nil +} From ba9857d062dc0c65fffcd29151318914af563403 Mon Sep 17 00:00:00 2001 From: Gesa Stupperich Date: Mon, 21 Aug 2023 08:34:35 +0100 Subject: [PATCH 13/15] fix: add a test for has2be SignCertificate --- manager/handlers/has2be/authorize.go | 4 +- .../has2be/get_15118_ev_certificate.go | 4 +- .../handlers/has2be/get_certificate_status.go | 4 +- manager/handlers/has2be/sign_certificate.go | 12 ++- .../handlers/has2be/sign_certificate_test.go | 81 +++++++++++++++++++ 5 files changed, 95 insertions(+), 10 deletions(-) diff --git a/manager/handlers/has2be/authorize.go b/manager/handlers/has2be/authorize.go index a96fcac..0dbf981 100644 --- a/manager/handlers/has2be/authorize.go +++ b/manager/handlers/has2be/authorize.go @@ -4,14 +4,14 @@ package has2be import ( "context" - handlers201 "github.com/thoughtworks/maeve-csms/manager/handlers/ocpp201" + "github.com/thoughtworks/maeve-csms/manager/handlers" "github.com/thoughtworks/maeve-csms/manager/ocpp" typesHasToBe "github.com/thoughtworks/maeve-csms/manager/ocpp/has2be" types201 "github.com/thoughtworks/maeve-csms/manager/ocpp/ocpp201" ) type AuthorizeHandler struct { - Handler201 handlers201.AuthorizeHandler + Handler201 handlers.CallHandler } func (a AuthorizeHandler) HandleCall(ctx context.Context, chargeStationId string, request ocpp.Request) (ocpp.Response, error) { diff --git a/manager/handlers/has2be/get_15118_ev_certificate.go b/manager/handlers/has2be/get_15118_ev_certificate.go index 84d3dbf..0325887 100644 --- a/manager/handlers/has2be/get_15118_ev_certificate.go +++ b/manager/handlers/has2be/get_15118_ev_certificate.go @@ -4,14 +4,14 @@ package has2be import ( "context" - handlers201 "github.com/thoughtworks/maeve-csms/manager/handlers/ocpp201" + "github.com/thoughtworks/maeve-csms/manager/handlers" "github.com/thoughtworks/maeve-csms/manager/ocpp" typesHasToBe "github.com/thoughtworks/maeve-csms/manager/ocpp/has2be" types201 "github.com/thoughtworks/maeve-csms/manager/ocpp/ocpp201" ) type Get15118EvCertificateHandler struct { - Handler201 handlers201.Get15118EvCertificateHandler + Handler201 handlers.CallHandler } func (g Get15118EvCertificateHandler) HandleCall(ctx context.Context, _ string, request ocpp.Request) (ocpp.Response, error) { diff --git a/manager/handlers/has2be/get_certificate_status.go b/manager/handlers/has2be/get_certificate_status.go index 5c2bb0a..31a37fe 100644 --- a/manager/handlers/has2be/get_certificate_status.go +++ b/manager/handlers/has2be/get_certificate_status.go @@ -4,14 +4,14 @@ package has2be import ( "context" - handlers201 "github.com/thoughtworks/maeve-csms/manager/handlers/ocpp201" + "github.com/thoughtworks/maeve-csms/manager/handlers" "github.com/thoughtworks/maeve-csms/manager/ocpp" typesHasToBe "github.com/thoughtworks/maeve-csms/manager/ocpp/has2be" types201 "github.com/thoughtworks/maeve-csms/manager/ocpp/ocpp201" ) type GetCertificateStatusHandler struct { - Handler201 handlers201.GetCertificateStatusHandler + Handler201 handlers.CallHandler } func (g GetCertificateStatusHandler) HandleCall(ctx context.Context, chargeStationId string, request ocpp.Request) (ocpp.Response, error) { diff --git a/manager/handlers/has2be/sign_certificate.go b/manager/handlers/has2be/sign_certificate.go index 73e91db..88b7ac9 100644 --- a/manager/handlers/has2be/sign_certificate.go +++ b/manager/handlers/has2be/sign_certificate.go @@ -6,7 +6,8 @@ import ( "context" "encoding/base64" "encoding/pem" - handlers201 "github.com/thoughtworks/maeve-csms/manager/handlers/ocpp201" + + "github.com/thoughtworks/maeve-csms/manager/handlers" "github.com/thoughtworks/maeve-csms/manager/ocpp" typesHasToBe "github.com/thoughtworks/maeve-csms/manager/ocpp/has2be" types201 "github.com/thoughtworks/maeve-csms/manager/ocpp/ocpp201" @@ -15,7 +16,7 @@ import ( ) type SignCertificateHandler struct { - Handler201 handlers201.SignCertificateHandler + Handler201 handlers.CallHandler } func (s SignCertificateHandler) HandleCall(ctx context.Context, chargeStationId string, request ocpp.Request) (ocpp.Response, error) { @@ -24,6 +25,7 @@ func (s SignCertificateHandler) HandleCall(ctx context.Context, chargeStationId req := request.(*typesHasToBe.SignCertificateRequestJson) csr, inputFormat, err := normalizeCsrEncoding(req.Csr) + if err != nil { return nil, err } @@ -53,16 +55,18 @@ func (s SignCertificateHandler) HandleCall(ctx context.Context, chargeStationId func normalizeCsrEncoding(csr string) (string, string, error) { if pemDecoded, _ := pem.Decode([]byte(csr)); pemDecoded == nil { - base64Decoded, err := base64.StdEncoding.DecodeString(csr) + // not PEM encoded, assume base64-encoded DER + der, err := base64.StdEncoding.DecodeString(csr) if err != nil { return "", "", err } pemBlock := pem.Block{ Type: "CERTIFICATE REQUEST", - Bytes: base64Decoded, + Bytes: der, } csr = string(pem.EncodeToMemory(&pemBlock)) return csr, "base64", nil } + return csr, "pem", nil } diff --git a/manager/handlers/has2be/sign_certificate_test.go b/manager/handlers/has2be/sign_certificate_test.go index e7982f0..f56efb9 100644 --- a/manager/handlers/has2be/sign_certificate_test.go +++ b/manager/handlers/has2be/sign_certificate_test.go @@ -1,3 +1,84 @@ // SPDX-License-Identifier: Apache-2.0 package has2be_test + +import ( + "context" + "encoding/base64" + "encoding/pem" + "github.com/stretchr/testify/assert" + handlersHasToBe "github.com/thoughtworks/maeve-csms/manager/handlers/has2be" + "github.com/thoughtworks/maeve-csms/manager/ocpp" + typesHasToBe "github.com/thoughtworks/maeve-csms/manager/ocpp/has2be" + types201 "github.com/thoughtworks/maeve-csms/manager/ocpp/ocpp201" + "testing" +) + +type spy201SignCertificateHandler struct { + RecordedCsr *string +} + +func (d spy201SignCertificateHandler) HandleCall(ctx context.Context, chargeStationId string, request ocpp.Request) (ocpp.Response, error) { + d.recordReceivedCsr(request.(*types201.SignCertificateRequestJson).Csr) + return &types201.SignCertificateResponseJson{ + Status: types201.GenericStatusEnumTypeAccepted, + }, nil +} + +func (d *spy201SignCertificateHandler) recordReceivedCsr(csr string) { + *d.RecordedCsr = csr +} + +var csrBytes = []byte("some-csr") +var pemEncodedCsr = string(pem.EncodeToMemory(&pem.Block{ + Type: "CERTIFICATE REQUEST", + Bytes: csrBytes, +})) + +func TestPassesPEMEncodedCsrOnAsIs(t *testing.T) { + // it would be preferable to mock the dependencies of the 201 handler instead of the handler itself + // however, the 201 handler calls its dependencies from a go routine, but the things I tried in making the test wait + // for the go routine to finish (like passing a waitgroup into the mocked dependencies and calling wg.Done from + // its methods) didn't work + csrRecorder := "" + spy201Handler := spy201SignCertificateHandler{ + RecordedCsr: &csrRecorder, + } + handler := handlersHasToBe.SignCertificateHandler{ + Handler201: spy201Handler, + } + req := &typesHasToBe.SignCertificateRequestJson{ + Csr: pemEncodedCsr, + } + + _, err := handler.HandleCall(context.Background(), "cs001", req) + if err != nil { + t.Errorf("unexpected error %v", err) + } + + want := pemEncodedCsr + got := *spy201Handler.RecordedCsr + assert.Equal(t, want, got) +} + +func TestDecodesBase64EncodedDERAndReencodesAsPEM(t *testing.T) { + csrRecorder := "" + spy201Handler := spy201SignCertificateHandler{ + RecordedCsr: &csrRecorder, + } + handler := handlersHasToBe.SignCertificateHandler{ + Handler201: spy201Handler, + } + req := &typesHasToBe.SignCertificateRequestJson{ + Csr: base64.StdEncoding.EncodeToString(csrBytes), + } + + _, err := handler.HandleCall(context.Background(), "cs001", req) + if err != nil { + t.Errorf("unexpected error %v", err) + } + + want := pemEncodedCsr + got := *spy201Handler.RecordedCsr + assert.Equal(t, want, got) +} From 2369cab5b7e7fadc6d40fa2e3f904976b425a8aa Mon Sep 17 00:00:00 2001 From: Gesa Stupperich Date: Mon, 28 Aug 2023 14:38:29 +0100 Subject: [PATCH 14/15] fix: add has2be.CertificateSignedRequest to callmaker actions --- manager/mqtt/router.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manager/mqtt/router.go b/manager/mqtt/router.go index b957724..2db7980 100644 --- a/manager/mqtt/router.go +++ b/manager/mqtt/router.go @@ -49,6 +49,10 @@ func NewV16Router(emitter Emitter, VendorId: "org.openchargealliance.iso15118pnc", MessageId: "CertificateSigned", }, + reflect.TypeOf(&has2be.CertificateSignedRequestJson{}): { + VendorId: "iso15118", + MessageId: "CertificateSigned", + }, }, } From 3f7127d3ff448249ab78e48208fe15b7ec2e8da1 Mon Sep 17 00:00:00 2001 From: Dale Peakall Date: Tue, 29 Aug 2023 16:20:48 +0100 Subject: [PATCH 15/15] refactor: remove a few warnings --- manager/handlers/has2be/certificate_signed_result.go | 2 +- manager/handlers/has2be/get_15118_ev_certificate.go | 4 ++-- manager/handlers/has2be/sign_certificate_test.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manager/handlers/has2be/certificate_signed_result.go b/manager/handlers/has2be/certificate_signed_result.go index cef7a27..cbf8d4f 100644 --- a/manager/handlers/has2be/certificate_signed_result.go +++ b/manager/handlers/has2be/certificate_signed_result.go @@ -13,7 +13,7 @@ import ( type CertificateSignedResultHandler struct{} -func (c CertificateSignedResultHandler) HandleCallResult(ctx context.Context, chargeStationId string, request ocpp.Request, response ocpp.Response, state any) error { +func (c CertificateSignedResultHandler) HandleCallResult(ctx context.Context, _ string, _ ocpp.Request, response ocpp.Response, _ any) error { span := trace.SpanFromContext(ctx) resp := response.(*has2be.CertificateSignedResponseJson) diff --git a/manager/handlers/has2be/get_15118_ev_certificate.go b/manager/handlers/has2be/get_15118_ev_certificate.go index 0325887..4a5349f 100644 --- a/manager/handlers/has2be/get_15118_ev_certificate.go +++ b/manager/handlers/has2be/get_15118_ev_certificate.go @@ -14,7 +14,7 @@ type Get15118EvCertificateHandler struct { Handler201 handlers.CallHandler } -func (g Get15118EvCertificateHandler) HandleCall(ctx context.Context, _ string, request ocpp.Request) (ocpp.Response, error) { +func (g Get15118EvCertificateHandler) HandleCall(ctx context.Context, chargeStationId string, request ocpp.Request) (ocpp.Response, error) { req := request.(*typesHasToBe.Get15118EVCertificateRequestJson) req201 := types201.Get15118EVCertificateRequestJson{ @@ -24,7 +24,7 @@ func (g Get15118EvCertificateHandler) HandleCall(ctx context.Context, _ string, Action: types201.CertificateActionEnumTypeInstall, } - res, err := g.Handler201.HandleCall(ctx, "", &req201) + res, err := g.Handler201.HandleCall(ctx, chargeStationId, &req201) if err != nil { return nil, err } diff --git a/manager/handlers/has2be/sign_certificate_test.go b/manager/handlers/has2be/sign_certificate_test.go index f56efb9..6b93d8b 100644 --- a/manager/handlers/has2be/sign_certificate_test.go +++ b/manager/handlers/has2be/sign_certificate_test.go @@ -18,7 +18,7 @@ type spy201SignCertificateHandler struct { RecordedCsr *string } -func (d spy201SignCertificateHandler) HandleCall(ctx context.Context, chargeStationId string, request ocpp.Request) (ocpp.Response, error) { +func (d *spy201SignCertificateHandler) HandleCall(_ context.Context, _ string, request ocpp.Request) (ocpp.Response, error) { d.recordReceivedCsr(request.(*types201.SignCertificateRequestJson).Csr) return &types201.SignCertificateResponseJson{ Status: types201.GenericStatusEnumTypeAccepted, @@ -45,7 +45,7 @@ func TestPassesPEMEncodedCsrOnAsIs(t *testing.T) { RecordedCsr: &csrRecorder, } handler := handlersHasToBe.SignCertificateHandler{ - Handler201: spy201Handler, + Handler201: &spy201Handler, } req := &typesHasToBe.SignCertificateRequestJson{ Csr: pemEncodedCsr, @@ -67,7 +67,7 @@ func TestDecodesBase64EncodedDERAndReencodesAsPEM(t *testing.T) { RecordedCsr: &csrRecorder, } handler := handlersHasToBe.SignCertificateHandler{ - Handler201: spy201Handler, + Handler201: &spy201Handler, } req := &typesHasToBe.SignCertificateRequestJson{ Csr: base64.StdEncoding.EncodeToString(csrBytes),