From 302352c435448e6f6d32155ba6347b55f1e627ff Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Wed, 18 Sep 2024 13:18:27 +0200 Subject: [PATCH] Use go-nuts-client for better Nuts node API support --- discovery/nuts_discovery_client.gen.go | 955 -------- discovery/service.go | 23 +- go.mod | 35 +- go.sum | 83 +- identity/service.go | 37 +- issuer/service.go | 12 +- main.go | 7 +- makefile | 5 - nuts/generated.go | 177 -- nuts/types.go | 11 - nuts/util.go | 15 - nuts/vcr/client.gen.go | 2811 ------------------------ nuts/vdr/client.gen.go | 1926 ---------------- 13 files changed, 111 insertions(+), 5986 deletions(-) delete mode 100644 discovery/nuts_discovery_client.gen.go delete mode 100644 nuts/generated.go delete mode 100644 nuts/types.go delete mode 100644 nuts/util.go delete mode 100644 nuts/vcr/client.gen.go delete mode 100644 nuts/vdr/client.gen.go diff --git a/discovery/nuts_discovery_client.gen.go b/discovery/nuts_discovery_client.gen.go deleted file mode 100644 index 1dce58e..0000000 --- a/discovery/nuts_discovery_client.gen.go +++ /dev/null @@ -1,955 +0,0 @@ -// Package discovery provides primitives to interact with the openapi HTTP API. -// -// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. -package discovery - -import ( - "context" - "encoding/json" - "fmt" - "io" - "net/http" - "net/url" - "strings" - - externalRef0 "github.com/nuts-foundation/nuts-admin/nuts" - "github.com/oapi-codegen/runtime" -) - -const ( - JwtBearerAuthScopes = "jwtBearerAuth.Scopes" -) - -// SearchResult defines model for SearchResult. -type SearchResult struct { - // CredentialSubjectId The ID of the Verifiable Credential subject (holder), typically a DID. - CredentialSubjectId string `json:"credential_subject_id"` - - // Fields Input descriptor IDs and their mapped values that from the Verifiable Credential. - Fields map[string]interface{} `json:"fields"` - - // Id The ID of the Verifiable Presentation. - Id string `json:"id"` - Vp VerifiablePresentation `json:"vp"` -} - -// ServiceDefinition defines model for ServiceDefinition. -type ServiceDefinition struct { - // Endpoint The endpoint of the Discovery Service. - Endpoint string `json:"endpoint"` - - // Id The ID of the Discovery Service. - Id string `json:"id"` - - // PresentationDefinition The Presentation Definition of the Discovery Service. - PresentationDefinition map[string]interface{} `json:"presentation_definition"` - - // PresentationMaxValidity The maximum validity (in seconds) of a Verifiable Presentation of the Discovery Service. - PresentationMaxValidity int `json:"presentation_max_validity"` -} - -// VerifiablePresentation defines model for VerifiablePresentation. -type VerifiablePresentation = externalRef0.VerifiablePresentation - -// SearchPresentationsParams defines parameters for SearchPresentations. -type SearchPresentationsParams struct { - Query *map[string]string `form:"query,omitempty" json:"query,omitempty"` -} - -// 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 { - // GetServices request - GetServices(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - - // SearchPresentations request - SearchPresentations(ctx context.Context, serviceID string, params *SearchPresentationsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeactivateServiceForSubject request - DeactivateServiceForSubject(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetServiceActivation request - GetServiceActivation(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ActivateServiceForSubject request - ActivateServiceForSubject(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*http.Response, error) -} - -func (c *Client) GetServices(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetServicesRequest(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) SearchPresentations(ctx context.Context, serviceID string, params *SearchPresentationsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewSearchPresentationsRequest(c.Server, serviceID, params) - 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) DeactivateServiceForSubject(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeactivateServiceForSubjectRequest(c.Server, serviceID, subjectID) - 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) GetServiceActivation(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetServiceActivationRequest(c.Server, serviceID, subjectID) - 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) ActivateServiceForSubject(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewActivateServiceForSubjectRequest(c.Server, serviceID, subjectID) - 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) -} - -// NewGetServicesRequest generates requests for GetServices -func NewGetServicesRequest(server string) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/discovery/v1") - 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 -} - -// NewSearchPresentationsRequest generates requests for SearchPresentations -func NewSearchPresentationsRequest(server string, serviceID string, params *SearchPresentationsParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "serviceID", runtime.ParamLocationPath, serviceID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/discovery/v1/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Query != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "query", runtime.ParamLocationQuery, *params.Query); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewDeactivateServiceForSubjectRequest generates requests for DeactivateServiceForSubject -func NewDeactivateServiceForSubjectRequest(server string, serviceID string, subjectID string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "serviceID", runtime.ParamLocationPath, serviceID) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1 = subjectID - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/discovery/v1/%s/%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 -} - -// NewGetServiceActivationRequest generates requests for GetServiceActivation -func NewGetServiceActivationRequest(server string, serviceID string, subjectID string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "serviceID", runtime.ParamLocationPath, serviceID) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1 = subjectID - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/discovery/v1/%s/%s", pathParam0, pathParam1) - 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 -} - -// NewActivateServiceForSubjectRequest generates requests for ActivateServiceForSubject -func NewActivateServiceForSubjectRequest(server string, serviceID string, subjectID string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "serviceID", runtime.ParamLocationPath, serviceID) - if err != nil { - return nil, err - } - - var pathParam1 string - - pathParam1 = subjectID - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/discovery/v1/%s/%s", pathParam0, pathParam1) - 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 -} - -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 { - // GetServicesWithResponse request - GetServicesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetServicesResponse, error) - - // SearchPresentationsWithResponse request - SearchPresentationsWithResponse(ctx context.Context, serviceID string, params *SearchPresentationsParams, reqEditors ...RequestEditorFn) (*SearchPresentationsResponse, error) - - // DeactivateServiceForSubjectWithResponse request - DeactivateServiceForSubjectWithResponse(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*DeactivateServiceForSubjectResponse, error) - - // GetServiceActivationWithResponse request - GetServiceActivationWithResponse(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*GetServiceActivationResponse, error) - - // ActivateServiceForSubjectWithResponse request - ActivateServiceForSubjectWithResponse(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*ActivateServiceForSubjectResponse, error) -} - -type GetServicesResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]ServiceDefinition - 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 GetServicesResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetServicesResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type SearchPresentationsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]SearchResult - 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 SearchPresentationsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r SearchPresentationsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type DeactivateServiceForSubjectResponse struct { - Body []byte - HTTPResponse *http.Response - JSON202 *struct { - // Reason Description of why removal of the registration failed. - Reason string `json:"reason"` - } - ApplicationproblemJSON400 *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"` - } - 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 DeactivateServiceForSubjectResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeactivateServiceForSubjectResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetServiceActivationResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *struct { - // Activated Whether the Discovery Service is activated for the given subject - Activated bool `json:"activated"` - - // Vp List of VPs on the Discovery Service for the subject. One per DID method registered on the Service. - // The list can be empty even if activated==true if none of the DIDs of a subject is actually registered on the Discovery Service. - Vp *[]VerifiablePresentation `json:"vp,omitempty"` - } - 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 GetServiceActivationResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetServiceActivationResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ActivateServiceForSubjectResponse struct { - Body []byte - HTTPResponse *http.Response - JSON202 *struct { - // Reason Description of why registration failed. - Reason string `json:"reason"` - } - ApplicationproblemJSON400 *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"` - } - 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 ActivateServiceForSubjectResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ActivateServiceForSubjectResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -// GetServicesWithResponse request returning *GetServicesResponse -func (c *ClientWithResponses) GetServicesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetServicesResponse, error) { - rsp, err := c.GetServices(ctx, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetServicesResponse(rsp) -} - -// SearchPresentationsWithResponse request returning *SearchPresentationsResponse -func (c *ClientWithResponses) SearchPresentationsWithResponse(ctx context.Context, serviceID string, params *SearchPresentationsParams, reqEditors ...RequestEditorFn) (*SearchPresentationsResponse, error) { - rsp, err := c.SearchPresentations(ctx, serviceID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseSearchPresentationsResponse(rsp) -} - -// DeactivateServiceForSubjectWithResponse request returning *DeactivateServiceForSubjectResponse -func (c *ClientWithResponses) DeactivateServiceForSubjectWithResponse(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*DeactivateServiceForSubjectResponse, error) { - rsp, err := c.DeactivateServiceForSubject(ctx, serviceID, subjectID, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeactivateServiceForSubjectResponse(rsp) -} - -// GetServiceActivationWithResponse request returning *GetServiceActivationResponse -func (c *ClientWithResponses) GetServiceActivationWithResponse(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*GetServiceActivationResponse, error) { - rsp, err := c.GetServiceActivation(ctx, serviceID, subjectID, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetServiceActivationResponse(rsp) -} - -// ActivateServiceForSubjectWithResponse request returning *ActivateServiceForSubjectResponse -func (c *ClientWithResponses) ActivateServiceForSubjectWithResponse(ctx context.Context, serviceID string, subjectID string, reqEditors ...RequestEditorFn) (*ActivateServiceForSubjectResponse, error) { - rsp, err := c.ActivateServiceForSubject(ctx, serviceID, subjectID, reqEditors...) - if err != nil { - return nil, err - } - return ParseActivateServiceForSubjectResponse(rsp) -} - -// ParseGetServicesResponse parses an HTTP response from a GetServicesWithResponse call -func ParseGetServicesResponse(rsp *http.Response) (*GetServicesResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetServicesResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []ServiceDefinition - 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 -} - -// ParseSearchPresentationsResponse parses an HTTP response from a SearchPresentationsWithResponse call -func ParseSearchPresentationsResponse(rsp *http.Response) (*SearchPresentationsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &SearchPresentationsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []SearchResult - 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 -} - -// ParseDeactivateServiceForSubjectResponse parses an HTTP response from a DeactivateServiceForSubjectWithResponse call -func ParseDeactivateServiceForSubjectResponse(rsp *http.Response) (*DeactivateServiceForSubjectResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeactivateServiceForSubjectResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: - var dest struct { - // Reason Description of why removal of the registration failed. - Reason string `json:"reason"` - } - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON202 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - 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.ApplicationproblemJSON400 = &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 -} - -// ParseGetServiceActivationResponse parses an HTTP response from a GetServiceActivationWithResponse call -func ParseGetServiceActivationResponse(rsp *http.Response) (*GetServiceActivationResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetServiceActivationResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - // Activated Whether the Discovery Service is activated for the given subject - Activated bool `json:"activated"` - - // Vp List of VPs on the Discovery Service for the subject. One per DID method registered on the Service. - // The list can be empty even if activated==true if none of the DIDs of a subject is actually registered on the Discovery Service. - Vp *[]VerifiablePresentation `json:"vp,omitempty"` - } - 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 -} - -// ParseActivateServiceForSubjectResponse parses an HTTP response from a ActivateServiceForSubjectWithResponse call -func ParseActivateServiceForSubjectResponse(rsp *http.Response) (*ActivateServiceForSubjectResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ActivateServiceForSubjectResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: - var dest struct { - // Reason Description of why registration failed. - Reason string `json:"reason"` - } - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON202 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - 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.ApplicationproblemJSON400 = &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 -} diff --git a/discovery/service.go b/discovery/service.go index e1dc350..af7f7fe 100644 --- a/discovery/service.go +++ b/discovery/service.go @@ -2,41 +2,32 @@ package discovery import ( "context" - "errors" - "github.com/nuts-foundation/nuts-admin/nuts" + "github.com/nuts-foundation/go-nuts-client/nuts" + "github.com/nuts-foundation/go-nuts-client/nuts/discovery" ) type Service struct { - Client *Client + Client *discovery.Client } -func (i Service) GetDiscoveryServices(ctx context.Context) ([]ServiceDefinition, error) { +func (i Service) GetDiscoveryServices(ctx context.Context) ([]discovery.ServiceDefinition, error) { httpResponse, err := i.Client.GetServices(ctx) - if err != nil { - return nil, nuts.UnwrapAPIError(err) - } - response, err := ParseGetServicesResponse(httpResponse) + response, err := nuts.ParseResponse(err, httpResponse, discovery.ParseGetServicesResponse) if err != nil { return nil, err } - if response.JSON200 == nil { - return nil, errors.New("unable to get services") - } return *response.JSON200, nil } func (i Service) ActivationStatus(ctx context.Context, serviceID string, subjectID string) (*DIDStatus, error) { httpResponse, err := i.Client.GetServiceActivation(ctx, serviceID, subjectID) + response, err := nuts.ParseResponse(err, httpResponse, discovery.ParseGetServiceActivationResponse) if err != nil { - return nil, nuts.UnwrapAPIError(err) + return nil, err } - response, err := ParseGetServiceActivationResponse(httpResponse) if err != nil { return nil, err } - if response.JSON200 == nil { - return nil, errors.New("unable to get service activation") - } result := &DIDStatus{ ServiceID: serviceID, Active: response.JSON200.Activated, diff --git a/go.mod b/go.mod index fa96299..a9a8724 100644 --- a/go.mod +++ b/go.mod @@ -1,50 +1,65 @@ module github.com/nuts-foundation/nuts-admin -go 1.20 +go 1.22.2 + +toolchain go1.22.4 require ( github.com/google/uuid v1.5.0 github.com/knadh/koanf v1.5.0 github.com/labstack/echo/v4 v4.11.4 github.com/lestrrat-go/jwx v1.2.28 - github.com/nuts-foundation/go-did v0.11.0 + github.com/nuts-foundation/go-did v0.14.0 + github.com/nuts-foundation/go-nuts-client v0.1.4 github.com/oapi-codegen/runtime v1.1.1 + github.com/rs/zerolog v1.33.0 github.com/spf13/pflag v1.0.5 - golang.org/x/crypto v0.18.0 + golang.org/x/crypto v0.25.0 ) require ( github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect + github.com/getkin/kin-openapi v0.124.0 // indirect + github.com/go-openapi/jsonpointer v0.20.2 // indirect + github.com/go-openapi/swag v0.22.8 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect + github.com/invopop/yaml v0.2.0 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/labstack/gommon v0.4.2 // indirect github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect github.com/lestrrat-go/blackmagic v1.0.2 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect - github.com/lestrrat-go/httprc v1.0.4 // indirect + github.com/lestrrat-go/httprc v1.0.5 // indirect github.com/lestrrat-go/iter v1.0.2 // indirect - github.com/lestrrat-go/jwx/v2 v2.0.18 // indirect + github.com/lestrrat-go/jwx/v2 v2.0.21 // indirect github.com/lestrrat-go/option v1.0.1 // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/mr-tron/base58 v1.1.0 // indirect github.com/multiformats/go-base32 v0.0.3 // indirect github.com/multiformats/go-base36 v0.1.0 // indirect github.com/multiformats/go-multibase v0.2.0 // indirect + github.com/oapi-codegen/oapi-codegen/v2 v2.3.0 // indirect + github.com/perimeterx/marshmallow v1.1.5 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/rs/zerolog v1.33.0 // indirect github.com/segmentio/asm v1.2.0 // indirect github.com/shengdoushi/base58 v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 3216a0b..1a836f6 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,9 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -54,6 +55,8 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= +github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -62,8 +65,14 @@ github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= +github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= +github.com/go-openapi/swag v0.22.8 h1:/9RjDSQ0vbFR+NyjGMkFTsA1IA0fmhKSThmfGZjicbw= +github.com/go-openapi/swag v0.22.8/go.mod h1:6QT22icPLEqAM/z/TChgb4WAveCHF92+2gF0CNjHpPI= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= +github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -140,10 +149,14 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKe github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hjson/hjson-go/v4 v4.0.0 h1:wlm6IYYqHjOdXH1gHev4VoXCaW20HdQAGCxdOEEg2cs= github.com/hjson/hjson-go/v4 v4.0.0/go.mod h1:KaYt3bTw3zhBjYqnXkYywcYctk0A2nxeEFTse3rH13E= +github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= +github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -159,11 +172,13 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/labstack/echo/v4 v4.11.4 h1:vDZmA+qNeh1pd/cCkEicDMrjtrnMGQ1QFI9gWN1zGq8= github.com/labstack/echo/v4 v4.11.4/go.mod h1:noh7EvLwqDsmh/X/HWKPUl1AjzJrhyptRyEbQJfxen8= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= @@ -174,17 +189,19 @@ github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= -github.com/lestrrat-go/httprc v1.0.4 h1:bAZymwoZQb+Oq8MEbyipag7iSq6YIga8Wj6GOiJGdI8= -github.com/lestrrat-go/httprc v1.0.4/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= +github.com/lestrrat-go/httprc v1.0.5 h1:bsTfiH8xaKOJPrg1R+E3iE/AWZr/x0Phj9PBTG/OLUk= +github.com/lestrrat-go/httprc v1.0.5/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= github.com/lestrrat-go/jwx v1.2.28 h1:uadI6o0WpOVrBSf498tRXZIwPpEtLnR9CvqPFXeI5sA= github.com/lestrrat-go/jwx v1.2.28/go.mod h1:nF+91HEMh/MYFVwKPl5HHsBGMPscqbQb+8IDQdIazP8= -github.com/lestrrat-go/jwx/v2 v2.0.18 h1:HHZkYS5wWDDyAiNBwztEtDoX07WDhGEdixm8G06R50o= -github.com/lestrrat-go/jwx/v2 v2.0.18/go.mod h1:fAJ+k5eTgKdDqanzCuK6DAt3W7n3cs2/FX7JhQdk83U= +github.com/lestrrat-go/jwx/v2 v2.0.21 h1:jAPKupy4uHgrHFEdjVjNkUgoBKtVDgrQPB/h55FHrR0= +github.com/lestrrat-go/jwx/v2 v2.0.21/go.mod h1:09mLW8zto6bWL9GbwnqAli+ArLf+5M33QLQPDggkUWM= github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -222,6 +239,8 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mr-tron/base58 v1.1.0 h1:Y51FGVJ91WBqCEabAi5OPUz38eAx8DakuAm5svLcsfQ= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI= @@ -233,8 +252,14 @@ github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6o github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk= -github.com/nuts-foundation/go-did v0.11.0 h1:RTem1MlVoOOoLa/Y2miYRy70Jex0/kJBTCPH5RtUmrY= -github.com/nuts-foundation/go-did v0.11.0/go.mod h1:2e2H2Hqk0SWrrGZEg97dbK/ZFIkkFB65hNWdOSbylrg= +github.com/nuts-foundation/go-did v0.14.0 h1:Y1tuQCC2xmDX1bdXQS9iquwzJgcT1zcJxbZkqC5Dfac= +github.com/nuts-foundation/go-did v0.14.0/go.mod h1:dQm9b2dYUnhgVW1FmpAi5nNe0mfIrnxM3EaQx4GsDhI= +github.com/nuts-foundation/go-nuts-client v0.1.3 h1:greij2A5o12T3CZisszkDksfokH3IasaiXyU1E9hz6A= +github.com/nuts-foundation/go-nuts-client v0.1.3/go.mod h1:/apCT1jOnplzvbAsP0GvTgMyUA0fPtesUDwi7VGEi5U= +github.com/nuts-foundation/go-nuts-client v0.1.4 h1:UV010QfqMO5GFCHbWBxzMCSxrrK1Rw8f3a1NTsU85yQ= +github.com/nuts-foundation/go-nuts-client v0.1.4/go.mod h1:/apCT1jOnplzvbAsP0GvTgMyUA0fPtesUDwi7VGEi5U= +github.com/oapi-codegen/oapi-codegen/v2 v2.3.0 h1:rICjNsHbPP1LttefanBPnwsSwl09SqhCO7Ee623qR84= +github.com/oapi-codegen/oapi-codegen/v2 v2.3.0/go.mod h1:4k+cJeSq5ntkwlcpQSxLxICCxQzCL772o30PxdibRt4= github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= @@ -242,6 +267,8 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= +github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= +github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -268,6 +295,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= @@ -297,8 +326,11 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= @@ -319,10 +351,9 @@ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -334,6 +365,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/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.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= 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-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -354,8 +387,8 @@ golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -370,6 +403,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -401,7 +436,6 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -410,14 +444,15 @@ 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.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 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= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -427,8 +462,9 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= @@ -445,6 +481,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= 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.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= 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= @@ -479,8 +517,9 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -489,9 +528,11 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +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= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/identity/service.go b/identity/service.go index f881deb..80b2fdc 100644 --- a/identity/service.go +++ b/identity/service.go @@ -4,10 +4,10 @@ import ( "context" "errors" "github.com/nuts-foundation/go-did/vc" + "github.com/nuts-foundation/go-nuts-client/nuts" + "github.com/nuts-foundation/go-nuts-client/nuts/vcr" + "github.com/nuts-foundation/go-nuts-client/nuts/vdr" "github.com/nuts-foundation/nuts-admin/discovery" - "github.com/nuts-foundation/nuts-admin/nuts" - "github.com/nuts-foundation/nuts-admin/nuts/vcr" - "github.com/nuts-foundation/nuts-admin/nuts/vdr" "slices" "strings" ) @@ -22,19 +22,13 @@ func (i Service) Create(ctx context.Context, subject *string) (*Identity, error) if subject != nil && *subject == "" { subject = nil } - httpResponse, err := i.VDRClient.CreateDID(ctx, vdr.CreateDIDJSONRequestBody{ + httpResponse, err := i.VDRClient.CreateSubject(ctx, vdr.CreateSubjectJSONRequestBody{ Subject: subject, }) - if err != nil { - return nil, nuts.UnwrapAPIError(err) - } - response, err := vdr.ParseCreateDIDResponse(httpResponse) + response, err := nuts.ParseResponse(err, httpResponse, vdr.ParseCreateSubjectResponse) if err != nil { return nil, err } - if response.JSON200 == nil { - return nil, errors.New("unable to create new subject") - } result := Identity{Subject: response.JSON200.Subject} for _, didDocument := range response.JSON200.Documents { result.DIDs = append(result.DIDs, didDocument.ID.String()) @@ -44,16 +38,10 @@ func (i Service) Create(ctx context.Context, subject *string) (*Identity, error) func (i Service) List(ctx context.Context) ([]Identity, error) { httpResponse, err := i.VDRClient.ListSubjects(ctx) - if err != nil { - return nil, nuts.UnwrapAPIError(err) - } - response, err := vdr.ParseListSubjectsResponse(httpResponse) + response, err := nuts.ParseResponse(err, httpResponse, vdr.ParseListSubjectsResponse) if err != nil { return nil, err } - if response.JSON200 == nil { - return nil, errors.New("unable to list DIDs") - } identities := make([]Identity, 0) for subject, subjectDIDs := range *response.JSON200 { identities = append(identities, Identity{ @@ -121,16 +109,10 @@ func (i Service) Get(ctx context.Context, subjectID string) (*IdentityDetails, e func (i Service) getSubject(ctx context.Context, subject string) (*Identity, error) { httpResponse, err := i.VDRClient.SubjectDIDs(ctx, subject) - if err != nil { - return nil, nuts.UnwrapAPIError(err) - } - response, err := vdr.ParseSubjectDIDsResponse(httpResponse) + response, err := nuts.ParseResponse(err, httpResponse, vdr.ParseSubjectDIDsResponse) if err != nil { return nil, err } - if response.JSON200 == nil { - return nil, errors.New("unable to resolve DID") - } return &Identity{ Subject: subject, DIDs: *response.JSON200, @@ -139,10 +121,7 @@ func (i Service) getSubject(ctx context.Context, subject string) (*Identity, err func (i Service) credentialsInWallet(ctx context.Context, id string) ([]vc.VerifiableCredential, error) { httpResponse, err := i.VCRClient.GetCredentialsInWallet(ctx, id) - if err != nil { - return nil, nuts.UnwrapAPIError(err) - } - response, err := vcr.ParseGetCredentialsInWalletResponse(httpResponse) + response, err := nuts.ParseResponse(err, httpResponse, vcr.ParseGetCredentialsInWalletResponse) if err != nil { return nil, err } diff --git a/issuer/service.go b/issuer/service.go index 87cd09b..fd568cb 100644 --- a/issuer/service.go +++ b/issuer/service.go @@ -3,8 +3,9 @@ package issuer import ( "context" "github.com/nuts-foundation/go-did/vc" + "github.com/nuts-foundation/go-nuts-client/nuts" + "github.com/nuts-foundation/go-nuts-client/nuts/vcr" "github.com/nuts-foundation/nuts-admin/identity" - "github.com/nuts-foundation/nuts-admin/nuts/vcr" "strings" ) @@ -20,18 +21,15 @@ func (s Service) GetIssuedCredentials(ctx context.Context, issuer string, creden if credentialType == "" { continue } - searchHTTPResponse, err := s.VCRClient.SearchIssuedVCs(ctx, &vcr.SearchIssuedVCsParams{ + httpResponse, err := s.VCRClient.SearchIssuedVCs(ctx, &vcr.SearchIssuedVCsParams{ CredentialType: credentialType, Issuer: issuer, }) + response, err := nuts.ParseResponse(err, httpResponse, vcr.ParseSearchIssuedVCsResponse) if err != nil { return nil, err } - searchResponse, err := vcr.ParseSearchIssuedVCsResponse(searchHTTPResponse) - if err != nil { - return nil, err - } - for _, searchResult := range searchResponse.JSON200.VerifiableCredentials { + for _, searchResult := range response.JSON200.VerifiableCredentials { result = append(result, searchResult.VerifiableCredential) } } diff --git a/main.go b/main.go index e33f1a5..a7970fa 100644 --- a/main.go +++ b/main.go @@ -11,11 +11,12 @@ import ( "github.com/labstack/echo/v4/middleware" "github.com/lestrrat-go/jwx/jwk" "github.com/lestrrat-go/jwx/jwt" + libDiscovery "github.com/nuts-foundation/go-nuts-client/nuts/discovery" + "github.com/nuts-foundation/go-nuts-client/nuts/vcr" + "github.com/nuts-foundation/go-nuts-client/nuts/vdr" "github.com/nuts-foundation/nuts-admin/discovery" "github.com/nuts-foundation/nuts-admin/identity" "github.com/nuts-foundation/nuts-admin/issuer" - "github.com/nuts-foundation/nuts-admin/nuts/vcr" - "github.com/nuts-foundation/nuts-admin/nuts/vdr" "github.com/rs/zerolog" "io/fs" "log" @@ -82,7 +83,7 @@ func main() { vdrClient, _ := vdr.NewClient(config.Node.Address) vcrClient, _ := vcr.NewClient(config.Node.Address) - discoveryClient, _ := discovery.NewClient(config.Node.Address) + discoveryClient, _ := libDiscovery.NewClient(config.Node.Address) // Initialize wrapper discoveryService := discovery.Service{ diff --git a/makefile b/makefile index f933c7c..7d18771 100644 --- a/makefile +++ b/makefile @@ -8,11 +8,6 @@ install-tools: gen-api: oapi-codegen -generate server,types -package api api/api.yaml > api/generated.go - oapi-codegen -generate client,types -package nuts -exclude-schemas VerifiableCredential,VerifiablePresentation,DID,DIDDocument -generate types,skip-prune -o nuts/generated.go https://nuts-node.readthedocs.io/en/latest/_static/common/ssi_types.yaml - oapi-codegen -generate client,types -package vdr -import-mapping='../common/ssi_types.yaml:github.com/nuts-foundation/nuts-admin/nuts' -o nuts/vdr/client.gen.go https://nuts-node.readthedocs.io/en/latest/_static/vdr/v2.yaml - oapi-codegen -generate client,types -package vcr -import-mapping='../common/ssi_types.yaml:github.com/nuts-foundation/nuts-admin/nuts' -o nuts/vcr/client.gen.go https://nuts-node.readthedocs.io/en/latest/_static/vcr/vcr_v2.yaml - oapi-codegen -generate client,types -package discovery -import-mapping='../common/ssi_types.yaml:github.com/nuts-foundation/nuts-admin/nuts' -o discovery/nuts_discovery_client.gen.go https://nuts-node.readthedocs.io/en/latest/_static/discovery/v1.yaml - dev: make -j3 watch run-nuts-node run-api diff --git a/nuts/generated.go b/nuts/generated.go deleted file mode 100644 index 9618eac..0000000 --- a/nuts/generated.go +++ /dev/null @@ -1,177 +0,0 @@ -// Package nuts provides primitives to interact with the openapi HTTP API. -// -// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. -package nuts - -// CredentialStatus Object enabling the discovery of information related to the status of a verifiable credential, such as whether it is suspended or revoked. -// Interpretation of the credentialStatus is defined by its 'type' property. -type CredentialStatus = interface{} - -// CredentialSubject Subject of a Verifiable Credential identifying the holder and expressing claims. -type CredentialSubject = interface{} - -// DIDDocumentMetadata The DID document metadata. -type DIDDocumentMetadata struct { - // Created Time when DID document was created in rfc3339 form. - Created string `json:"created"` - - // Deactivated Whether the DID document has been deactivated. - Deactivated bool `json:"deactivated"` - - // Hash Sha256 in hex form of the DID document contents. - Hash string `json:"hash"` - - // PreviousHash Sha256 in hex form of the previous version of this DID document. - PreviousHash *string `json:"previousHash,omitempty"` - - // Txs txs lists the transaction(s) that created the current version of this DID Document. - // If multiple transactions are listed, the DID Document is conflicted - Txs []string `json:"txs"` - - // Updated Time when DID document was updated in rfc3339 form. - Updated *string `json:"updated,omitempty"` -} - -// EmbeddedProof Cryptographic proofs that can be used to detect tampering and verify the authorship of a -// credential or presentation. An embedded proof is a mechanism where the proof is included in -// the data, such as a Linked Data Signature. -type EmbeddedProof struct { - // Challenge A random or pseudo-random value, provided by the verifier, used by some authentication protocols to - // mitigate replay attacks. - Challenge *string `json:"challenge,omitempty"` - - // Created Date and time at which proof has been created. - Created string `json:"created"` - - // Domain A string value that specifies the operational domain of a digital proof. This could be an Internet domain - // name like example.com, an ad-hoc value such as mycorp-level3-access, or a very specific transaction value - // like 8zF6T$mqP. A signer could include a domain in its digital proof to restrict its use to particular - // target, identified by the specified domain. - Domain *string `json:"domain,omitempty"` - - // Jws JSON Web Signature - Jws string `json:"jws"` - - // Nonce A unique string value generated by the holder, MUST only be used once for a particular domain - // and window of time. This value can be used to mitigate replay attacks. - Nonce *string `json:"nonce,omitempty"` - - // ProofPurpose It expresses the purpose of the proof and ensures the information is protected by the - // signature. - ProofPurpose string `json:"proofPurpose"` - - // Type Type of the object or the datatype of the typed value. Currently only supported value is "JsonWebSignature2020". - Type string `json:"type"` - - // VerificationMethod Specifies the public key that can be used to verify the digital signature. - // Dereferencing a public key URL reveals information about the controller of the key, - // which can be checked against the issuer of the credential. - VerificationMethod string `json:"verificationMethod"` -} - -// JSONVerifiableCredential Verifiable Credential in JSON-LD format. -type JSONVerifiableCredential struct { - // Context List of URIs of JSON-LD contexts of the VC. - Context interface{} `json:"@context"` - - // CredentialStatus Object enabling the discovery of information related to the status of a verifiable credential, such as whether it is suspended or revoked. - // Interpretation of the credentialStatus is defined by its 'type' property. - CredentialStatus *CredentialStatus `json:"credentialStatus,omitempty"` - - // CredentialSubject Subject of a Verifiable Credential identifying the holder and expressing claims. - CredentialSubject CredentialSubject `json:"credentialSubject"` - - // ExpirationDate rfc3339 time string until when the credential is valid. - ExpirationDate *string `json:"expirationDate,omitempty"` - - // Id Credential ID. An URI which uniquely identifies the credential e.g. the issuers DID concatenated with a UUID. - Id *string `json:"id,omitempty"` - - // IssuanceDate rfc3339 time string when the credential was issued. - IssuanceDate string `json:"issuanceDate"` - - // Issuer DID according to Nuts specification - Issuer DID `json:"issuer"` - - // Proof one or multiple cryptographic proofs - Proof interface{} `json:"proof"` - - // Type A single string or array of strings. The value(s) indicate the type of credential. It should contain `VerifiableCredential`. Each type should be defined in the @context. - Type []string `json:"type"` -} - -// JSONVerifiablePresentation Verifiable Presentation in JSON-LD format. -type JSONVerifiablePresentation struct { - // Context An ordered set where the first item is a URI https://www.w3.org/2018/credentials/v1. It is used to define - // terms and help to express specific identifiers in a compact manner. - Context interface{} `json:"@context"` - - // Holder URI of the entity that is generating the presentation. - Holder *string `json:"holder,omitempty"` - - // Id URI that is used to unambiguously refer to an object, such as a person, product, or organization. - Id *string `json:"id,omitempty"` - - // Proof Cryptographic proofs that can be used to detect tampering and verify the authorship of a - // credential or presentation. An embedded proof is a mechanism where the proof is included in - // the data, such as a Linked Data Signature. - Proof *interface{} `json:"proof,omitempty"` - - // Type A single string or array of strings. Values indicate the type of object. It should contain `VerifiablePresentation`. Each type must be defined in the @context. - Type interface{} `json:"type"` - - // VerifiableCredential VerifiableCredential is composed of a list containing one or more verifiable credentials, in a - // cryptographically verifiable format. - VerifiableCredential *interface{} `json:"verifiableCredential,omitempty"` -} - -// JWTCompactVerifiableCredential Verifiable Credential in JWT compact serialization format. -type JWTCompactVerifiableCredential = string - -// JWTCompactVerifiablePresentation Verifiable Presentation in JWT compact serialization format. -type JWTCompactVerifiablePresentation = string - -// Revocation Credential revocation record -type Revocation struct { - // Date date is a rfc3339 formatted datetime. - Date string `json:"date"` - - // Issuer DID according to Nuts specification - Issuer DID `json:"issuer"` - - // Proof Proof contains the cryptographic proof(s). - Proof *map[string]interface{} `json:"proof,omitempty"` - - // Reason reason describes why the VC has been revoked - Reason *string `json:"reason,omitempty"` - - // Subject subject refers to the credential identifier that is revoked (not the credential subject) - Subject string `json:"subject"` -} - -// Service A service supported by a DID subject. -type Service struct { - // Id ID of the service. - Id string `json:"id"` - - // ServiceEndpoint Either a URI or a complex object. - ServiceEndpoint interface{} `json:"serviceEndpoint"` - - // Type The type of the endpoint. - Type string `json:"type"` -} - -// VerificationMethod A public key in JWK form. -type VerificationMethod struct { - // Controller The DID subject this key belongs to. - Controller string `json:"controller"` - - // Id The ID of the key, used as KID in various JWX technologies. - Id string `json:"id"` - - // PublicKeyJwk The public key formatted according rfc7517. - PublicKeyJwk map[string]interface{} `json:"publicKeyJwk"` - - // Type The type of the key. - Type string `json:"type"` -} diff --git a/nuts/types.go b/nuts/types.go deleted file mode 100644 index 236859a..0000000 --- a/nuts/types.go +++ /dev/null @@ -1,11 +0,0 @@ -package nuts - -import ( - "github.com/nuts-foundation/go-did/did" - "github.com/nuts-foundation/go-did/vc" -) - -type DID = did.DID -type DIDDocument = did.Document -type VerifiableCredential = vc.VerifiableCredential -type VerifiablePresentation = vc.VerifiablePresentation diff --git a/nuts/util.go b/nuts/util.go deleted file mode 100644 index e795363..0000000 --- a/nuts/util.go +++ /dev/null @@ -1,15 +0,0 @@ -package nuts - -import ( - "errors" - "net" -) - -var ErrNutsNodeUnreachable = errors.New("nuts node unreachable") - -func UnwrapAPIError(err error) error { - if _, ok := err.(net.Error); ok { - return errors.Join(ErrNutsNodeUnreachable, err) - } - return err -} diff --git a/nuts/vcr/client.gen.go b/nuts/vcr/client.gen.go deleted file mode 100644 index 96ffdf7..0000000 --- a/nuts/vcr/client.gen.go +++ /dev/null @@ -1,2811 +0,0 @@ -// Package vcr provides primitives to interact with the openapi HTTP API. -// -// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. -package vcr - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "io" - "net/http" - "net/url" - "strings" - - externalRef0 "github.com/nuts-foundation/nuts-admin/nuts" - "github.com/oapi-codegen/runtime" -) - -const ( - JwtBearerAuthScopes = "jwtBearerAuth.Scopes" -) - -// Defines values for CreateVPRequestFormat. -const ( - JwtVp CreateVPRequestFormat = "jwt_vp" - LdpVp CreateVPRequestFormat = "ldp_vp" -) - -// Defines values for CreateVPRequestProofPurpose. -const ( - AssertionMethod CreateVPRequestProofPurpose = "assertionMethod" - Authentication CreateVPRequestProofPurpose = "authentication" - CapabilityDelegation CreateVPRequestProofPurpose = "capabilityDelegation" - CapabilityInvocation CreateVPRequestProofPurpose = "capabilityInvocation" - KeyAgreement CreateVPRequestProofPurpose = "keyAgreement" -) - -// Defines values for IssueVCRequestFormat. -const ( - JwtVc IssueVCRequestFormat = "jwt_vc" - LdpVc IssueVCRequestFormat = "ldp_vc" -) - -// Defines values for IssueVCRequestVisibility. -const ( - Private IssueVCRequestVisibility = "private" - Public IssueVCRequestVisibility = "public" -) - -// CreateVPRequest A request for creating a new Verifiable Presentation for a set of Verifiable Credentials. -type CreateVPRequest struct { - // Context Array of JSON-LD contexts, contain definitions of the given types. - Context *[]string `json:"@context,omitempty"` - - // Challenge A random or pseudo-random value used by some authentication protocols to mitigate replay attacks. - Challenge *string `json:"challenge,omitempty"` - - // Domain A string value that specifies the operational domain of a digital proof. This could be an Internet domain - // name like example.com, an ad-hoc value such as mycorp-level3-access, or a very specific transaction value - // like 8zF6T$mqP. A signer could include a domain in its digital proof to restrict its use to particular - // target, identified by the specified domain. - Domain *string `json:"domain,omitempty"` - - // Expires Date and time at which proof will expire. If omitted, the proof does not have an end date. - Expires *string `json:"expires,omitempty"` - - // Format Proof format for the presentation (JSON-LD or JWT). If not set, it defaults to JSON-LD. - Format *CreateVPRequestFormat `json:"format,omitempty"` - - // ProofPurpose The specific intent for the proof, the reason why an entity created it. Acts as a safeguard to prevent the - // proof from being misused for a purpose other than the one it was intended for. - ProofPurpose *CreateVPRequestProofPurpose `json:"proofPurpose,omitempty"` - - // SignerDID Specifies the DID of the signing party that must be used to create the digital signature. - // If not specified, it is derived from the given Verifiable Credentials' subjectCredential ID. - // It can only be derived if all given Verifiable Credentials have the same, single subjectCredential. - SignerDID *string `json:"signerDID,omitempty"` - - // Type Array of VerifiablePresentation types that will be added next to the default type. Types must be available in the given context. - Type *[]string `json:"type,omitempty"` - VerifiableCredentials []VerifiableCredential `json:"verifiableCredentials"` -} - -// CreateVPRequestFormat Proof format for the presentation (JSON-LD or JWT). If not set, it defaults to JSON-LD. -type CreateVPRequestFormat string - -// CreateVPRequestProofPurpose The specific intent for the proof, the reason why an entity created it. Acts as a safeguard to prevent the -// proof from being misused for a purpose other than the one it was intended for. -type CreateVPRequestProofPurpose string - -// CredentialIssuer defines model for CredentialIssuer. -type CredentialIssuer struct { - // CredentialType a credential type - CredentialType string `json:"credentialType"` - - // Issuer the DID of an issuer - Issuer string `json:"issuer"` -} - -// CredentialSubject Subject of a Verifiable Credential identifying the holder and expressing claims. -type CredentialSubject = externalRef0.CredentialSubject - -// IssueVCRequest A request for issuing a new Verifiable Credential. -type IssueVCRequest struct { - // Context The resolvable context of the credentialSubject as URI. If omitted, the "https://nuts.nl/credentials/v1" context is used. - // It always adds the "https://www.w3.org/2018/credentials/v1" context if not present. - Context *IssueVCRequest_Context `json:"@context,omitempty"` - - // CredentialSubject Subject of a Verifiable Credential identifying the holder and expressing claims. - CredentialSubject CredentialSubject `json:"credentialSubject"` - - // ExpirationDate RFC3339 time string until when the credential is valid. - ExpirationDate *string `json:"expirationDate,omitempty"` - - // Format Proof format for the credential (ldp_vc for JSON-LD or jwt_vc for JWT). If not set, it defaults to JSON-LD. - Format *IssueVCRequestFormat `json:"format,omitempty"` - - // Issuer DID according to Nuts specification. - Issuer string `json:"issuer"` - - // PublishToNetwork If set, the node publishes this credential to the network. This is the default behaviour. - // When set to false, the caller is responsible for distributing the VC to a holder. When the issuer is - // also the holder, it then can be used to directly create a presentation (self issued). - // Note: a not published credential can still be publicly revoked. - // Only valid for did:nuts issuers. - PublishToNetwork *bool `json:"publishToNetwork,omitempty"` - - // Type Type definition for the credential. - Type IssueVCRequest_Type `json:"type"` - - // Visibility When publishToNetwork is true, the credential can be published publicly or privately to the holder. - // This field is mandatory if publishToNetwork is true to prevent accidents. It defaults to "private". - // Only valid for did:nuts issuers. - Visibility *IssueVCRequestVisibility `json:"visibility,omitempty"` - - // WithStatusList2021Revocation Add a credentialStatus with statusPurpose 'revocation' to the issued credential. This allows a credential to - // be revoked using the referenced StatusList2021Credential. StatusPurpose 'suspension' is not supported (yet). - // See https://www.w3.org/TR/2023/WD-vc-status-list-20230427/ - // - // Credentials with a short lifespan (expiry) are preferred over adding a credentialStatus. - // This is a required field for credentials without an expirationDate. - // Only valid for did:web issuers. - WithStatusList2021Revocation *bool `json:"withStatusList2021Revocation,omitempty"` -} - -// IssueVCRequestContext0 defines model for . -type IssueVCRequestContext0 = string - -// IssueVCRequestContext1 defines model for . -type IssueVCRequestContext1 = []string - -// IssueVCRequest_Context The resolvable context of the credentialSubject as URI. If omitted, the "https://nuts.nl/credentials/v1" context is used. -// It always adds the "https://www.w3.org/2018/credentials/v1" context if not present. -type IssueVCRequest_Context struct { - union json.RawMessage -} - -// IssueVCRequestFormat Proof format for the credential (ldp_vc for JSON-LD or jwt_vc for JWT). If not set, it defaults to JSON-LD. -type IssueVCRequestFormat string - -// IssueVCRequestType0 defines model for . -type IssueVCRequestType0 = string - -// IssueVCRequestType1 defines model for . -type IssueVCRequestType1 = []string - -// IssueVCRequest_Type Type definition for the credential. -type IssueVCRequest_Type struct { - union json.RawMessage -} - -// IssueVCRequestVisibility When publishToNetwork is true, the credential can be published publicly or privately to the holder. -// This field is mandatory if publishToNetwork is true to prevent accidents. It defaults to "private". -// Only valid for did:nuts issuers. -type IssueVCRequestVisibility string - -// Revocation Credential revocation record -type Revocation = externalRef0.Revocation - -// SearchOptions defines model for SearchOptions. -type SearchOptions struct { - // AllowUntrustedIssuer If set to true, VCs from an untrusted issuer are returned. - AllowUntrustedIssuer *bool `json:"allowUntrustedIssuer,omitempty"` -} - -// SearchVCRequest request body for searching VCs -type SearchVCRequest struct { - // Query A partial VerifiableCredential in JSON-LD format. Each field will be used to match credentials against. All fields MUST be present. - Query map[string]interface{} `json:"query"` - SearchOptions *SearchOptions `json:"searchOptions,omitempty"` -} - -// SearchVCResult Result of a Search operation. -// The revocation property is only present if a credential is revoked with a Verifiable Credential of type CredentialRevocation. -// The absence of a the revocation property does not indicate a valid credential, use the /internal/vcr/v2/verifier/vc API for this. -type SearchVCResult struct { - // Revocation Credential revocation record - Revocation *Revocation `json:"revocation,omitempty"` - VerifiableCredential VerifiableCredential `json:"verifiableCredential"` -} - -// SearchVCResults result of a Search operation. -type SearchVCResults struct { - VerifiableCredentials []SearchVCResult `json:"verifiableCredentials"` -} - -// VCVerificationOptions defines model for VCVerificationOptions. -type VCVerificationOptions struct { - // AllowUntrustedIssuer If set to true, an untrusted credential issuer is allowed. - // Deprecated: - AllowUntrustedIssuer *bool `json:"allowUntrustedIssuer,omitempty"` -} - -// VCVerificationRequest defines model for VCVerificationRequest. -type VCVerificationRequest struct { - VerifiableCredential VerifiableCredential `json:"verifiableCredential"` - VerificationOptions *VCVerificationOptions `json:"verificationOptions,omitempty"` -} - -// VCVerificationResult Contains the verifiable credential verification result. -type VCVerificationResult struct { - // Message Indicates what went wrong - Message *string `json:"message,omitempty"` - - // Validity Indicates the validity of the signature, issuer and revocation state. - Validity bool `json:"validity"` -} - -// VPVerificationRequest defines model for VPVerificationRequest. -type VPVerificationRequest struct { - // ValidAt Date and time at which the VP should be valid. If not supplied, the current date/time is used. - ValidAt *string `json:"validAt,omitempty"` - VerifiablePresentation VerifiablePresentation `json:"verifiablePresentation"` - - // VerifyCredentials Indicates whether the Verifiable Credentials within the VP must be verified, default true. - VerifyCredentials *bool `json:"verifyCredentials,omitempty"` -} - -// VPVerificationResult Contains the verifiable presentation verification result. -type VPVerificationResult struct { - // Credentials If the VP is valid, it will contain the credentials inside the VP. - Credentials *[]VerifiableCredential `json:"credentials,omitempty"` - - // Message Indicates what went wrong - Message *string `json:"message,omitempty"` - - // Validity Indicates the validity of the signature, issuer and revocation state. - Validity bool `json:"validity"` -} - -// VerifiableCredential defines model for VerifiableCredential. -type VerifiableCredential = externalRef0.VerifiableCredential - -// VerifiablePresentation defines model for VerifiablePresentation. -type VerifiablePresentation = externalRef0.VerifiablePresentation - -// SearchIssuedVCsParams defines parameters for SearchIssuedVCs. -type SearchIssuedVCsParams struct { - // CredentialType The type of the credential - CredentialType string `form:"credentialType" json:"credentialType"` - - // Issuer the DID of the issuer - Issuer string `form:"issuer" json:"issuer"` - - // Subject the URI which indicates the subject (usually a DID) - Subject *string `form:"subject,omitempty" json:"subject,omitempty"` -} - -// CreateVPJSONRequestBody defines body for CreateVP for application/json ContentType. -type CreateVPJSONRequestBody = CreateVPRequest - -// LoadVCJSONRequestBody defines body for LoadVC for application/json ContentType. -type LoadVCJSONRequestBody = VerifiableCredential - -// IssueVCJSONRequestBody defines body for IssueVC for application/json ContentType. -type IssueVCJSONRequestBody = IssueVCRequest - -// SearchVCsJSONRequestBody defines body for SearchVCs for application/json ContentType. -type SearchVCsJSONRequestBody = SearchVCRequest - -// UntrustIssuerJSONRequestBody defines body for UntrustIssuer for application/json ContentType. -type UntrustIssuerJSONRequestBody = CredentialIssuer - -// TrustIssuerJSONRequestBody defines body for TrustIssuer for application/json ContentType. -type TrustIssuerJSONRequestBody = CredentialIssuer - -// VerifyVCJSONRequestBody defines body for VerifyVC for application/json ContentType. -type VerifyVCJSONRequestBody = VCVerificationRequest - -// VerifyVPJSONRequestBody defines body for VerifyVP for application/json ContentType. -type VerifyVPJSONRequestBody = VPVerificationRequest - -// AsIssueVCRequestContext0 returns the union data inside the IssueVCRequest_Context as a IssueVCRequestContext0 -func (t IssueVCRequest_Context) AsIssueVCRequestContext0() (IssueVCRequestContext0, error) { - var body IssueVCRequestContext0 - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromIssueVCRequestContext0 overwrites any union data inside the IssueVCRequest_Context as the provided IssueVCRequestContext0 -func (t *IssueVCRequest_Context) FromIssueVCRequestContext0(v IssueVCRequestContext0) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeIssueVCRequestContext0 performs a merge with any union data inside the IssueVCRequest_Context, using the provided IssueVCRequestContext0 -func (t *IssueVCRequest_Context) MergeIssueVCRequestContext0(v IssueVCRequestContext0) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsIssueVCRequestContext1 returns the union data inside the IssueVCRequest_Context as a IssueVCRequestContext1 -func (t IssueVCRequest_Context) AsIssueVCRequestContext1() (IssueVCRequestContext1, error) { - var body IssueVCRequestContext1 - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromIssueVCRequestContext1 overwrites any union data inside the IssueVCRequest_Context as the provided IssueVCRequestContext1 -func (t *IssueVCRequest_Context) FromIssueVCRequestContext1(v IssueVCRequestContext1) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeIssueVCRequestContext1 performs a merge with any union data inside the IssueVCRequest_Context, using the provided IssueVCRequestContext1 -func (t *IssueVCRequest_Context) MergeIssueVCRequestContext1(v IssueVCRequestContext1) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t IssueVCRequest_Context) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - return b, err -} - -func (t *IssueVCRequest_Context) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - return err -} - -// AsIssueVCRequestType0 returns the union data inside the IssueVCRequest_Type as a IssueVCRequestType0 -func (t IssueVCRequest_Type) AsIssueVCRequestType0() (IssueVCRequestType0, error) { - var body IssueVCRequestType0 - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromIssueVCRequestType0 overwrites any union data inside the IssueVCRequest_Type as the provided IssueVCRequestType0 -func (t *IssueVCRequest_Type) FromIssueVCRequestType0(v IssueVCRequestType0) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeIssueVCRequestType0 performs a merge with any union data inside the IssueVCRequest_Type, using the provided IssueVCRequestType0 -func (t *IssueVCRequest_Type) MergeIssueVCRequestType0(v IssueVCRequestType0) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -// AsIssueVCRequestType1 returns the union data inside the IssueVCRequest_Type as a IssueVCRequestType1 -func (t IssueVCRequest_Type) AsIssueVCRequestType1() (IssueVCRequestType1, error) { - var body IssueVCRequestType1 - err := json.Unmarshal(t.union, &body) - return body, err -} - -// FromIssueVCRequestType1 overwrites any union data inside the IssueVCRequest_Type as the provided IssueVCRequestType1 -func (t *IssueVCRequest_Type) FromIssueVCRequestType1(v IssueVCRequestType1) error { - b, err := json.Marshal(v) - t.union = b - return err -} - -// MergeIssueVCRequestType1 performs a merge with any union data inside the IssueVCRequest_Type, using the provided IssueVCRequestType1 -func (t *IssueVCRequest_Type) MergeIssueVCRequestType1(v IssueVCRequestType1) error { - b, err := json.Marshal(v) - if err != nil { - return err - } - - merged, err := runtime.JSONMerge(t.union, b) - t.union = merged - return err -} - -func (t IssueVCRequest_Type) MarshalJSON() ([]byte, error) { - b, err := t.union.MarshalJSON() - return b, err -} - -func (t *IssueVCRequest_Type) UnmarshalJSON(b []byte) error { - err := t.union.UnmarshalJSON(b) - return err -} - -// 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 { - // CreateVPWithBody request with any body - CreateVPWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - CreateVP(ctx context.Context, body CreateVPJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetCredentialsInWallet request - GetCredentialsInWallet(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // LoadVCWithBody request with any body - LoadVCWithBody(ctx context.Context, did string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - LoadVC(ctx context.Context, did string, body LoadVCJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // RemoveCredentialFromWallet request - RemoveCredentialFromWallet(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // IssueVCWithBody request with any body - IssueVCWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - IssueVC(ctx context.Context, body IssueVCJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // SearchIssuedVCs request - SearchIssuedVCs(ctx context.Context, params *SearchIssuedVCsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // RevokeVC request - RevokeVC(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // SearchVCsWithBody request with any body - SearchVCsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - SearchVCs(ctx context.Context, body SearchVCsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ResolveVC request - ResolveVC(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // UntrustIssuerWithBody request with any body - UntrustIssuerWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - UntrustIssuer(ctx context.Context, body UntrustIssuerJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // TrustIssuerWithBody request with any body - TrustIssuerWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - TrustIssuer(ctx context.Context, body TrustIssuerJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // VerifyVCWithBody request with any body - VerifyVCWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - VerifyVC(ctx context.Context, body VerifyVCJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // VerifyVPWithBody request with any body - VerifyVPWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - VerifyVP(ctx context.Context, body VerifyVPJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ListTrusted request - ListTrusted(ctx context.Context, credentialType string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ListUntrusted request - ListUntrusted(ctx context.Context, credentialType string, reqEditors ...RequestEditorFn) (*http.Response, error) -} - -func (c *Client) CreateVPWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateVPRequestWithBody(c.Server, contentType, body) - 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) CreateVP(ctx context.Context, body CreateVPJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateVPRequest(c.Server, body) - 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) GetCredentialsInWallet(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetCredentialsInWalletRequest(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) LoadVCWithBody(ctx context.Context, did string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewLoadVCRequestWithBody(c.Server, did, contentType, body) - 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) LoadVC(ctx context.Context, did string, body LoadVCJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewLoadVCRequest(c.Server, did, body) - 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) RemoveCredentialFromWallet(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewRemoveCredentialFromWalletRequest(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) IssueVCWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewIssueVCRequestWithBody(c.Server, contentType, body) - 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) IssueVC(ctx context.Context, body IssueVCJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewIssueVCRequest(c.Server, body) - 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) SearchIssuedVCs(ctx context.Context, params *SearchIssuedVCsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewSearchIssuedVCsRequest(c.Server, params) - 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) RevokeVC(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewRevokeVCRequest(c.Server, 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) SearchVCsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewSearchVCsRequestWithBody(c.Server, contentType, body) - 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) SearchVCs(ctx context.Context, body SearchVCsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewSearchVCsRequest(c.Server, body) - 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) ResolveVC(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewResolveVCRequest(c.Server, 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) UntrustIssuerWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUntrustIssuerRequestWithBody(c.Server, contentType, body) - 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) UntrustIssuer(ctx context.Context, body UntrustIssuerJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUntrustIssuerRequest(c.Server, body) - 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) TrustIssuerWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewTrustIssuerRequestWithBody(c.Server, contentType, body) - 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) TrustIssuer(ctx context.Context, body TrustIssuerJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewTrustIssuerRequest(c.Server, body) - 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) VerifyVCWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewVerifyVCRequestWithBody(c.Server, contentType, body) - 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) VerifyVC(ctx context.Context, body VerifyVCJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewVerifyVCRequest(c.Server, body) - 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) VerifyVPWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewVerifyVPRequestWithBody(c.Server, contentType, body) - 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) VerifyVP(ctx context.Context, body VerifyVPJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewVerifyVPRequest(c.Server, body) - 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) ListTrusted(ctx context.Context, credentialType string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListTrustedRequest(c.Server, credentialType) - 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) ListUntrusted(ctx context.Context, credentialType string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListUntrustedRequest(c.Server, credentialType) - 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) -} - -// NewCreateVPRequest calls the generic CreateVP builder with application/json body -func NewCreateVPRequest(server string, body CreateVPJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewCreateVPRequestWithBody(server, "application/json", bodyReader) -} - -// NewCreateVPRequestWithBody generates requests for CreateVP with any type of body -func NewCreateVPRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/holder/vp") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewGetCredentialsInWalletRequest generates requests for GetCredentialsInWallet -func NewGetCredentialsInWalletRequest(server string, did string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = did - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/holder/%s/vc", 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 -} - -// NewLoadVCRequest calls the generic LoadVC builder with application/json body -func NewLoadVCRequest(server string, did string, body LoadVCJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewLoadVCRequestWithBody(server, did, "application/json", bodyReader) -} - -// NewLoadVCRequestWithBody generates requests for LoadVC with any type of body -func NewLoadVCRequestWithBody(server string, did string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = did - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/holder/%s/vc", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewRemoveCredentialFromWalletRequest generates requests for RemoveCredentialFromWallet -func NewRemoveCredentialFromWalletRequest(server string, did string, id string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = did - - 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/vcr/v2/holder/%s/vc/%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 -} - -// NewIssueVCRequest calls the generic IssueVC builder with application/json body -func NewIssueVCRequest(server string, body IssueVCJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewIssueVCRequestWithBody(server, "application/json", bodyReader) -} - -// NewIssueVCRequestWithBody generates requests for IssueVC with any type of body -func NewIssueVCRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/issuer/vc") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewSearchIssuedVCsRequest generates requests for SearchIssuedVCs -func NewSearchIssuedVCsRequest(server string, params *SearchIssuedVCsParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/issuer/vc/search") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "credentialType", runtime.ParamLocationQuery, params.CredentialType); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "issuer", runtime.ParamLocationQuery, params.Issuer); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - if params.Subject != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "subject", runtime.ParamLocationQuery, *params.Subject); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewRevokeVCRequest generates requests for RevokeVC -func NewRevokeVCRequest(server string, id string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, 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/vcr/v2/issuer/vc/%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 -} - -// NewSearchVCsRequest calls the generic SearchVCs builder with application/json body -func NewSearchVCsRequest(server string, body SearchVCsJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewSearchVCsRequestWithBody(server, "application/json", bodyReader) -} - -// NewSearchVCsRequestWithBody generates requests for SearchVCs with any type of body -func NewSearchVCsRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/search") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewResolveVCRequest generates requests for ResolveVC -func NewResolveVCRequest(server string, id string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, 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/vcr/v2/vc/%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 -} - -// NewUntrustIssuerRequest calls the generic UntrustIssuer builder with application/json body -func NewUntrustIssuerRequest(server string, body UntrustIssuerJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewUntrustIssuerRequestWithBody(server, "application/json", bodyReader) -} - -// NewUntrustIssuerRequestWithBody generates requests for UntrustIssuer with any type of body -func NewUntrustIssuerRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/verifier/trust") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewTrustIssuerRequest calls the generic TrustIssuer builder with application/json body -func NewTrustIssuerRequest(server string, body TrustIssuerJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewTrustIssuerRequestWithBody(server, "application/json", bodyReader) -} - -// NewTrustIssuerRequestWithBody generates requests for TrustIssuer with any type of body -func NewTrustIssuerRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/verifier/trust") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewVerifyVCRequest calls the generic VerifyVC builder with application/json body -func NewVerifyVCRequest(server string, body VerifyVCJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewVerifyVCRequestWithBody(server, "application/json", bodyReader) -} - -// NewVerifyVCRequestWithBody generates requests for VerifyVC with any type of body -func NewVerifyVCRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/verifier/vc") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewVerifyVPRequest calls the generic VerifyVP builder with application/json body -func NewVerifyVPRequest(server string, body VerifyVPJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewVerifyVPRequestWithBody(server, "application/json", bodyReader) -} - -// NewVerifyVPRequestWithBody generates requests for VerifyVP with any type of body -func NewVerifyVPRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/verifier/vp") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewListTrustedRequest generates requests for ListTrusted -func NewListTrustedRequest(server string, credentialType string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "credentialType", runtime.ParamLocationPath, credentialType) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/verifier/%s/trusted", 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 -} - -// NewListUntrustedRequest generates requests for ListUntrusted -func NewListUntrustedRequest(server string, credentialType string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "credentialType", runtime.ParamLocationPath, credentialType) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vcr/v2/verifier/%s/untrusted", 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 -} - -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 { - // CreateVPWithBodyWithResponse request with any body - CreateVPWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateVPResponse, error) - - CreateVPWithResponse(ctx context.Context, body CreateVPJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateVPResponse, error) - - // GetCredentialsInWalletWithResponse request - GetCredentialsInWalletWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*GetCredentialsInWalletResponse, error) - - // LoadVCWithBodyWithResponse request with any body - LoadVCWithBodyWithResponse(ctx context.Context, did string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LoadVCResponse, error) - - LoadVCWithResponse(ctx context.Context, did string, body LoadVCJSONRequestBody, reqEditors ...RequestEditorFn) (*LoadVCResponse, error) - - // RemoveCredentialFromWalletWithResponse request - RemoveCredentialFromWalletWithResponse(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*RemoveCredentialFromWalletResponse, error) - - // IssueVCWithBodyWithResponse request with any body - IssueVCWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IssueVCResponse, error) - - IssueVCWithResponse(ctx context.Context, body IssueVCJSONRequestBody, reqEditors ...RequestEditorFn) (*IssueVCResponse, error) - - // SearchIssuedVCsWithResponse request - SearchIssuedVCsWithResponse(ctx context.Context, params *SearchIssuedVCsParams, reqEditors ...RequestEditorFn) (*SearchIssuedVCsResponse, error) - - // RevokeVCWithResponse request - RevokeVCWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*RevokeVCResponse, error) - - // SearchVCsWithBodyWithResponse request with any body - SearchVCsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SearchVCsResponse, error) - - SearchVCsWithResponse(ctx context.Context, body SearchVCsJSONRequestBody, reqEditors ...RequestEditorFn) (*SearchVCsResponse, error) - - // ResolveVCWithResponse request - ResolveVCWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ResolveVCResponse, error) - - // UntrustIssuerWithBodyWithResponse request with any body - UntrustIssuerWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UntrustIssuerResponse, error) - - UntrustIssuerWithResponse(ctx context.Context, body UntrustIssuerJSONRequestBody, reqEditors ...RequestEditorFn) (*UntrustIssuerResponse, error) - - // TrustIssuerWithBodyWithResponse request with any body - TrustIssuerWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TrustIssuerResponse, error) - - TrustIssuerWithResponse(ctx context.Context, body TrustIssuerJSONRequestBody, reqEditors ...RequestEditorFn) (*TrustIssuerResponse, error) - - // VerifyVCWithBodyWithResponse request with any body - VerifyVCWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*VerifyVCResponse, error) - - VerifyVCWithResponse(ctx context.Context, body VerifyVCJSONRequestBody, reqEditors ...RequestEditorFn) (*VerifyVCResponse, error) - - // VerifyVPWithBodyWithResponse request with any body - VerifyVPWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*VerifyVPResponse, error) - - VerifyVPWithResponse(ctx context.Context, body VerifyVPJSONRequestBody, reqEditors ...RequestEditorFn) (*VerifyVPResponse, error) - - // ListTrustedWithResponse request - ListTrustedWithResponse(ctx context.Context, credentialType string, reqEditors ...RequestEditorFn) (*ListTrustedResponse, error) - - // ListUntrustedWithResponse request - ListUntrustedWithResponse(ctx context.Context, credentialType string, reqEditors ...RequestEditorFn) (*ListUntrustedResponse, error) -} - -type CreateVPResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *VerifiablePresentation - 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 CreateVPResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r CreateVPResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetCredentialsInWalletResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]VerifiableCredential - 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 GetCredentialsInWalletResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetCredentialsInWalletResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type LoadVCResponse 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 LoadVCResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r LoadVCResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type RemoveCredentialFromWalletResponse 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 RemoveCredentialFromWalletResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r RemoveCredentialFromWalletResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type IssueVCResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *VerifiableCredential - 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 IssueVCResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r IssueVCResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type SearchIssuedVCsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *SearchVCResults - 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 SearchIssuedVCsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r SearchIssuedVCsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type RevokeVCResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Revocation - 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 RevokeVCResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r RevokeVCResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type SearchVCsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *SearchVCResults - 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 SearchVCsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r SearchVCsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ResolveVCResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *VerifiableCredential - 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 ResolveVCResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ResolveVCResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type UntrustIssuerResponse 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 UntrustIssuerResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r UntrustIssuerResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type TrustIssuerResponse 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 TrustIssuerResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r TrustIssuerResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type VerifyVCResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *VCVerificationResult - 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 VerifyVCResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r VerifyVCResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type VerifyVPResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *VPVerificationResult - 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 VerifyVPResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r VerifyVPResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ListTrustedResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]string - 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 ListTrustedResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListTrustedResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ListUntrustedResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]string - 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 ListUntrustedResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListUntrustedResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -// CreateVPWithBodyWithResponse request with arbitrary body returning *CreateVPResponse -func (c *ClientWithResponses) CreateVPWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateVPResponse, error) { - rsp, err := c.CreateVPWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateVPResponse(rsp) -} - -func (c *ClientWithResponses) CreateVPWithResponse(ctx context.Context, body CreateVPJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateVPResponse, error) { - rsp, err := c.CreateVP(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateVPResponse(rsp) -} - -// GetCredentialsInWalletWithResponse request returning *GetCredentialsInWalletResponse -func (c *ClientWithResponses) GetCredentialsInWalletWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*GetCredentialsInWalletResponse, error) { - rsp, err := c.GetCredentialsInWallet(ctx, did, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetCredentialsInWalletResponse(rsp) -} - -// LoadVCWithBodyWithResponse request with arbitrary body returning *LoadVCResponse -func (c *ClientWithResponses) LoadVCWithBodyWithResponse(ctx context.Context, did string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LoadVCResponse, error) { - rsp, err := c.LoadVCWithBody(ctx, did, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseLoadVCResponse(rsp) -} - -func (c *ClientWithResponses) LoadVCWithResponse(ctx context.Context, did string, body LoadVCJSONRequestBody, reqEditors ...RequestEditorFn) (*LoadVCResponse, error) { - rsp, err := c.LoadVC(ctx, did, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseLoadVCResponse(rsp) -} - -// RemoveCredentialFromWalletWithResponse request returning *RemoveCredentialFromWalletResponse -func (c *ClientWithResponses) RemoveCredentialFromWalletWithResponse(ctx context.Context, did string, id string, reqEditors ...RequestEditorFn) (*RemoveCredentialFromWalletResponse, error) { - rsp, err := c.RemoveCredentialFromWallet(ctx, did, id, reqEditors...) - if err != nil { - return nil, err - } - return ParseRemoveCredentialFromWalletResponse(rsp) -} - -// IssueVCWithBodyWithResponse request with arbitrary body returning *IssueVCResponse -func (c *ClientWithResponses) IssueVCWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IssueVCResponse, error) { - rsp, err := c.IssueVCWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseIssueVCResponse(rsp) -} - -func (c *ClientWithResponses) IssueVCWithResponse(ctx context.Context, body IssueVCJSONRequestBody, reqEditors ...RequestEditorFn) (*IssueVCResponse, error) { - rsp, err := c.IssueVC(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseIssueVCResponse(rsp) -} - -// SearchIssuedVCsWithResponse request returning *SearchIssuedVCsResponse -func (c *ClientWithResponses) SearchIssuedVCsWithResponse(ctx context.Context, params *SearchIssuedVCsParams, reqEditors ...RequestEditorFn) (*SearchIssuedVCsResponse, error) { - rsp, err := c.SearchIssuedVCs(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseSearchIssuedVCsResponse(rsp) -} - -// RevokeVCWithResponse request returning *RevokeVCResponse -func (c *ClientWithResponses) RevokeVCWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*RevokeVCResponse, error) { - rsp, err := c.RevokeVC(ctx, id, reqEditors...) - if err != nil { - return nil, err - } - return ParseRevokeVCResponse(rsp) -} - -// SearchVCsWithBodyWithResponse request with arbitrary body returning *SearchVCsResponse -func (c *ClientWithResponses) SearchVCsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SearchVCsResponse, error) { - rsp, err := c.SearchVCsWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseSearchVCsResponse(rsp) -} - -func (c *ClientWithResponses) SearchVCsWithResponse(ctx context.Context, body SearchVCsJSONRequestBody, reqEditors ...RequestEditorFn) (*SearchVCsResponse, error) { - rsp, err := c.SearchVCs(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseSearchVCsResponse(rsp) -} - -// ResolveVCWithResponse request returning *ResolveVCResponse -func (c *ClientWithResponses) ResolveVCWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ResolveVCResponse, error) { - rsp, err := c.ResolveVC(ctx, id, reqEditors...) - if err != nil { - return nil, err - } - return ParseResolveVCResponse(rsp) -} - -// UntrustIssuerWithBodyWithResponse request with arbitrary body returning *UntrustIssuerResponse -func (c *ClientWithResponses) UntrustIssuerWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UntrustIssuerResponse, error) { - rsp, err := c.UntrustIssuerWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUntrustIssuerResponse(rsp) -} - -func (c *ClientWithResponses) UntrustIssuerWithResponse(ctx context.Context, body UntrustIssuerJSONRequestBody, reqEditors ...RequestEditorFn) (*UntrustIssuerResponse, error) { - rsp, err := c.UntrustIssuer(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUntrustIssuerResponse(rsp) -} - -// TrustIssuerWithBodyWithResponse request with arbitrary body returning *TrustIssuerResponse -func (c *ClientWithResponses) TrustIssuerWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TrustIssuerResponse, error) { - rsp, err := c.TrustIssuerWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseTrustIssuerResponse(rsp) -} - -func (c *ClientWithResponses) TrustIssuerWithResponse(ctx context.Context, body TrustIssuerJSONRequestBody, reqEditors ...RequestEditorFn) (*TrustIssuerResponse, error) { - rsp, err := c.TrustIssuer(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseTrustIssuerResponse(rsp) -} - -// VerifyVCWithBodyWithResponse request with arbitrary body returning *VerifyVCResponse -func (c *ClientWithResponses) VerifyVCWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*VerifyVCResponse, error) { - rsp, err := c.VerifyVCWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseVerifyVCResponse(rsp) -} - -func (c *ClientWithResponses) VerifyVCWithResponse(ctx context.Context, body VerifyVCJSONRequestBody, reqEditors ...RequestEditorFn) (*VerifyVCResponse, error) { - rsp, err := c.VerifyVC(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseVerifyVCResponse(rsp) -} - -// VerifyVPWithBodyWithResponse request with arbitrary body returning *VerifyVPResponse -func (c *ClientWithResponses) VerifyVPWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*VerifyVPResponse, error) { - rsp, err := c.VerifyVPWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseVerifyVPResponse(rsp) -} - -func (c *ClientWithResponses) VerifyVPWithResponse(ctx context.Context, body VerifyVPJSONRequestBody, reqEditors ...RequestEditorFn) (*VerifyVPResponse, error) { - rsp, err := c.VerifyVP(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseVerifyVPResponse(rsp) -} - -// ListTrustedWithResponse request returning *ListTrustedResponse -func (c *ClientWithResponses) ListTrustedWithResponse(ctx context.Context, credentialType string, reqEditors ...RequestEditorFn) (*ListTrustedResponse, error) { - rsp, err := c.ListTrusted(ctx, credentialType, reqEditors...) - if err != nil { - return nil, err - } - return ParseListTrustedResponse(rsp) -} - -// ListUntrustedWithResponse request returning *ListUntrustedResponse -func (c *ClientWithResponses) ListUntrustedWithResponse(ctx context.Context, credentialType string, reqEditors ...RequestEditorFn) (*ListUntrustedResponse, error) { - rsp, err := c.ListUntrusted(ctx, credentialType, reqEditors...) - if err != nil { - return nil, err - } - return ParseListUntrustedResponse(rsp) -} - -// ParseCreateVPResponse parses an HTTP response from a CreateVPWithResponse call -func ParseCreateVPResponse(rsp *http.Response) (*CreateVPResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &CreateVPResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest VerifiablePresentation - 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 -} - -// ParseGetCredentialsInWalletResponse parses an HTTP response from a GetCredentialsInWalletWithResponse call -func ParseGetCredentialsInWalletResponse(rsp *http.Response) (*GetCredentialsInWalletResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetCredentialsInWalletResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []VerifiableCredential - 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 -} - -// ParseLoadVCResponse parses an HTTP response from a LoadVCWithResponse call -func ParseLoadVCResponse(rsp *http.Response) (*LoadVCResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &LoadVCResponse{ - 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 -} - -// ParseRemoveCredentialFromWalletResponse parses an HTTP response from a RemoveCredentialFromWalletWithResponse call -func ParseRemoveCredentialFromWalletResponse(rsp *http.Response) (*RemoveCredentialFromWalletResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &RemoveCredentialFromWalletResponse{ - 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 -} - -// ParseIssueVCResponse parses an HTTP response from a IssueVCWithResponse call -func ParseIssueVCResponse(rsp *http.Response) (*IssueVCResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &IssueVCResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest VerifiableCredential - 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 -} - -// ParseSearchIssuedVCsResponse parses an HTTP response from a SearchIssuedVCsWithResponse call -func ParseSearchIssuedVCsResponse(rsp *http.Response) (*SearchIssuedVCsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &SearchIssuedVCsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest SearchVCResults - 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 -} - -// ParseRevokeVCResponse parses an HTTP response from a RevokeVCWithResponse call -func ParseRevokeVCResponse(rsp *http.Response) (*RevokeVCResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &RevokeVCResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Revocation - 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 -} - -// ParseSearchVCsResponse parses an HTTP response from a SearchVCsWithResponse call -func ParseSearchVCsResponse(rsp *http.Response) (*SearchVCsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &SearchVCsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest SearchVCResults - 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 -} - -// ParseResolveVCResponse parses an HTTP response from a ResolveVCWithResponse call -func ParseResolveVCResponse(rsp *http.Response) (*ResolveVCResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ResolveVCResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest VerifiableCredential - 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 -} - -// ParseUntrustIssuerResponse parses an HTTP response from a UntrustIssuerWithResponse call -func ParseUntrustIssuerResponse(rsp *http.Response) (*UntrustIssuerResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &UntrustIssuerResponse{ - 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 -} - -// ParseTrustIssuerResponse parses an HTTP response from a TrustIssuerWithResponse call -func ParseTrustIssuerResponse(rsp *http.Response) (*TrustIssuerResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &TrustIssuerResponse{ - 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 -} - -// ParseVerifyVCResponse parses an HTTP response from a VerifyVCWithResponse call -func ParseVerifyVCResponse(rsp *http.Response) (*VerifyVCResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &VerifyVCResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest VCVerificationResult - 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 -} - -// ParseVerifyVPResponse parses an HTTP response from a VerifyVPWithResponse call -func ParseVerifyVPResponse(rsp *http.Response) (*VerifyVPResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &VerifyVPResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest VPVerificationResult - 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 -} - -// ParseListTrustedResponse parses an HTTP response from a ListTrustedWithResponse call -func ParseListTrustedResponse(rsp *http.Response) (*ListTrustedResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ListTrustedResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []string - 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 -} - -// ParseListUntrustedResponse parses an HTTP response from a ListUntrustedWithResponse call -func ParseListUntrustedResponse(rsp *http.Response) (*ListUntrustedResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ListUntrustedResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []string - 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 -} diff --git a/nuts/vdr/client.gen.go b/nuts/vdr/client.gen.go deleted file mode 100644 index 1b7802d..0000000 --- a/nuts/vdr/client.gen.go +++ /dev/null @@ -1,1926 +0,0 @@ -// Package vdr provides primitives to interact with the openapi HTTP API. -// -// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. -package vdr - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "io" - "net/http" - "net/url" - "strings" - - externalRef0 "github.com/nuts-foundation/nuts-admin/nuts" - "github.com/oapi-codegen/runtime" -) - -const ( - JwtBearerAuthScopes = "jwtBearerAuth.Scopes" -) - -// Defines values for FindServicesParamsEndpointType. -const ( - Array FindServicesParamsEndpointType = "array" - Object FindServicesParamsEndpointType = "object" - String FindServicesParamsEndpointType = "string" -) - -// CreateDIDOptions Options for the DID creation. -type CreateDIDOptions struct { - // Keys Options for the key creation. - Keys *KeyCreationOptions `json:"keys,omitempty"` - - // Subject controls the DID subject to which all created DIDs are bound. If not given, a uuid is generated and returned. - Subject *string `json:"subject,omitempty"` -} - -// DIDDocument A DID document according to the W3C spec following the Nuts Method rules as defined in [Nuts RFC006] -type DIDDocument = externalRef0.DIDDocument - -// DIDDocumentMetadata The DID document metadata. -type DIDDocumentMetadata = externalRef0.DIDDocumentMetadata - -// 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"` -} - -// KeyCreationOptions Options for the key creation. -type KeyCreationOptions struct { - // AssertionKey If true, an EC keypair is generated and added to the DID Document as a assertion, authentication, capability invocation and capability delegation method. - AssertionKey bool `json:"assertionKey"` - - // EncryptionKey If true, an RSA keypair is generated and added to the DID Document as a key agreement method. - EncryptionKey bool `json:"encryptionKey"` -} - -// Service A service supported by a DID subject. -type Service = externalRef0.Service - -// SubjectCreationResult Result of a DID creation request. Contains the subject and any created DID Documents. -type SubjectCreationResult struct { - Documents []DIDDocument `json:"documents"` - - // Subject The subject of the created DID Documents. - Subject string `json:"subject"` -} - -// VerificationMethod A public key in JWK form. -type VerificationMethod = externalRef0.VerificationMethod - -// FindServicesParams defines parameters for FindServices. -type FindServicesParams struct { - // Type Type of the service to filter for. If specified, only services with the given service type are returned. - Type *string `form:"type,omitempty" json:"type,omitempty"` - - // EndpointType The data type of the service endpoint to filter for. If specified, only services with the given endpoint type are returned. - // Endpoint types as mapped as follows: - // - // - string: serviceEndpoint contains a JSON string - // - array: serviceEndpoint contains a JSON array - // - object: serviceEndpoint contains a JSON object (key-value map) - // - // If not specified, services are not filtered on their endpoint data type. - EndpointType *FindServicesParamsEndpointType `form:"endpointType,omitempty" json:"endpointType,omitempty"` -} - -// FindServicesParamsEndpointType defines parameters for FindServices. -type FindServicesParamsEndpointType string - -// CreateDIDJSONRequestBody defines body for CreateDID for application/json ContentType. -type CreateDIDJSONRequestBody = CreateDIDOptions - -// CreateServiceJSONRequestBody defines body for CreateService for application/json ContentType. -type CreateServiceJSONRequestBody = Service - -// UpdateServiceJSONRequestBody defines body for UpdateService for application/json ContentType. -type UpdateServiceJSONRequestBody = Service - -// AddVerificationMethodJSONRequestBody defines body for AddVerificationMethod for application/json ContentType. -type AddVerificationMethodJSONRequestBody = KeyCreationOptions - -// 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 { - // GetRootWebDID request - GetRootWebDID(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetTenantWebDID request - GetTenantWebDID(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ResolveDID request - ResolveDID(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ListSubjects request - ListSubjects(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - - // CreateDIDWithBody request with any body - CreateDIDWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - CreateDID(ctx context.Context, body CreateDIDJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // Deactivate request - Deactivate(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // SubjectDIDs request - SubjectDIDs(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // FindServices request - FindServices(ctx context.Context, id string, params *FindServicesParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // CreateServiceWithBody request with any body - CreateServiceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - CreateService(ctx context.Context, id string, body CreateServiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteService request - DeleteService(ctx context.Context, id string, serviceId string, reqEditors ...RequestEditorFn) (*http.Response, error) - - // UpdateServiceWithBody request with any body - UpdateServiceWithBody(ctx context.Context, id string, serviceId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - UpdateService(ctx context.Context, id string, serviceId string, body UpdateServiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // AddVerificationMethodWithBody request with any body - AddVerificationMethodWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - AddVerificationMethod(ctx context.Context, id string, body AddVerificationMethodJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) -} - -func (c *Client) GetRootWebDID(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetRootWebDIDRequest(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) GetTenantWebDID(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetTenantWebDIDRequest(c.Server, 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) 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) ListSubjects(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListSubjectsRequest(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) CreateDIDWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateDIDRequestWithBody(c.Server, contentType, body) - 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) CreateDID(ctx context.Context, body CreateDIDJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateDIDRequest(c.Server, body) - 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) Deactivate(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeactivateRequest(c.Server, 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) SubjectDIDs(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewSubjectDIDsRequest(c.Server, 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) FindServices(ctx context.Context, id string, params *FindServicesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewFindServicesRequest(c.Server, id, params) - 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) CreateServiceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateServiceRequestWithBody(c.Server, id, contentType, body) - 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) CreateService(ctx context.Context, id string, body CreateServiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateServiceRequest(c.Server, id, body) - 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, id string, serviceId string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteServiceRequest(c.Server, id, serviceId) - 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) UpdateServiceWithBody(ctx context.Context, id string, serviceId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateServiceRequestWithBody(c.Server, id, serviceId, contentType, body) - 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, id string, serviceId string, body UpdateServiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateServiceRequest(c.Server, id, serviceId, body) - 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) AddVerificationMethodWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewAddVerificationMethodRequestWithBody(c.Server, id, contentType, body) - 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, id string, body AddVerificationMethodJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewAddVerificationMethodRequest(c.Server, id, body) - 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) -} - -// NewGetRootWebDIDRequest generates requests for GetRootWebDID -func NewGetRootWebDIDRequest(server string) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/.well-known/did.json") - 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 -} - -// NewGetTenantWebDIDRequest generates requests for GetTenantWebDID -func NewGetTenantWebDIDRequest(server string, id string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, 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("/iam/%s/did.json", 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 -} - -// NewResolveDIDRequest generates requests for ResolveDID -func NewResolveDIDRequest(server string, did string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = did - - 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 -} - -// NewListSubjectsRequest generates requests for ListSubjects -func NewListSubjectsRequest(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/subject") - 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 -} - -// NewCreateDIDRequest calls the generic CreateDID builder with application/json body -func NewCreateDIDRequest(server string, body CreateDIDJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewCreateDIDRequestWithBody(server, "application/json", bodyReader) -} - -// NewCreateDIDRequestWithBody generates requests for CreateDID with any type of body -func NewCreateDIDRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vdr/v2/subject") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewDeactivateRequest generates requests for Deactivate -func NewDeactivateRequest(server string, id string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = id - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vdr/v2/subject/%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 -} - -// NewSubjectDIDsRequest generates requests for SubjectDIDs -func NewSubjectDIDsRequest(server string, id string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = id - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vdr/v2/subject/%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 -} - -// NewFindServicesRequest generates requests for FindServices -func NewFindServicesRequest(server string, id string, params *FindServicesParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = id - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vdr/v2/subject/%s/service", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Type != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "type", runtime.ParamLocationQuery, *params.Type); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.EndpointType != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "endpointType", runtime.ParamLocationQuery, *params.EndpointType); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewCreateServiceRequest calls the generic CreateService builder with application/json body -func NewCreateServiceRequest(server string, id string, body CreateServiceJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewCreateServiceRequestWithBody(server, id, "application/json", bodyReader) -} - -// NewCreateServiceRequestWithBody generates requests for CreateService with any type of body -func NewCreateServiceRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = id - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vdr/v2/subject/%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(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewDeleteServiceRequest generates requests for DeleteService -func NewDeleteServiceRequest(server string, id string, serviceId string) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = id - - var pathParam1 string - - pathParam1 = serviceId - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vdr/v2/subject/%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 calls the generic UpdateService builder with application/json body -func NewUpdateServiceRequest(server string, id string, serviceId string, body UpdateServiceJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewUpdateServiceRequestWithBody(server, id, serviceId, "application/json", bodyReader) -} - -// NewUpdateServiceRequestWithBody generates requests for UpdateService with any type of body -func NewUpdateServiceRequestWithBody(server string, id string, serviceId string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = id - - var pathParam1 string - - pathParam1 = serviceId - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vdr/v2/subject/%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(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewAddVerificationMethodRequest calls the generic AddVerificationMethod builder with application/json body -func NewAddVerificationMethodRequest(server string, id string, body AddVerificationMethodJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewAddVerificationMethodRequestWithBody(server, id, "application/json", bodyReader) -} - -// NewAddVerificationMethodRequestWithBody generates requests for AddVerificationMethod with any type of body -func NewAddVerificationMethodRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0 = id - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/internal/vdr/v2/subject/%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(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - 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 { - // GetRootWebDIDWithResponse request - GetRootWebDIDWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetRootWebDIDResponse, error) - - // GetTenantWebDIDWithResponse request - GetTenantWebDIDWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetTenantWebDIDResponse, error) - - // ResolveDIDWithResponse request - ResolveDIDWithResponse(ctx context.Context, did string, reqEditors ...RequestEditorFn) (*ResolveDIDResponse, error) - - // ListSubjectsWithResponse request - ListSubjectsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListSubjectsResponse, error) - - // CreateDIDWithBodyWithResponse request with any body - CreateDIDWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateDIDResponse, error) - - CreateDIDWithResponse(ctx context.Context, body CreateDIDJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateDIDResponse, error) - - // DeactivateWithResponse request - DeactivateWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeactivateResponse, error) - - // SubjectDIDsWithResponse request - SubjectDIDsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*SubjectDIDsResponse, error) - - // FindServicesWithResponse request - FindServicesWithResponse(ctx context.Context, id string, params *FindServicesParams, reqEditors ...RequestEditorFn) (*FindServicesResponse, error) - - // CreateServiceWithBodyWithResponse request with any body - CreateServiceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateServiceResponse, error) - - CreateServiceWithResponse(ctx context.Context, id string, body CreateServiceJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateServiceResponse, error) - - // DeleteServiceWithResponse request - DeleteServiceWithResponse(ctx context.Context, id string, serviceId string, reqEditors ...RequestEditorFn) (*DeleteServiceResponse, error) - - // UpdateServiceWithBodyWithResponse request with any body - UpdateServiceWithBodyWithResponse(ctx context.Context, id string, serviceId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateServiceResponse, error) - - UpdateServiceWithResponse(ctx context.Context, id string, serviceId string, body UpdateServiceJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateServiceResponse, error) - - // AddVerificationMethodWithBodyWithResponse request with any body - AddVerificationMethodWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddVerificationMethodResponse, error) - - AddVerificationMethodWithResponse(ctx context.Context, id string, body AddVerificationMethodJSONRequestBody, reqEditors ...RequestEditorFn) (*AddVerificationMethodResponse, error) -} - -type GetRootWebDIDResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *DIDDocument -} - -// Status returns HTTPResponse.Status -func (r GetRootWebDIDResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetRootWebDIDResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetTenantWebDIDResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *DIDDocument -} - -// Status returns HTTPResponse.Status -func (r GetTenantWebDIDResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetTenantWebDIDResponse) 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 ListSubjectsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *map[string][]string - 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 ListSubjectsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListSubjectsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type CreateDIDResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *SubjectCreationResult - 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 DeactivateResponse 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 DeactivateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeactivateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type SubjectDIDsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]string - 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 SubjectDIDsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r SubjectDIDsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type FindServicesResponse 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 FindServicesResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r FindServicesResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type CreateServiceResponse 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 CreateServiceResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r CreateServiceResponse) 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 -} - -// GetRootWebDIDWithResponse request returning *GetRootWebDIDResponse -func (c *ClientWithResponses) GetRootWebDIDWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetRootWebDIDResponse, error) { - rsp, err := c.GetRootWebDID(ctx, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetRootWebDIDResponse(rsp) -} - -// GetTenantWebDIDWithResponse request returning *GetTenantWebDIDResponse -func (c *ClientWithResponses) GetTenantWebDIDWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetTenantWebDIDResponse, error) { - rsp, err := c.GetTenantWebDID(ctx, id, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetTenantWebDIDResponse(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) -} - -// ListSubjectsWithResponse request returning *ListSubjectsResponse -func (c *ClientWithResponses) ListSubjectsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListSubjectsResponse, error) { - rsp, err := c.ListSubjects(ctx, reqEditors...) - if err != nil { - return nil, err - } - return ParseListSubjectsResponse(rsp) -} - -// CreateDIDWithBodyWithResponse request with arbitrary body returning *CreateDIDResponse -func (c *ClientWithResponses) CreateDIDWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateDIDResponse, error) { - rsp, err := c.CreateDIDWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateDIDResponse(rsp) -} - -func (c *ClientWithResponses) CreateDIDWithResponse(ctx context.Context, body CreateDIDJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateDIDResponse, error) { - rsp, err := c.CreateDID(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateDIDResponse(rsp) -} - -// DeactivateWithResponse request returning *DeactivateResponse -func (c *ClientWithResponses) DeactivateWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeactivateResponse, error) { - rsp, err := c.Deactivate(ctx, id, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeactivateResponse(rsp) -} - -// SubjectDIDsWithResponse request returning *SubjectDIDsResponse -func (c *ClientWithResponses) SubjectDIDsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*SubjectDIDsResponse, error) { - rsp, err := c.SubjectDIDs(ctx, id, reqEditors...) - if err != nil { - return nil, err - } - return ParseSubjectDIDsResponse(rsp) -} - -// FindServicesWithResponse request returning *FindServicesResponse -func (c *ClientWithResponses) FindServicesWithResponse(ctx context.Context, id string, params *FindServicesParams, reqEditors ...RequestEditorFn) (*FindServicesResponse, error) { - rsp, err := c.FindServices(ctx, id, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseFindServicesResponse(rsp) -} - -// CreateServiceWithBodyWithResponse request with arbitrary body returning *CreateServiceResponse -func (c *ClientWithResponses) CreateServiceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateServiceResponse, error) { - rsp, err := c.CreateServiceWithBody(ctx, id, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateServiceResponse(rsp) -} - -func (c *ClientWithResponses) CreateServiceWithResponse(ctx context.Context, id string, body CreateServiceJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateServiceResponse, error) { - rsp, err := c.CreateService(ctx, id, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateServiceResponse(rsp) -} - -// DeleteServiceWithResponse request returning *DeleteServiceResponse -func (c *ClientWithResponses) DeleteServiceWithResponse(ctx context.Context, id string, serviceId string, reqEditors ...RequestEditorFn) (*DeleteServiceResponse, error) { - rsp, err := c.DeleteService(ctx, id, serviceId, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteServiceResponse(rsp) -} - -// UpdateServiceWithBodyWithResponse request with arbitrary body returning *UpdateServiceResponse -func (c *ClientWithResponses) UpdateServiceWithBodyWithResponse(ctx context.Context, id string, serviceId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateServiceResponse, error) { - rsp, err := c.UpdateServiceWithBody(ctx, id, serviceId, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateServiceResponse(rsp) -} - -func (c *ClientWithResponses) UpdateServiceWithResponse(ctx context.Context, id string, serviceId string, body UpdateServiceJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateServiceResponse, error) { - rsp, err := c.UpdateService(ctx, id, serviceId, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateServiceResponse(rsp) -} - -// AddVerificationMethodWithBodyWithResponse request with arbitrary body returning *AddVerificationMethodResponse -func (c *ClientWithResponses) AddVerificationMethodWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddVerificationMethodResponse, error) { - rsp, err := c.AddVerificationMethodWithBody(ctx, id, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseAddVerificationMethodResponse(rsp) -} - -func (c *ClientWithResponses) AddVerificationMethodWithResponse(ctx context.Context, id string, body AddVerificationMethodJSONRequestBody, reqEditors ...RequestEditorFn) (*AddVerificationMethodResponse, error) { - rsp, err := c.AddVerificationMethod(ctx, id, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseAddVerificationMethodResponse(rsp) -} - -// ParseGetRootWebDIDResponse parses an HTTP response from a GetRootWebDIDWithResponse call -func ParseGetRootWebDIDResponse(rsp *http.Response) (*GetRootWebDIDResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetRootWebDIDResponse{ - 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 - - } - - return response, nil -} - -// ParseGetTenantWebDIDResponse parses an HTTP response from a GetTenantWebDIDWithResponse call -func ParseGetTenantWebDIDResponse(rsp *http.Response) (*GetTenantWebDIDResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetTenantWebDIDResponse{ - 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 - - } - - 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 -} - -// ParseListSubjectsResponse parses an HTTP response from a ListSubjectsWithResponse call -func ParseListSubjectsResponse(rsp *http.Response) (*ListSubjectsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ListSubjectsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest map[string][]string - 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 -} - -// 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 SubjectCreationResult - 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 -} - -// ParseDeactivateResponse parses an HTTP response from a DeactivateWithResponse call -func ParseDeactivateResponse(rsp *http.Response) (*DeactivateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeactivateResponse{ - 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 -} - -// ParseSubjectDIDsResponse parses an HTTP response from a SubjectDIDsWithResponse call -func ParseSubjectDIDsResponse(rsp *http.Response) (*SubjectDIDsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &SubjectDIDsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []string - 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 -} - -// ParseFindServicesResponse parses an HTTP response from a FindServicesWithResponse call -func ParseFindServicesResponse(rsp *http.Response) (*FindServicesResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &FindServicesResponse{ - 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 -} - -// ParseCreateServiceResponse parses an HTTP response from a CreateServiceWithResponse call -func ParseCreateServiceResponse(rsp *http.Response) (*CreateServiceResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &CreateServiceResponse{ - 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 -} - -// 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 -}