Skip to content

Commit

Permalink
Use go-nuts-client for better Nuts node API support
Browse files Browse the repository at this point in the history
  • Loading branch information
reinkrul committed Sep 18, 2024
1 parent 4de3586 commit 302352c
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 5,986 deletions.
955 changes: 0 additions & 955 deletions discovery/nuts_discovery_client.gen.go

This file was deleted.

23 changes: 7 additions & 16 deletions discovery/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
35 changes: 25 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
Loading

0 comments on commit 302352c

Please sign in to comment.