From d9524745e59d276d0039a420debe8dd43b1ff7c1 Mon Sep 17 00:00:00 2001 From: Wout Slakhorst Date: Wed, 29 Nov 2023 15:59:23 +0100 Subject: [PATCH] added VDR v2 spec, generated code and empty wrapper --- codegen/configs/vdr_v2.yaml | 13 + docs/_static/vdr/v2.yaml | 268 +++++ makefile | 1 + vdr/api/v1/types.go | 4 +- vdr/api/v2/api.go | 79 ++ vdr/api/v2/generated.go | 1996 +++++++++++++++++++++++++++++++++++ vdr/api/v2/types.go | 35 + 7 files changed, 2395 insertions(+), 1 deletion(-) create mode 100644 codegen/configs/vdr_v2.yaml create mode 100644 docs/_static/vdr/v2.yaml create mode 100644 vdr/api/v2/api.go create mode 100644 vdr/api/v2/generated.go create mode 100644 vdr/api/v2/types.go diff --git a/codegen/configs/vdr_v2.yaml b/codegen/configs/vdr_v2.yaml new file mode 100644 index 0000000000..6da94fe17d --- /dev/null +++ b/codegen/configs/vdr_v2.yaml @@ -0,0 +1,13 @@ +package: v2 +generate: + echo-server: true + client: true + models: true + strict-server: true +output-options: + skip-prune: true + exclude-schemas: + - DIDDocument + - DIDDocumentMetadata + - Service + - VerificationMethod diff --git a/docs/_static/vdr/v2.yaml b/docs/_static/vdr/v2.yaml new file mode 100644 index 0000000000..63fdb1aea1 --- /dev/null +++ b/docs/_static/vdr/v2.yaml @@ -0,0 +1,268 @@ +openapi: "3.0.0" +info: + title: Nuts Verifiable Data Registry API spec + description: API specification for the Verifiable Data Registry + version: 2.0.0 + license: + name: GPLv3 +servers: + - url: http://localhost:1323 +paths: + /internal/vdr/v2/did: + post: + summary: Creates a new Web DID + description: | + A new web DID is created. Only the DID is returned. The DID document can be retrieved using the DID resolution endpoint. + A single key pair is generated and added to the DID document. The key pair is used for all verificationMethods. + No services are added. The PublicURL needs to be configured. + + error returns: + * 412 - PublicURL is not configured + * 500 - An error occurred while processing the request + operationId: "createDID" + tags: + - DID + responses: + "200": + description: "New DID has been created successfully. Returns the DID document." + content: + application/json: + schema: + $ref: '#/components/schemas/DIDDocument' + default: + $ref: '../common/error_response.yaml' + /internal/vdr/v2/did/{did}: + parameters: + - name: did + in: path + description: URL encoded DID. + required: true + example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b + schema: + type: string + get: + summary: "Resolves a DID document" + description: | + Resolves a DID document. + + error returns: + * 400 - Returned in case of malformed DID + * 404 - Corresponding DID document could not be found + * 500 - An error occurred while processing the request + operationId: "resolveDID" + tags: + - DID + responses: + "200": + description: DID document has been found and returned. + content: + application/json: + schema: + $ref: '#/components/schemas/DIDResolutionResult' + default: + $ref: '../common/error_response.yaml' + delete: + summary: Deleted the web DID Document. + description: | + + error returns: + * 400 - the DID param was malformed + * 404 - Corresponding DID document could not be found + * 500 - An error occurred while processing the request + operationId: "deleteDID" + tags: + - DID + responses: + "204": + description: DID document has been deactivated. + default: + $ref: '../common/error_response.yaml' + /internal/vdr/v2/did/{did}/service: + parameters: + - name: did + in: path + description: URL encoded DID. + required: true + example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b + schema: + type: string + post: + summary: Adds a service to the DID document. + description: | + It adds the given service to the DID Document. The ID will be generated and replaced. + + error returns: + * 400 - Returned in case of malformed DID or service + * 404 - Corresponding DID document could not be found + * 500 - An error occurred while processing the request + parameters: + - name: service + in: body + description: Service to be added to the DID document. + required: true + schema: + $ref: '#/components/schemas/Service' + operationId: addService + tags: + - DID + responses: + "200": + description: "New verification method has been created and added successfully. Returns the verification method." + content: + application/json: + schema: + $ref: '#/components/schemas/VerificationMethod' + default: + $ref: '../common/error_response.yaml' + /internal/vdr/v2/did/{did}/service/{id}: + parameters: + - name: did + in: path + description: URL encoded DID. + required: true + example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b + schema: + type: string + - name: id + in: path + description: URL encoded id identifying the service. + required: true + example: "did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b#3106f751-59e3-440f-b57b-39a96a2da6c6" + schema: + type: string + delete: + summary: Delete a specific service + description: | + Removes the service from the DID Document. + No cascading will happen for references to the service. + + error returns: + * 404 - Corresponding DID document or verification method could not be found + * 500 - An error occurred while processing the request + tags: + - DID + operationId: deleteService + responses: + "204": + description: Verification Method was successfully deleted + default: + $ref: '../common/error_response.yaml' + put: + summary: Updates a service in the DID document. + description: | + It updates the given service in the DID Document. The ID will remain the same. + + error returns: + * 400 - Returned in case of malformed DID or service + * 404 - Corresponding DID document could not be found + * 500 - An error occurred while processing the request + tags: + - DID + operationId: updateService + parameters: + - name: service + in: body + description: Service to be added to the DID document. + required: true + schema: + $ref: '#/components/schemas/Service' + responses: + "200": + description: "Service has been updated successfully. Returns the service." + content: + application/json: + schema: + $ref: '#/components/schemas/Service' + default: + $ref: '../common/error_response.yaml' + /internal/vdr/v2/did/{did}/verificationmethod: + parameters: + - name: did + in: path + description: URL encoded DID. + required: true + example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b + schema: + type: string + post: + summary: Creates and adds a new verificationMethod to the DID document. + description: | + It creates a new private public keypair. The public key is wrapped in verificationMethod. This method is added to the DID Document. + The key pair is used for all verificationMethods. + + error returns: + * 404 - Corresponding DID document could not be found + * 500 - An error occurred while processing the request + operationId: addVerificationMethod + tags: + - DID + responses: + "200": + description: "New verification method has been created and added successfully. Returns the verification method." + content: + application/json: + schema: + $ref: '#/components/schemas/VerificationMethod' + default: + $ref: '../common/error_response.yaml' + /internal/vdr/v2/did/{did}/verificationmethod/{kid}: + parameters: + - name: did + in: path + description: URL encoded DID. + required: true + example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b + schema: + type: string + - name: kid + in: path + description: URL encoded kid identifying the verification method. + required: true + example: "did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b#3106f751-59e3-440f-b57b-39a96a2da6c6" + schema: + type: string + delete: + summary: Delete a specific verification method + description: | + Removes the verification method from the DID Document. + Revokes the public key with the corresponding key-id. + Note: Other verification methods with different key-ids with the same private key will still be valid. + + error returns: + * 404 - Corresponding DID document or verification method could not be found + * 500 - An error occurred while processing the request + tags: + - DID + operationId: deleteVerificationMethod + responses: + "204": + description: Verification Method was successfully deleted + default: + $ref: '../common/error_response.yaml' +components: + schemas: + DIDDocument: + $ref: '../common/ssi_types.yaml#/components/schemas/DIDDocument' + DIDDocumentMetadata: + $ref: '../common/ssi_types.yaml#/components/schemas/DIDDocumentMetadata' + VerificationMethod: + $ref: '../common/ssi_types.yaml#/components/schemas/VerificationMethod' + Service: + $ref: '../common/ssi_types.yaml#/components/schemas/Service' + DIDResolutionResult: + required: + - document + - documentMetadata + properties: + document: + $ref: '#/components/schemas/DIDDocument' + documentMetadata: + $ref: '#/components/schemas/DIDDocumentMetadata' + securitySchemes: + jwtBearerAuth: + type: http + scheme: bearer + +security: + - {} + - jwtBearerAuth: [] diff --git a/makefile b/makefile index 31b5d65065..28b5480ef5 100644 --- a/makefile +++ b/makefile @@ -59,6 +59,7 @@ gen-api: oapi-codegen --config codegen/configs/common_ssi_types.yaml docs/_static/common/ssi_types.yaml | gofmt > api/ssi_types.go oapi-codegen --config codegen/configs/crypto_v1.yaml -package v1 docs/_static/crypto/v1.yaml | gofmt > crypto/api/v1/generated.go oapi-codegen --config codegen/configs/vdr_v1.yaml docs/_static/vdr/v1.yaml | gofmt > vdr/api/v1/generated.go + oapi-codegen --config codegen/configs/vdr_v2.yaml docs/_static/vdr/v2.yaml | gofmt > vdr/api/v2/generated.go oapi-codegen --config codegen/configs/network_v1.yaml docs/_static/network/v1.yaml | gofmt > network/api/v1/generated.go oapi-codegen --config codegen/configs/vcr_v2.yaml docs/_static/vcr/vcr_v2.yaml | gofmt > vcr/api/vcr/v2/generated.go oapi-codegen --config codegen/configs/vcr_openid4vci_v0.yaml docs/_static/vcr/openid4vci_v0.yaml | gofmt > vcr/api/openid4vci/v0/generated.go diff --git a/vdr/api/v1/types.go b/vdr/api/v1/types.go index 495533ecb2..6d99b01a05 100644 --- a/vdr/api/v1/types.go +++ b/vdr/api/v1/types.go @@ -1,14 +1,16 @@ /* - * Nuts node * Copyright (C) 2021 Nuts community + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ diff --git a/vdr/api/v2/api.go b/vdr/api/v2/api.go new file mode 100644 index 0000000000..06300dc564 --- /dev/null +++ b/vdr/api/v2/api.go @@ -0,0 +1,79 @@ +/* + * Nuts node + * Copyright (C) 2021 Nuts community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package v2 + +import ( + "context" + "github.com/nuts-foundation/nuts-node/core" + "github.com/nuts-foundation/nuts-node/vdr" +) + +var _ StrictServerInterface = (*Wrapper)(nil) +var _ core.ErrorStatusCodeResolver = (*Wrapper)(nil) + +// Wrapper is needed to connect the implementation to the echo ServiceWrapper +type Wrapper struct { + VDR vdr.VDR +} + +func (w Wrapper) ResolveStatusCode(err error) int { + //TODO implement me + panic("implement me") +} + +func (w Wrapper) CreateDID(ctx context.Context, request CreateDIDRequestObject) (CreateDIDResponseObject, error) { + //TODO implement me + panic("implement me") +} + +func (w Wrapper) DeleteDID(ctx context.Context, request DeleteDIDRequestObject) (DeleteDIDResponseObject, error) { + //TODO implement me + panic("implement me") +} + +func (w Wrapper) ResolveDID(ctx context.Context, request ResolveDIDRequestObject) (ResolveDIDResponseObject, error) { + //TODO implement me + panic("implement me") +} + +func (w Wrapper) AddService(ctx context.Context, request AddServiceRequestObject) (AddServiceResponseObject, error) { + //TODO implement me + panic("implement me") +} + +func (w Wrapper) DeleteService(ctx context.Context, request DeleteServiceRequestObject) (DeleteServiceResponseObject, error) { + //TODO implement me + panic("implement me") +} + +func (w Wrapper) UpdateService(ctx context.Context, request UpdateServiceRequestObject) (UpdateServiceResponseObject, error) { + //TODO implement me + panic("implement me") +} + +func (w Wrapper) AddVerificationMethod(ctx context.Context, request AddVerificationMethodRequestObject) (AddVerificationMethodResponseObject, error) { + //TODO implement me + panic("implement me") +} + +func (w Wrapper) DeleteVerificationMethod(ctx context.Context, request DeleteVerificationMethodRequestObject) (DeleteVerificationMethodResponseObject, error) { + //TODO implement me + panic("implement me") +} diff --git a/vdr/api/v2/generated.go b/vdr/api/v2/generated.go new file mode 100644 index 0000000000..ca2abd7af4 --- /dev/null +++ b/vdr/api/v2/generated.go @@ -0,0 +1,1996 @@ +// Package v2 provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.0.0 DO NOT EDIT. +package v2 + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strings" + + "github.com/labstack/echo/v4" + "github.com/oapi-codegen/runtime" + strictecho "github.com/oapi-codegen/runtime/strictmiddleware/echo" +) + +const ( + JwtBearerAuthScopes = "jwtBearerAuth.Scopes" +) + +// DIDResolutionResult defines model for DIDResolutionResult. +type DIDResolutionResult struct { + // Document A DID document according to the W3C spec following the Nuts Method rules as defined in [Nuts RFC006] + Document DIDDocument `json:"document"` + + // DocumentMetadata The DID document metadata. + DocumentMetadata DIDDocumentMetadata `json:"documentMetadata"` +} + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // CreateDID request + CreateDID(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteDID request + DeleteDID(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ResolveDID request + ResolveDID(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddService request + AddService(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteService request + DeleteService(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateService request + UpdateService(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddVerificationMethod request + AddVerificationMethod(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteVerificationMethod request + DeleteVerificationMethod(ctx context.Context, did string, kid string, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) CreateDID(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateDIDRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteDID(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteDIDRequest(c.Server, did) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ResolveDID(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewResolveDIDRequest(c.Server, did) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) AddService(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddServiceRequest(c.Server, did) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteService(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteServiceRequest(c.Server, did, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateService(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateServiceRequest(c.Server, did, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) AddVerificationMethod(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddVerificationMethodRequest(c.Server, did) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteVerificationMethod(ctx context.Context, did string, kid string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteVerificationMethodRequest(c.Server, did, kid) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewCreateDIDRequest generates requests for CreateDID +func NewCreateDIDRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/internal/vdr/v2/did") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteDIDRequest generates requests for DeleteDID +func NewDeleteDIDRequest(server string, did string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "did", runtime.ParamLocationPath, did) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/internal/vdr/v2/did/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewResolveDIDRequest generates requests for ResolveDID +func NewResolveDIDRequest(server string, did string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "did", runtime.ParamLocationPath, did) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/internal/vdr/v2/did/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewAddServiceRequest generates requests for AddService +func NewAddServiceRequest(server string, did string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "did", runtime.ParamLocationPath, did) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/internal/vdr/v2/did/%s/service", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteServiceRequest generates requests for DeleteService +func NewDeleteServiceRequest(server string, did string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "did", runtime.ParamLocationPath, did) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/internal/vdr/v2/did/%s/service/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateServiceRequest generates requests for UpdateService +func NewUpdateServiceRequest(server string, did string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "did", runtime.ParamLocationPath, did) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/internal/vdr/v2/did/%s/service/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewAddVerificationMethodRequest generates requests for AddVerificationMethod +func NewAddVerificationMethodRequest(server string, did string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "did", runtime.ParamLocationPath, did) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/internal/vdr/v2/did/%s/verificationmethod", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteVerificationMethodRequest generates requests for DeleteVerificationMethod +func NewDeleteVerificationMethodRequest(server string, did string, kid string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "did", runtime.ParamLocationPath, did) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "kid", runtime.ParamLocationPath, kid) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/internal/vdr/v2/did/%s/verificationmethod/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // CreateDIDWithResponse request + CreateDIDWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CreateDIDResponse, error) + + // DeleteDIDWithResponse request + DeleteDIDWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*DeleteDIDResponse, error) + + // ResolveDIDWithResponse request + ResolveDIDWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*ResolveDIDResponse, error) + + // AddServiceWithResponse request + AddServiceWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*AddServiceResponse, error) + + // DeleteServiceWithResponse request + DeleteServiceWithResponse(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*DeleteServiceResponse, error) + + // UpdateServiceWithResponse request + UpdateServiceWithResponse(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*UpdateServiceResponse, error) + + // AddVerificationMethodWithResponse request + AddVerificationMethodWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*AddVerificationMethodResponse, error) + + // DeleteVerificationMethodWithResponse request + DeleteVerificationMethodWithResponse(ctx context.Context, did string, kid string, reqEditors ...RequestEditorFn) (*DeleteVerificationMethodResponse, error) +} + +type CreateDIDResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DIDDocument + ApplicationproblemJSONDefault *struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } +} + +// Status returns HTTPResponse.Status +func (r CreateDIDResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateDIDResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteDIDResponse struct { + Body []byte + HTTPResponse *http.Response + ApplicationproblemJSONDefault *struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } +} + +// Status returns HTTPResponse.Status +func (r DeleteDIDResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteDIDResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ResolveDIDResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DIDResolutionResult + ApplicationproblemJSONDefault *struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } +} + +// Status returns HTTPResponse.Status +func (r ResolveDIDResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ResolveDIDResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AddServiceResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *VerificationMethod + ApplicationproblemJSONDefault *struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } +} + +// Status returns HTTPResponse.Status +func (r AddServiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AddServiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteServiceResponse struct { + Body []byte + HTTPResponse *http.Response + ApplicationproblemJSONDefault *struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } +} + +// Status returns HTTPResponse.Status +func (r DeleteServiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteServiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateServiceResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Service + ApplicationproblemJSONDefault *struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } +} + +// Status returns HTTPResponse.Status +func (r UpdateServiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateServiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AddVerificationMethodResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *VerificationMethod + ApplicationproblemJSONDefault *struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } +} + +// Status returns HTTPResponse.Status +func (r AddVerificationMethodResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AddVerificationMethodResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteVerificationMethodResponse struct { + Body []byte + HTTPResponse *http.Response + ApplicationproblemJSONDefault *struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } +} + +// Status returns HTTPResponse.Status +func (r DeleteVerificationMethodResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteVerificationMethodResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// CreateDIDWithResponse request returning *CreateDIDResponse +func (c *ClientWithResponses) CreateDIDWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CreateDIDResponse, error) { + rsp, err := c.CreateDID(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateDIDResponse(rsp) +} + +// DeleteDIDWithResponse request returning *DeleteDIDResponse +func (c *ClientWithResponses) DeleteDIDWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*DeleteDIDResponse, error) { + rsp, err := c.DeleteDID(ctx, did, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteDIDResponse(rsp) +} + +// ResolveDIDWithResponse request returning *ResolveDIDResponse +func (c *ClientWithResponses) ResolveDIDWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*ResolveDIDResponse, error) { + rsp, err := c.ResolveDID(ctx, did, reqEditors...) + if err != nil { + return nil, err + } + return ParseResolveDIDResponse(rsp) +} + +// AddServiceWithResponse request returning *AddServiceResponse +func (c *ClientWithResponses) AddServiceWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*AddServiceResponse, error) { + rsp, err := c.AddService(ctx, did, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddServiceResponse(rsp) +} + +// DeleteServiceWithResponse request returning *DeleteServiceResponse +func (c *ClientWithResponses) DeleteServiceWithResponse(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*DeleteServiceResponse, error) { + rsp, err := c.DeleteService(ctx, did, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteServiceResponse(rsp) +} + +// UpdateServiceWithResponse request returning *UpdateServiceResponse +func (c *ClientWithResponses) UpdateServiceWithResponse(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*UpdateServiceResponse, error) { + rsp, err := c.UpdateService(ctx, did, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateServiceResponse(rsp) +} + +// AddVerificationMethodWithResponse request returning *AddVerificationMethodResponse +func (c *ClientWithResponses) AddVerificationMethodWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*AddVerificationMethodResponse, error) { + rsp, err := c.AddVerificationMethod(ctx, did, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddVerificationMethodResponse(rsp) +} + +// DeleteVerificationMethodWithResponse request returning *DeleteVerificationMethodResponse +func (c *ClientWithResponses) DeleteVerificationMethodWithResponse(ctx context.Context, did string, kid string, reqEditors ...RequestEditorFn) (*DeleteVerificationMethodResponse, error) { + rsp, err := c.DeleteVerificationMethod(ctx, did, kid, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteVerificationMethodResponse(rsp) +} + +// ParseCreateDIDResponse parses an HTTP response from a CreateDIDWithResponse call +func ParseCreateDIDResponse(rsp *http.Response) (*CreateDIDResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateDIDResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DIDDocument + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSONDefault = &dest + + } + + return response, nil +} + +// ParseDeleteDIDResponse parses an HTTP response from a DeleteDIDWithResponse call +func ParseDeleteDIDResponse(rsp *http.Response) (*DeleteDIDResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteDIDResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSONDefault = &dest + + } + + return response, nil +} + +// ParseResolveDIDResponse parses an HTTP response from a ResolveDIDWithResponse call +func ParseResolveDIDResponse(rsp *http.Response) (*ResolveDIDResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResolveDIDResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DIDResolutionResult + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSONDefault = &dest + + } + + return response, nil +} + +// ParseAddServiceResponse parses an HTTP response from a AddServiceWithResponse call +func ParseAddServiceResponse(rsp *http.Response) (*AddServiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AddServiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest VerificationMethod + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSONDefault = &dest + + } + + return response, nil +} + +// ParseDeleteServiceResponse parses an HTTP response from a DeleteServiceWithResponse call +func ParseDeleteServiceResponse(rsp *http.Response) (*DeleteServiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteServiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSONDefault = &dest + + } + + return response, nil +} + +// ParseUpdateServiceResponse parses an HTTP response from a UpdateServiceWithResponse call +func ParseUpdateServiceResponse(rsp *http.Response) (*UpdateServiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateServiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Service + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSONDefault = &dest + + } + + return response, nil +} + +// ParseAddVerificationMethodResponse parses an HTTP response from a AddVerificationMethodWithResponse call +func ParseAddVerificationMethodResponse(rsp *http.Response) (*AddVerificationMethodResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AddVerificationMethodResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest VerificationMethod + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSONDefault = &dest + + } + + return response, nil +} + +// ParseDeleteVerificationMethodResponse parses an HTTP response from a DeleteVerificationMethodWithResponse call +func ParseDeleteVerificationMethodResponse(rsp *http.Response) (*DeleteVerificationMethodResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteVerificationMethodResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSONDefault = &dest + + } + + return response, nil +} + +// ServerInterface represents all server handlers. +type ServerInterface interface { + // Creates a new Web DID + // (POST /internal/vdr/v2/did) + CreateDID(ctx echo.Context) error + // Deleted the web DID Document. + // (DELETE /internal/vdr/v2/did/{did}) + DeleteDID(ctx echo.Context, did string) error + // Resolves a DID document + // (GET /internal/vdr/v2/did/{did}) + ResolveDID(ctx echo.Context, did string) error + // Adds a service to the DID document. + // (POST /internal/vdr/v2/did/{did}/service) + AddService(ctx echo.Context, did string) error + // Delete a specific service + // (DELETE /internal/vdr/v2/did/{did}/service/{id}) + DeleteService(ctx echo.Context, did string, id string) error + // Updates a service in the DID document. + // (PUT /internal/vdr/v2/did/{did}/service/{id}) + UpdateService(ctx echo.Context, did string, id string) error + // Creates and adds a new verificationMethod to the DID document. + // (POST /internal/vdr/v2/did/{did}/verificationmethod) + AddVerificationMethod(ctx echo.Context, did string) error + // Delete a specific verification method + // (DELETE /internal/vdr/v2/did/{did}/verificationmethod/{kid}) + DeleteVerificationMethod(ctx echo.Context, did string, kid string) error +} + +// ServerInterfaceWrapper converts echo contexts to parameters. +type ServerInterfaceWrapper struct { + Handler ServerInterface +} + +// CreateDID converts echo context to params. +func (w *ServerInterfaceWrapper) CreateDID(ctx echo.Context) error { + var err error + + ctx.Set(JwtBearerAuthScopes, []string{}) + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.CreateDID(ctx) + return err +} + +// DeleteDID converts echo context to params. +func (w *ServerInterfaceWrapper) DeleteDID(ctx echo.Context) error { + var err error + // ------------- Path parameter "did" ------------- + var did string + + err = runtime.BindStyledParameterWithLocation("simple", false, "did", runtime.ParamLocationPath, ctx.Param("did"), &did) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter did: %s", err)) + } + + ctx.Set(JwtBearerAuthScopes, []string{}) + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.DeleteDID(ctx, did) + return err +} + +// ResolveDID converts echo context to params. +func (w *ServerInterfaceWrapper) ResolveDID(ctx echo.Context) error { + var err error + // ------------- Path parameter "did" ------------- + var did string + + err = runtime.BindStyledParameterWithLocation("simple", false, "did", runtime.ParamLocationPath, ctx.Param("did"), &did) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter did: %s", err)) + } + + ctx.Set(JwtBearerAuthScopes, []string{}) + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.ResolveDID(ctx, did) + return err +} + +// AddService converts echo context to params. +func (w *ServerInterfaceWrapper) AddService(ctx echo.Context) error { + var err error + // ------------- Path parameter "did" ------------- + var did string + + err = runtime.BindStyledParameterWithLocation("simple", false, "did", runtime.ParamLocationPath, ctx.Param("did"), &did) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter did: %s", err)) + } + + ctx.Set(JwtBearerAuthScopes, []string{}) + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.AddService(ctx, did) + return err +} + +// DeleteService converts echo context to params. +func (w *ServerInterfaceWrapper) DeleteService(ctx echo.Context) error { + var err error + // ------------- Path parameter "did" ------------- + var did string + + err = runtime.BindStyledParameterWithLocation("simple", false, "did", runtime.ParamLocationPath, ctx.Param("did"), &did) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter did: %s", err)) + } + + // ------------- Path parameter "id" ------------- + var id string + + err = runtime.BindStyledParameterWithLocation("simple", false, "id", runtime.ParamLocationPath, ctx.Param("id"), &id) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err)) + } + + ctx.Set(JwtBearerAuthScopes, []string{}) + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.DeleteService(ctx, did, id) + return err +} + +// UpdateService converts echo context to params. +func (w *ServerInterfaceWrapper) UpdateService(ctx echo.Context) error { + var err error + // ------------- Path parameter "did" ------------- + var did string + + err = runtime.BindStyledParameterWithLocation("simple", false, "did", runtime.ParamLocationPath, ctx.Param("did"), &did) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter did: %s", err)) + } + + // ------------- Path parameter "id" ------------- + var id string + + err = runtime.BindStyledParameterWithLocation("simple", false, "id", runtime.ParamLocationPath, ctx.Param("id"), &id) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err)) + } + + ctx.Set(JwtBearerAuthScopes, []string{}) + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.UpdateService(ctx, did, id) + return err +} + +// AddVerificationMethod converts echo context to params. +func (w *ServerInterfaceWrapper) AddVerificationMethod(ctx echo.Context) error { + var err error + // ------------- Path parameter "did" ------------- + var did string + + err = runtime.BindStyledParameterWithLocation("simple", false, "did", runtime.ParamLocationPath, ctx.Param("did"), &did) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter did: %s", err)) + } + + ctx.Set(JwtBearerAuthScopes, []string{}) + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.AddVerificationMethod(ctx, did) + return err +} + +// DeleteVerificationMethod converts echo context to params. +func (w *ServerInterfaceWrapper) DeleteVerificationMethod(ctx echo.Context) error { + var err error + // ------------- Path parameter "did" ------------- + var did string + + err = runtime.BindStyledParameterWithLocation("simple", false, "did", runtime.ParamLocationPath, ctx.Param("did"), &did) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter did: %s", err)) + } + + // ------------- Path parameter "kid" ------------- + var kid string + + err = runtime.BindStyledParameterWithLocation("simple", false, "kid", runtime.ParamLocationPath, ctx.Param("kid"), &kid) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter kid: %s", err)) + } + + ctx.Set(JwtBearerAuthScopes, []string{}) + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.DeleteVerificationMethod(ctx, did, kid) + return err +} + +// This is a simple interface which specifies echo.Route addition functions which +// are present on both echo.Echo and echo.Group, since we want to allow using +// either of them for path registration +type EchoRouter interface { + CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route +} + +// RegisterHandlers adds each server route to the EchoRouter. +func RegisterHandlers(router EchoRouter, si ServerInterface) { + RegisterHandlersWithBaseURL(router, si, "") +} + +// Registers handlers, and prepends BaseURL to the paths, so that the paths +// can be served under a prefix. +func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) { + + wrapper := ServerInterfaceWrapper{ + Handler: si, + } + + router.POST(baseURL+"/internal/vdr/v2/did", wrapper.CreateDID) + router.DELETE(baseURL+"/internal/vdr/v2/did/:did", wrapper.DeleteDID) + router.GET(baseURL+"/internal/vdr/v2/did/:did", wrapper.ResolveDID) + router.POST(baseURL+"/internal/vdr/v2/did/:did/service", wrapper.AddService) + router.DELETE(baseURL+"/internal/vdr/v2/did/:did/service/:id", wrapper.DeleteService) + router.PUT(baseURL+"/internal/vdr/v2/did/:did/service/:id", wrapper.UpdateService) + router.POST(baseURL+"/internal/vdr/v2/did/:did/verificationmethod", wrapper.AddVerificationMethod) + router.DELETE(baseURL+"/internal/vdr/v2/did/:did/verificationmethod/:kid", wrapper.DeleteVerificationMethod) + +} + +type CreateDIDRequestObject struct { +} + +type CreateDIDResponseObject interface { + VisitCreateDIDResponse(w http.ResponseWriter) error +} + +type CreateDID200JSONResponse DIDDocument + +func (response CreateDID200JSONResponse) VisitCreateDIDResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type CreateDIDdefaultApplicationProblemPlusJSONResponse struct { + Body struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + StatusCode int +} + +func (response CreateDIDdefaultApplicationProblemPlusJSONResponse) VisitCreateDIDResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type DeleteDIDRequestObject struct { + Did string `json:"did"` +} + +type DeleteDIDResponseObject interface { + VisitDeleteDIDResponse(w http.ResponseWriter) error +} + +type DeleteDID204Response struct { +} + +func (response DeleteDID204Response) VisitDeleteDIDResponse(w http.ResponseWriter) error { + w.WriteHeader(204) + return nil +} + +type DeleteDIDdefaultApplicationProblemPlusJSONResponse struct { + Body struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + StatusCode int +} + +func (response DeleteDIDdefaultApplicationProblemPlusJSONResponse) VisitDeleteDIDResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type ResolveDIDRequestObject struct { + Did string `json:"did"` +} + +type ResolveDIDResponseObject interface { + VisitResolveDIDResponse(w http.ResponseWriter) error +} + +type ResolveDID200JSONResponse DIDResolutionResult + +func (response ResolveDID200JSONResponse) VisitResolveDIDResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type ResolveDIDdefaultApplicationProblemPlusJSONResponse struct { + Body struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + StatusCode int +} + +func (response ResolveDIDdefaultApplicationProblemPlusJSONResponse) VisitResolveDIDResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type AddServiceRequestObject struct { + Did string `json:"did"` +} + +type AddServiceResponseObject interface { + VisitAddServiceResponse(w http.ResponseWriter) error +} + +type AddService200JSONResponse VerificationMethod + +func (response AddService200JSONResponse) VisitAddServiceResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type AddServicedefaultApplicationProblemPlusJSONResponse struct { + Body struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + StatusCode int +} + +func (response AddServicedefaultApplicationProblemPlusJSONResponse) VisitAddServiceResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type DeleteServiceRequestObject struct { + Did string `json:"did"` + Id string `json:"id"` +} + +type DeleteServiceResponseObject interface { + VisitDeleteServiceResponse(w http.ResponseWriter) error +} + +type DeleteService204Response struct { +} + +func (response DeleteService204Response) VisitDeleteServiceResponse(w http.ResponseWriter) error { + w.WriteHeader(204) + return nil +} + +type DeleteServicedefaultApplicationProblemPlusJSONResponse struct { + Body struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + StatusCode int +} + +func (response DeleteServicedefaultApplicationProblemPlusJSONResponse) VisitDeleteServiceResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type UpdateServiceRequestObject struct { + Did string `json:"did"` + Id string `json:"id"` +} + +type UpdateServiceResponseObject interface { + VisitUpdateServiceResponse(w http.ResponseWriter) error +} + +type UpdateService200JSONResponse Service + +func (response UpdateService200JSONResponse) VisitUpdateServiceResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type UpdateServicedefaultApplicationProblemPlusJSONResponse struct { + Body struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + StatusCode int +} + +func (response UpdateServicedefaultApplicationProblemPlusJSONResponse) VisitUpdateServiceResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type AddVerificationMethodRequestObject struct { + Did string `json:"did"` +} + +type AddVerificationMethodResponseObject interface { + VisitAddVerificationMethodResponse(w http.ResponseWriter) error +} + +type AddVerificationMethod200JSONResponse VerificationMethod + +func (response AddVerificationMethod200JSONResponse) VisitAddVerificationMethodResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type AddVerificationMethoddefaultApplicationProblemPlusJSONResponse struct { + Body struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + StatusCode int +} + +func (response AddVerificationMethoddefaultApplicationProblemPlusJSONResponse) VisitAddVerificationMethodResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +type DeleteVerificationMethodRequestObject struct { + Did string `json:"did"` + Kid string `json:"kid"` +} + +type DeleteVerificationMethodResponseObject interface { + VisitDeleteVerificationMethodResponse(w http.ResponseWriter) error +} + +type DeleteVerificationMethod204Response struct { +} + +func (response DeleteVerificationMethod204Response) VisitDeleteVerificationMethodResponse(w http.ResponseWriter) error { + w.WriteHeader(204) + return nil +} + +type DeleteVerificationMethoddefaultApplicationProblemPlusJSONResponse struct { + Body struct { + // Detail A human-readable explanation specific to this occurrence of the problem. + Detail string `json:"detail"` + + // Status HTTP statuscode + Status float32 `json:"status"` + + // Title A short, human-readable summary of the problem type. + Title string `json:"title"` + } + StatusCode int +} + +func (response DeleteVerificationMethoddefaultApplicationProblemPlusJSONResponse) VisitDeleteVerificationMethodResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(response.StatusCode) + + return json.NewEncoder(w).Encode(response.Body) +} + +// StrictServerInterface represents all server handlers. +type StrictServerInterface interface { + // Creates a new Web DID + // (POST /internal/vdr/v2/did) + CreateDID(ctx context.Context, request CreateDIDRequestObject) (CreateDIDResponseObject, error) + // Deleted the web DID Document. + // (DELETE /internal/vdr/v2/did/{did}) + DeleteDID(ctx context.Context, request DeleteDIDRequestObject) (DeleteDIDResponseObject, error) + // Resolves a DID document + // (GET /internal/vdr/v2/did/{did}) + ResolveDID(ctx context.Context, request ResolveDIDRequestObject) (ResolveDIDResponseObject, error) + // Adds a service to the DID document. + // (POST /internal/vdr/v2/did/{did}/service) + AddService(ctx context.Context, request AddServiceRequestObject) (AddServiceResponseObject, error) + // Delete a specific service + // (DELETE /internal/vdr/v2/did/{did}/service/{id}) + DeleteService(ctx context.Context, request DeleteServiceRequestObject) (DeleteServiceResponseObject, error) + // Updates a service in the DID document. + // (PUT /internal/vdr/v2/did/{did}/service/{id}) + UpdateService(ctx context.Context, request UpdateServiceRequestObject) (UpdateServiceResponseObject, error) + // Creates and adds a new verificationMethod to the DID document. + // (POST /internal/vdr/v2/did/{did}/verificationmethod) + AddVerificationMethod(ctx context.Context, request AddVerificationMethodRequestObject) (AddVerificationMethodResponseObject, error) + // Delete a specific verification method + // (DELETE /internal/vdr/v2/did/{did}/verificationmethod/{kid}) + DeleteVerificationMethod(ctx context.Context, request DeleteVerificationMethodRequestObject) (DeleteVerificationMethodResponseObject, error) +} + +type StrictHandlerFunc = strictecho.StrictEchoHandlerFunc +type StrictMiddlewareFunc = strictecho.StrictEchoMiddlewareFunc + +func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface { + return &strictHandler{ssi: ssi, middlewares: middlewares} +} + +type strictHandler struct { + ssi StrictServerInterface + middlewares []StrictMiddlewareFunc +} + +// CreateDID operation middleware +func (sh *strictHandler) CreateDID(ctx echo.Context) error { + var request CreateDIDRequestObject + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.CreateDID(ctx.Request().Context(), request.(CreateDIDRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "CreateDID") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(CreateDIDResponseObject); ok { + return validResponse.VisitCreateDIDResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// DeleteDID operation middleware +func (sh *strictHandler) DeleteDID(ctx echo.Context, did string) error { + var request DeleteDIDRequestObject + + request.Did = did + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.DeleteDID(ctx.Request().Context(), request.(DeleteDIDRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "DeleteDID") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(DeleteDIDResponseObject); ok { + return validResponse.VisitDeleteDIDResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// ResolveDID operation middleware +func (sh *strictHandler) ResolveDID(ctx echo.Context, did string) error { + var request ResolveDIDRequestObject + + request.Did = did + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.ResolveDID(ctx.Request().Context(), request.(ResolveDIDRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "ResolveDID") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(ResolveDIDResponseObject); ok { + return validResponse.VisitResolveDIDResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// AddService operation middleware +func (sh *strictHandler) AddService(ctx echo.Context, did string) error { + var request AddServiceRequestObject + + request.Did = did + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.AddService(ctx.Request().Context(), request.(AddServiceRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "AddService") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(AddServiceResponseObject); ok { + return validResponse.VisitAddServiceResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// DeleteService operation middleware +func (sh *strictHandler) DeleteService(ctx echo.Context, did string, id string) error { + var request DeleteServiceRequestObject + + request.Did = did + request.Id = id + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.DeleteService(ctx.Request().Context(), request.(DeleteServiceRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "DeleteService") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(DeleteServiceResponseObject); ok { + return validResponse.VisitDeleteServiceResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// UpdateService operation middleware +func (sh *strictHandler) UpdateService(ctx echo.Context, did string, id string) error { + var request UpdateServiceRequestObject + + request.Did = did + request.Id = id + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.UpdateService(ctx.Request().Context(), request.(UpdateServiceRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "UpdateService") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(UpdateServiceResponseObject); ok { + return validResponse.VisitUpdateServiceResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// AddVerificationMethod operation middleware +func (sh *strictHandler) AddVerificationMethod(ctx echo.Context, did string) error { + var request AddVerificationMethodRequestObject + + request.Did = did + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.AddVerificationMethod(ctx.Request().Context(), request.(AddVerificationMethodRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "AddVerificationMethod") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(AddVerificationMethodResponseObject); ok { + return validResponse.VisitAddVerificationMethodResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// DeleteVerificationMethod operation middleware +func (sh *strictHandler) DeleteVerificationMethod(ctx echo.Context, did string, kid string) error { + var request DeleteVerificationMethodRequestObject + + request.Did = did + request.Kid = kid + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.DeleteVerificationMethod(ctx.Request().Context(), request.(DeleteVerificationMethodRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "DeleteVerificationMethod") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(DeleteVerificationMethodResponseObject); ok { + return validResponse.VisitDeleteVerificationMethodResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} diff --git a/vdr/api/v2/types.go b/vdr/api/v2/types.go new file mode 100644 index 0000000000..c32374fa29 --- /dev/null +++ b/vdr/api/v2/types.go @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Nuts community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package v2 + +import ( + "github.com/nuts-foundation/go-did/did" + "github.com/nuts-foundation/nuts-node/vdr/resolver" +) + +// DIDDocument is an alias +type DIDDocument = did.Document + +// DIDDocumentMetadata is an alias +type DIDDocumentMetadata = resolver.DocumentMetadata + +// VerificationMethod is an alias +type VerificationMethod = did.VerificationMethod + +// Service is an alias +type Service = did.Service