diff --git a/Earthfile b/Earthfile index c6e325f761..48fb17d0cd 100644 --- a/Earthfile +++ b/Earthfile @@ -1,7 +1,7 @@ VERSION 0.8 PROJECT FormanceHQ/stack -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core sources: FROM core+base-image diff --git a/components/Earthfile b/components/Earthfile index ba1758f0b2..a16ae5036b 100644 --- a/components/Earthfile +++ b/components/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT .. AS stack deploy: diff --git a/components/fctl/Earthfile b/components/fctl/Earthfile index 4070956fcf..b7e648e9d3 100644 --- a/components/fctl/Earthfile +++ b/components/fctl/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT ../../releases AS releases IMPORT .. AS components diff --git a/components/ledger/Earthfile b/components/ledger/Earthfile index 1407fa3f8d..68ed300451 100644 --- a/components/ledger/Earthfile +++ b/components/ledger/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT .. AS components @@ -45,11 +45,47 @@ build-image: tests: FROM core+builder-image + RUN go install github.com/onsi/ginkgo/v2/ginkgo@latest + COPY (+sources/*) /src WORKDIR /src/components/ledger COPY --dir --pass-args (+generate/*) . - WITH DOCKER --pull=postgres:15-alpine - DO --pass-args core+GO_TESTS + + ARG includeIntegrationTests="true" + ARG coverage="" + ARG debug=false + + ENV DEBUG=$debug + ENV CGO_ENABLED=1 # required for -race + RUN apk add gcc musl-dev + + LET goFlags="-race" + IF [ "$coverage" = "true" ] + SET goFlags="$goFlags -covermode=atomic" + SET goFlags="$goFlags -coverpkg=github.com/formancehq/stack/components/ledger/internal/..." + SET goFlags="$goFlags,github.com/formancehq/stack/components/ledger/cmd/..." + SET goFlags="$goFlags -coverprofile cover.out" + END + IF [ "$includeIntegrationTests" = "true" ] + SET goFlags="$goFlags -tags it" + WITH DOCKER \ + --pull=postgres:15-alpine \ + --pull=clickhouse/clickhouse-server:head \ + --pull=elasticsearch:8.14.3 + RUN --mount type=cache,id=gopkgcache,target=${GOPATH}/pkg/mod \ + --mount type=cache,id=gobuildcache,target=/root/.cache/go-build \ + ginkgo -r -p $goFlags + END + ELSE + RUN --mount type=cache,id=gopkgcache,target=${GOPATH}/pkg/mod \ + --mount type=cache,id=gobuildcache,target=/root/.cache/go-build \ + ginkgo -r -p $goFlags + END + IF [ "$coverage" = "true" ] + # exclude files suffixed with _generated.go, these are mocks used by tests + RUN cat cover.out | grep -v "_generated.go" > cover2.out + RUN mv cover2.out cover.out + SAVE ARTIFACT cover.out AS LOCAL cover.out END deploy: @@ -69,7 +105,7 @@ lint: COPY (+sources/*) /src COPY --pass-args +tidy/go.* . WORKDIR /src/components/ledger - DO --pass-args stack+GO_LINT + DO --pass-args stack+GO_LINT --ADDITIONAL_ARGUMENTS="--build-tags it" SAVE ARTIFACT cmd AS LOCAL cmd SAVE ARTIFACT internal AS LOCAL internal SAVE ARTIFACT pkg AS LOCAL pkg @@ -138,4 +174,16 @@ tidy: DO --pass-args stack+GO_TIDY release: - BUILD --pass-args stack+goreleaser --path=components/ledger \ No newline at end of file + BUILD --pass-args stack+goreleaser --path=components/ledger + +generate-sdk: + FROM node:20-alpine + RUN apk update && apk add yq git + WORKDIR /src + COPY (stack+speakeasy/speakeasy) /bin/speakeasy + ARG version=v0.0.0 + COPY openapi/v2.yaml openapi.yaml + COPY --dir pkg/client client + RUN --secret SPEAKEASY_API_KEY speakeasy generate sdk -s ./openapi.yaml -o ./client -l go + + SAVE ARTIFACT client AS LOCAL ./pkg/client diff --git a/components/ledger/benchmarks/ledger_test.go b/components/ledger/benchmarks/ledger_test.go index 0afb8c4363..754ac8740c 100644 --- a/components/ledger/benchmarks/ledger_test.go +++ b/components/ledger/benchmarks/ledger_test.go @@ -1,3 +1,5 @@ +//go:build it + package benchmarks import ( diff --git a/components/ledger/benchmarks/main_test.go b/components/ledger/benchmarks/main_test.go deleted file mode 100644 index 375b5c5d1e..0000000000 --- a/components/ledger/benchmarks/main_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package benchmarks - -import ( - "github.com/formancehq/stack/libs/go-libs/testing/docker" - "github.com/formancehq/stack/libs/go-libs/testing/utils" - dockerlib "github.com/ory/dockertest/v3/docker" - "testing" - - "github.com/formancehq/stack/libs/go-libs/logging" - "github.com/formancehq/stack/libs/go-libs/testing/platform/pgtesting" -) - -func TestMain(m *testing.M) { - utils.WithTestMain(func(t *utils.TestingTForMain) int { - pgtesting.CreatePostgresServer( - t, - docker.NewPool(t, logging.Testing()), - pgtesting.WithDockerHostConfigOption(func(hostConfig *dockerlib.HostConfig) { - hostConfig.CPUCount = 2 - }), - ) - - return m.Run() - }) -} diff --git a/components/ledger/cmd/container.go b/components/ledger/cmd/container.go index 62919c87f2..a004fc82f4 100644 --- a/components/ledger/cmd/container.go +++ b/components/ledger/cmd/container.go @@ -18,7 +18,7 @@ func resolveOptions(cmd *cobra.Command, userOptions ...fx.Option) []fx.Option { options := make([]fx.Option, 0) options = append(options, fx.NopLogger) - numscriptCacheMaxCountFlag, _ := cmd.Flags().GetInt(numscriptCacheMaxCountFlag) + numscriptCacheMaxCountFlag, _ := cmd.Flags().GetInt(NumscriptCacheMaxCountFlag) ledgerBatchSizeFlag, _ := cmd.Flags().GetInt(ledgerBatchSizeFlag) options = append(options, diff --git a/components/ledger/cmd/root.go b/components/ledger/cmd/root.go index fa063f1788..cb072a9108 100644 --- a/components/ledger/cmd/root.go +++ b/components/ledger/cmd/root.go @@ -17,7 +17,7 @@ import ( ) const ( - bindFlag = "bind" + BindFlag = "bind" ) var ( @@ -49,7 +49,7 @@ func NewRootCommand() *cobra.Command { root.AddCommand(NewDocCommand()) - root.PersistentFlags().String(bindFlag, "0.0.0.0:3068", "API bind address") + root.PersistentFlags().String(BindFlag, "0.0.0.0:3068", "API bind address") service.AddFlags(root.PersistentFlags()) otlpmetrics.AddFlags(root.PersistentFlags()) diff --git a/components/ledger/cmd/serve.go b/components/ledger/cmd/serve.go index 4fe97eb719..3addc2be88 100644 --- a/components/ledger/cmd/serve.go +++ b/components/ledger/cmd/serve.go @@ -19,21 +19,21 @@ import ( ) const ( - ballastSizeInBytesFlag = "ballast-size" - numscriptCacheMaxCountFlag = "numscript-cache-max-count" + BallastSizeInBytesFlag = "ballast-size" + NumscriptCacheMaxCountFlag = "numscript-cache-max-count" ledgerBatchSizeFlag = "ledger-batch-size" - readOnlyFlag = "read-only" - autoUpgradeFlag = "auto-upgrade" + ReadOnlyFlag = "read-only" + AutoUpgradeFlag = "auto-upgrade" ) func NewServe() *cobra.Command { cmd := &cobra.Command{ Use: "serve", RunE: func(cmd *cobra.Command, args []string) error { - readOnly, _ := cmd.Flags().GetBool(readOnlyFlag) - autoUpgrade, _ := cmd.Flags().GetBool(autoUpgradeFlag) - ballastSize, _ := cmd.Flags().GetUint(ballastSizeInBytesFlag) - bind, _ := cmd.Flags().GetString(bindFlag) + readOnly, _ := cmd.Flags().GetBool(ReadOnlyFlag) + autoUpgrade, _ := cmd.Flags().GetBool(AutoUpgradeFlag) + ballastSize, _ := cmd.Flags().GetUint(BallastSizeInBytesFlag) + bind, _ := cmd.Flags().GetString(BindFlag) return service.New(cmd.OutOrStdout(), resolveOptions( cmd, @@ -67,11 +67,11 @@ func NewServe() *cobra.Command { )...).Run(cmd) }, } - cmd.Flags().Uint(ballastSizeInBytesFlag, 0, "Ballast size in bytes, default to 0") - cmd.Flags().Int(numscriptCacheMaxCountFlag, 1024, "Numscript cache max count") + cmd.Flags().Uint(BallastSizeInBytesFlag, 0, "Ballast size in bytes, default to 0") + cmd.Flags().Int(NumscriptCacheMaxCountFlag, 1024, "Numscript cache max count") cmd.Flags().Int(ledgerBatchSizeFlag, 50, "ledger batch size") - cmd.Flags().Bool(readOnlyFlag, false, "Read only mode") - cmd.Flags().Bool(autoUpgradeFlag, false, "Automatically upgrade all schemas") + cmd.Flags().Bool(ReadOnlyFlag, false, "Read only mode") + cmd.Flags().Bool(AutoUpgradeFlag, false, "Automatically upgrade all schemas") return cmd } diff --git a/components/ledger/go.mod b/components/ledger/go.mod index a0e1ba8e6d..f1d2dd718b 100644 --- a/components/ledger/go.mod +++ b/components/ledger/go.mod @@ -4,11 +4,18 @@ go 1.22 toolchain go1.22.6 +replace github.com/formancehq/stack/ledger/client => ./pkg/client + +replace github.com/formancehq/stack/libs/go-libs => ../../libs/go-libs + +replace github.com/formancehq/stack/libs/core => ../../libs/core + require ( - github.com/ThreeDotsLabs/watermill v1.3.5 - github.com/alitto/pond v1.8.3 + github.com/ThreeDotsLabs/watermill v1.3.7 + github.com/alitto/pond v1.9.2 github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 github.com/bluele/gcache v0.0.2 + github.com/formancehq/stack/ledger/client v0.0.0-00010101000000-000000000000 github.com/formancehq/stack/libs/core v0.0.0-00010101000000-000000000000 github.com/formancehq/stack/libs/go-libs v0.0.0-00010101000000-000000000000 github.com/go-chi/chi/v5 v5.1.0 @@ -18,17 +25,18 @@ require ( github.com/jackc/pgx/v5 v5.6.0 github.com/lib/pq v1.10.9 github.com/logrusorgru/aurora v2.0.3+incompatible + github.com/onsi/ginkgo/v2 v2.20.2 github.com/pborman/uuid v1.2.1 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 - github.com/uptrace/bun v1.2.1 - github.com/uptrace/bun/dialect/pgdialect v1.2.1 - go.opentelemetry.io/otel v1.28.0 - go.opentelemetry.io/otel/metric v1.28.0 - go.opentelemetry.io/otel/trace v1.28.0 + github.com/uptrace/bun v1.2.3 + github.com/uptrace/bun/dialect/pgdialect v1.2.3 + go.opentelemetry.io/otel v1.29.0 + go.opentelemetry.io/otel/metric v1.29.0 + go.opentelemetry.io/otel/trace v1.29.0 go.uber.org/fx v1.22.2 go.uber.org/mock v0.4.0 ) @@ -43,7 +51,6 @@ require ( github.com/ThreeDotsLabs/watermill-http/v2 v2.3.0 // indirect github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.1 // indirect github.com/ThreeDotsLabs/watermill-nats/v2 v2.0.2 // indirect - github.com/ajg/form v1.5.1 // indirect github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0 // indirect github.com/aws/aws-sdk-go-v2 v1.30.4 // indirect github.com/aws/aws-sdk-go-v2/config v1.27.28 // indirect @@ -64,15 +71,16 @@ require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dnwe/otelsarama v0.0.0-20231212173111-631a0a53d5d4 // indirect github.com/docker/cli v26.1.4+incompatible // indirect - github.com/docker/docker v27.1.2+incompatible // indirect + github.com/docker/docker v27.1.1+incompatible // indirect github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/eapache/go-resiliency v1.7.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect github.com/eapache/queue v1.1.0 // indirect + github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/go-chi/chi v4.1.2+incompatible // indirect - github.com/go-chi/render v1.0.2 // indirect + github.com/go-chi/chi v4.0.2+incompatible // indirect + github.com/go-chi/render v1.0.1 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect @@ -80,10 +88,10 @@ require ( github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect + github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/gorilla/mux v1.8.0 // indirect - github.com/gorilla/schema v1.4.1 // indirect + github.com/gorilla/schema v1.2.0 // indirect github.com/gorilla/securecookie v1.1.1 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -113,7 +121,7 @@ require ( github.com/nats-io/nkeys v0.4.7 // indirect github.com/nats-io/nuid v1.0.1 // indirect github.com/oklog/ulid v1.3.1 // indirect - github.com/onsi/ginkgo/v2 v2.20.0 // indirect + github.com/onsi/gomega v1.34.2 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/opencontainers/runc v1.1.13 // indirect @@ -121,9 +129,10 @@ require ( github.com/pierrec/lz4/v4 v4.1.21 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect + github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/riandyrn/otelchi v0.9.0 // indirect - github.com/rs/cors v1.11.0 // indirect + github.com/rs/cors v1.10.1 // indirect github.com/shirou/gopsutil/v4 v4.24.6 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/tklauser/go-sysconf v0.3.14 // indirect @@ -166,7 +175,7 @@ require ( golang.org/x/net v0.28.0 // indirect golang.org/x/oauth2 v0.20.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.23.0 // indirect + golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.17.0 // indirect golang.org/x/tools v0.24.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect @@ -177,7 +186,3 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace github.com/formancehq/stack/libs/go-libs => ../../libs/go-libs - -replace github.com/formancehq/stack/libs/core => ../../libs/core diff --git a/components/ledger/go.sum b/components/ledger/go.sum index 330399e82f..c9da8e9ac2 100644 --- a/components/ledger/go.sum +++ b/components/ledger/go.sum @@ -10,18 +10,16 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= -github.com/ThreeDotsLabs/watermill v1.3.5 h1:50JEPEhMGZQMh08ct0tfO1PsgMOAOhV3zxK2WofkbXg= -github.com/ThreeDotsLabs/watermill v1.3.5/go.mod h1:O/u/Ptyrk5MPTxSeWM5vzTtZcZfxXfO9PK9eXTYiFZY= +github.com/ThreeDotsLabs/watermill v1.3.7 h1:NV0PSTmuACVEOV4dMxRnmGXrmbz8U83LENOvpHekN7o= +github.com/ThreeDotsLabs/watermill v1.3.7/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= github.com/ThreeDotsLabs/watermill-http/v2 v2.3.0 h1:EMLYXiuFhza/p5LgoM+R49JHYbkXuNLNC6tlXyG/x0E= github.com/ThreeDotsLabs/watermill-http/v2 v2.3.0/go.mod h1:Ily2cdTrvlj9dLB8BqAy5OIzWwS8B5WrFh+Ey7wOgQQ= github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.1 h1:xqSjxMpZUROIjFTLqmKDJfOn/1zbqagcOcKE4xSxUzc= github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.1/go.mod h1:VPGwfsuZOEBcS2DKuq8DYMAMzir/eqCSXbNvMUy5bvs= github.com/ThreeDotsLabs/watermill-nats/v2 v2.0.2 h1:/87LcdSzUEdCKbJptaLE987hOVOs852b+v5pukegggo= github.com/ThreeDotsLabs/watermill-nats/v2 v2.0.2/go.mod h1:uslCjpuzANBzawXYlwx2IDyGjpv9M42U2TQH6JMMQis= -github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= -github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= -github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= +github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= +github.com/alitto/pond v1.9.2/go.mod h1:xQn3P/sHTYcU/1BR3i86IGIrilcrGC2LiS+E2+CJWsI= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0 h1:UyjtGmO0Uwl/K+zpzPwLoXzMhcN9xmnR2nrqJoBrg3c= @@ -71,8 +69,8 @@ github.com/dnwe/otelsarama v0.0.0-20231212173111-631a0a53d5d4 h1:/xc676lCNA8jgPF github.com/dnwe/otelsarama v0.0.0-20231212173111-631a0a53d5d4/go.mod h1:xLagu9ssYlykwO0rMuogWgQbqKF/96Et0ve0G9xnAHk= github.com/docker/cli v26.1.4+incompatible h1:I8PHdc0MtxEADqYJZvhBrW9bo8gawKwwenxRM7/rLu8= github.com/docker/cli v26.1.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/docker v27.1.2+incompatible h1:AhGzR1xaQIy53qCkxARaFluI00WPGtXn0AJuoQsVYTY= -github.com/docker/docker v27.1.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY= +github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -83,20 +81,22 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4A github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 h1:S92OBrGuLLZsyM5ybUzgc/mPjIYk2AZqufieooe98uw= +github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec= -github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= +github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs= +github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw= github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= -github.com/go-chi/render v1.0.2 h1:4ER/udB0+fMWB2Jlf15RV3F4A2FDuYi/9f+lFttR/Lg= -github.com/go-chi/render v1.0.2/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0= +github.com/go-chi/render v1.0.1 h1:4/5tis2cKaNdnv9zFLfXzcquC9HbeZgCnxGnKrltBS8= +github.com/go-chi/render v1.0.1/go.mod h1:pq4Rr7HbnsdaeHagklXub+p6Wd16Af5l9koip1OvJns= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -117,8 +117,8 @@ github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= -github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -127,8 +127,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E= -github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= +github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= +github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= @@ -218,10 +218,10 @@ github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/onsi/ginkgo/v2 v2.20.0 h1:PE84V2mHqoT1sglvHc8ZdQtPcwmvvt29WLEEO3xmdZw= -github.com/onsi/ginkgo/v2 v2.20.0/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= -github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= -github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= +github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= +github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= +github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= +github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= @@ -241,14 +241,16 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/puzpuzpuz/xsync/v3 v3.4.0 h1:DuVBAdXuGFHv8adVXjWWZ63pJq+NRXOWVXlKDBZ+mJ4= +github.com/puzpuzpuz/xsync/v3 v3.4.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/riandyrn/otelchi v0.9.0 h1:BuQxXR7/JF2yYOQl21Yyz5d52hns/96ecAaPUZiKQzc= github.com/riandyrn/otelchi v0.9.0/go.mod h1:iX30kllzThsf8oEcEbl3GifPJZtN4cnCWUUc+UhE4yM= 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/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po= -github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= +github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64= github.com/shirou/gopsutil/v4 v4.24.6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= @@ -279,10 +281,10 @@ github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYg github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs= -github.com/uptrace/bun v1.2.1 h1:2ENAcfeCfaY5+2e7z5pXrzFKy3vS8VXvkCag6N2Yzfk= -github.com/uptrace/bun v1.2.1/go.mod h1:cNg+pWBUMmJ8rHnETgf65CEvn3aIKErrwOD6IA8e+Ec= -github.com/uptrace/bun/dialect/pgdialect v1.2.1 h1:ceP99r03u+s8ylaDE/RzgcajwGiC76Jz3nS2ZgyPQ4M= -github.com/uptrace/bun/dialect/pgdialect v1.2.1/go.mod h1:mv6B12cisvSc6bwKm9q9wcrr26awkZK8QXM+nso9n2U= +github.com/uptrace/bun v1.2.3 h1:6KDc6YiNlXde38j9ATKufb8o7MS8zllhAOeIyELKrk0= +github.com/uptrace/bun v1.2.3/go.mod h1:8frYFHrO/Zol3I4FEjoXam0HoNk+t5k7aJRl3FXp0mk= +github.com/uptrace/bun/dialect/pgdialect v1.2.3 h1:YyCxxqeL0lgFWRZzKCOt6mnxUsjqITcxSo0mLqgwMUA= +github.com/uptrace/bun/dialect/pgdialect v1.2.3/go.mod h1:Vx9TscyEq1iN4tnirn6yYGwEflz0KG3rBZTBCLpKAjc= github.com/uptrace/bun/extra/bundebug v1.2.1 h1:85MYpX3QESYI02YerKxUi1CD9mHuLrc2BXs1eOCtQus= github.com/uptrace/bun/extra/bundebug v1.2.1/go.mod h1:sfGKIi0HSGxsTC/sgIHGwpnYduHHYhdMeOIwurgSY+Y= github.com/uptrace/bun/extra/bunotel v1.2.1 h1:5oTy3Jh7Q1bhCd5vnPszBmJgYouw+PuuZ8iSCm+uNCQ= @@ -327,8 +329,8 @@ go.opentelemetry.io/contrib/instrumentation/runtime v0.53.0 h1:nOlJEAJyrcy8hexK6 go.opentelemetry.io/contrib/instrumentation/runtime v0.53.0/go.mod h1:u79lGGIlkg3Ryw425RbMjEkGYNxSnXRyR286O840+u4= go.opentelemetry.io/contrib/propagators/b3 v1.28.0 h1:XR6CFQrQ/ttAYmTBX2loUEFGdk1h17pxYI8828dk/1Y= go.opentelemetry.io/contrib/propagators/b3 v1.28.0/go.mod h1:DWRkzJONLquRz7OJPh2rRbZ7MugQj62rk7g6HRnEqh0= -go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= -go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= +go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0/go.mod h1:yeGZANgEcpdx/WK0IvvRFC+2oLiMS2u4L/0Rj2M2Qr0= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.28.0 h1:aLmmtjRke7LPDQ3lvpFz+kNEH43faFhzW7v8BFIEydg= @@ -345,14 +347,14 @@ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.28.0 h1:EVSnY9JbEEW92bE go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.28.0/go.mod h1:Ea1N1QQryNXpCD0I1fdLibBAIpQuBkznMmkdKrapk1Y= go.opentelemetry.io/otel/log v0.3.0 h1:kJRFkpUFYtny37NQzL386WbznUByZx186DpEMKhEGZs= go.opentelemetry.io/otel/log v0.3.0/go.mod h1:ziCwqZr9soYDwGNbIL+6kAvQC+ANvjgG367HVcyR/ys= -go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= -go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc= +go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8= go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= -go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= -go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4= +go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/dig v1.18.0 h1:imUL1UiY0Mg4bqbFfsRQO5G4CGRBec/ZujWTvSVp3pw= @@ -374,8 +376,6 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -411,8 +411,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.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= diff --git a/components/ledger/internal/engine/command/lock.go b/components/ledger/internal/engine/command/lock.go index 65e7f3b12c..828215a588 100644 --- a/components/ledger/internal/engine/command/lock.go +++ b/components/ledger/internal/engine/command/lock.go @@ -7,7 +7,6 @@ import ( "time" "github.com/formancehq/stack/libs/go-libs/collectionutils" - "github.com/formancehq/stack/libs/go-libs/logging" "github.com/pkg/errors" ) @@ -37,7 +36,7 @@ type lockIntent struct { at time.Time } -func (intent *lockIntent) tryLock(ctx context.Context, chain *DefaultLocker) bool { +func (intent *lockIntent) tryLock(chain *DefaultLocker) bool { for _, account := range intent.accounts.Read { _, ok := chain.writeLocks[account] @@ -57,8 +56,6 @@ func (intent *lockIntent) tryLock(ctx context.Context, chain *DefaultLocker) boo } } - logging.FromContext(ctx).Debugf("Lock acquired") - for _, account := range intent.accounts.Read { atomicValue, ok := chain.readLocks[account] if !ok { @@ -74,8 +71,7 @@ func (intent *lockIntent) tryLock(ctx context.Context, chain *DefaultLocker) boo return true } -func (intent *lockIntent) unlock(ctx context.Context, chain *DefaultLocker) { - logging.FromContext(ctx).Debugf("Unlock accounts") +func (intent *lockIntent) unlock(chain *DefaultLocker) { for _, account := range intent.accounts.Read { atomicValue := chain.readLocks[account] if atomicValue.Add(-1) == 0 { @@ -97,13 +93,6 @@ type DefaultLocker struct { func (defaultLocker *DefaultLocker) Lock(ctx context.Context, accounts Accounts) (Unlock, error) { defaultLocker.mu.Lock() - logger := logging.FromContext(ctx).WithFields(map[string]any{ - "read": accounts.Read, - "write": accounts.Write, - }) - ctx = logging.ContextWithLogger(ctx, logger) - - logger.Debugf("Intent lock") intent := &lockIntent{ accounts: accounts, acquired: make(chan struct{}), @@ -116,7 +105,7 @@ func (defaultLocker *DefaultLocker) Lock(ctx context.Context, accounts Accounts) if node == nil { return } - if node.Value().tryLock(ctx, defaultLocker) { + if node.Value().tryLock(defaultLocker) { node.Remove() close(node.Value().acquired) return @@ -129,20 +118,18 @@ func (defaultLocker *DefaultLocker) Lock(ctx context.Context, accounts Accounts) defaultLocker.mu.Lock() defer defaultLocker.mu.Unlock() - intent.unlock(logging.ContextWithLogger(ctx, logger), defaultLocker) + intent.unlock(defaultLocker) recheck() } - acquired := intent.tryLock(ctx, defaultLocker) + acquired := intent.tryLock(defaultLocker) if acquired { - logger.Debugf("Lock directly acquired") defaultLocker.mu.Unlock() return releaseIntent, nil } - logger.Debugf("Lock not acquired, some accounts are already used, putting in queue") defaultLocker.intents.Append(intent) defaultLocker.mu.Unlock() diff --git a/components/ledger/internal/engine/command/lock_test.go b/components/ledger/internal/engine/command/lock_test.go index 2e7fb1cfc5..d7b7f71b32 100644 --- a/components/ledger/internal/engine/command/lock_test.go +++ b/components/ledger/internal/engine/command/lock_test.go @@ -26,10 +26,12 @@ func TestLock(t *testing.T) { wg.Add(nbLoop) for i := 0; i < nbLoop; i++ { + read := accounts[r.Int31n(10)] + write := accounts[r.Int31n(10)] go func() { unlock, err := locker.Lock(ctx, Accounts{ - Read: []string{accounts[r.Int31n(10)]}, - Write: []string{accounts[r.Int31n(10)]}, + Read: []string{read}, + Write: []string{write}, }) require.NoError(t, err) defer unlock(ctx) diff --git a/components/ledger/internal/storage/driver/driver_test.go b/components/ledger/internal/storage/driver/driver_test.go index 4a4a4b24cf..d77c07267b 100644 --- a/components/ledger/internal/storage/driver/driver_test.go +++ b/components/ledger/internal/storage/driver/driver_test.go @@ -1,3 +1,5 @@ +//go:build it + package driver_test import ( diff --git a/components/ledger/internal/storage/driver/main_test.go b/components/ledger/internal/storage/driver/main_test.go index 8eb317f444..194724652d 100644 --- a/components/ledger/internal/storage/driver/main_test.go +++ b/components/ledger/internal/storage/driver/main_test.go @@ -1,3 +1,5 @@ +//go:build it + package driver import ( diff --git a/components/ledger/internal/storage/ledgerstore/accounts_test.go b/components/ledger/internal/storage/ledgerstore/accounts_test.go index d0e3572162..5d39f34941 100644 --- a/components/ledger/internal/storage/ledgerstore/accounts_test.go +++ b/components/ledger/internal/storage/ledgerstore/accounts_test.go @@ -1,3 +1,5 @@ +//go:build it + package ledgerstore import ( diff --git a/components/ledger/internal/storage/ledgerstore/balances_test.go b/components/ledger/internal/storage/ledgerstore/balances_test.go index d31786f44c..ad6485eb9e 100644 --- a/components/ledger/internal/storage/ledgerstore/balances_test.go +++ b/components/ledger/internal/storage/ledgerstore/balances_test.go @@ -1,3 +1,5 @@ +//go:build it + package ledgerstore import ( diff --git a/components/ledger/internal/storage/ledgerstore/bucket_test.go b/components/ledger/internal/storage/ledgerstore/bucket_test.go index 67bc9a85a5..eb62d3be71 100644 --- a/components/ledger/internal/storage/ledgerstore/bucket_test.go +++ b/components/ledger/internal/storage/ledgerstore/bucket_test.go @@ -1,3 +1,5 @@ +//go:build it + package ledgerstore import ( diff --git a/components/ledger/internal/storage/ledgerstore/logs_test.go b/components/ledger/internal/storage/ledgerstore/logs_test.go index 43034d0e2e..00b002e677 100644 --- a/components/ledger/internal/storage/ledgerstore/logs_test.go +++ b/components/ledger/internal/storage/ledgerstore/logs_test.go @@ -1,3 +1,5 @@ +//go:build it + package ledgerstore import ( diff --git a/components/ledger/internal/storage/ledgerstore/main_test.go b/components/ledger/internal/storage/ledgerstore/main_test.go index 5a6cac1e03..72a19bf3b4 100644 --- a/components/ledger/internal/storage/ledgerstore/main_test.go +++ b/components/ledger/internal/storage/ledgerstore/main_test.go @@ -1,3 +1,5 @@ +//go:build it + package ledgerstore import ( diff --git a/components/ledger/internal/storage/ledgerstore/store_benchmarks_test.go b/components/ledger/internal/storage/ledgerstore/store_benchmarks_test.go index ca26b1c99f..7c88dc461a 100644 --- a/components/ledger/internal/storage/ledgerstore/store_benchmarks_test.go +++ b/components/ledger/internal/storage/ledgerstore/store_benchmarks_test.go @@ -1,3 +1,5 @@ +//go:build it + package ledgerstore import ( diff --git a/components/ledger/internal/storage/ledgerstore/store_test.go b/components/ledger/internal/storage/ledgerstore/store_test.go index 29fb5ed3d3..55a9f268c7 100644 --- a/components/ledger/internal/storage/ledgerstore/store_test.go +++ b/components/ledger/internal/storage/ledgerstore/store_test.go @@ -1,3 +1,5 @@ +//go:build it + package ledgerstore import ( diff --git a/components/ledger/internal/storage/ledgerstore/transactions_test.go b/components/ledger/internal/storage/ledgerstore/transactions_test.go index af64774538..1c3c3e9e5f 100644 --- a/components/ledger/internal/storage/ledgerstore/transactions_test.go +++ b/components/ledger/internal/storage/ledgerstore/transactions_test.go @@ -1,3 +1,5 @@ +//go:build it + package ledgerstore import ( diff --git a/components/ledger/internal/storage/ledgerstore/volumes_test.go b/components/ledger/internal/storage/ledgerstore/volumes_test.go index 4c8750d368..a9771a4f5f 100644 --- a/components/ledger/internal/storage/ledgerstore/volumes_test.go +++ b/components/ledger/internal/storage/ledgerstore/volumes_test.go @@ -1,3 +1,5 @@ +//go:build it + package ledgerstore import ( diff --git a/components/ledger/internal/storage/migrate_ledger_v1_test.go b/components/ledger/internal/storage/migrate_ledger_v1_test.go index 96e8543708..9a3d9abc93 100644 --- a/components/ledger/internal/storage/migrate_ledger_v1_test.go +++ b/components/ledger/internal/storage/migrate_ledger_v1_test.go @@ -1,3 +1,5 @@ +//go:build it + package storage_test import ( diff --git a/components/ledger/internal/storage/systemstore/ledgers_test.go b/components/ledger/internal/storage/systemstore/ledgers_test.go index ef3cbfd6ec..415784d9cf 100644 --- a/components/ledger/internal/storage/systemstore/ledgers_test.go +++ b/components/ledger/internal/storage/systemstore/ledgers_test.go @@ -1,3 +1,5 @@ +//go:build it + package systemstore import ( diff --git a/components/ledger/internal/storage/systemstore/main_test.go b/components/ledger/internal/storage/systemstore/main_test.go index 935f49b971..abfb501797 100644 --- a/components/ledger/internal/storage/systemstore/main_test.go +++ b/components/ledger/internal/storage/systemstore/main_test.go @@ -1,3 +1,5 @@ +//go:build it + package systemstore import ( diff --git a/components/ledger/openapi.yaml b/components/ledger/openapi.yaml index 0817bdcdc6..3d5f5855bc 100644 --- a/components/ledger/openapi.yaml +++ b/components/ledger/openapi.yaml @@ -3,6 +3,8 @@ info: title: Ledger API contact: {} version: LEDGER_VERSION +servers: + - url: http://localhost:8080/ paths: /_info: get: @@ -1137,6 +1139,12 @@ paths: application/json: schema: $ref: '#/components/schemas/V2ErrorResponse' + 5XX: + description: Error + content: + application/json: + schema: + $ref: '#/components/schemas/V2ErrorResponse' /v2: get: summary: List ledgers @@ -1255,6 +1263,12 @@ paths: application/json: schema: $ref: '#/components/schemas/V2ErrorResponse' + 5XX: + description: Error + content: + application/json: + schema: + $ref: '#/components/schemas/V2ErrorResponse' /v2/{ledger}/metadata/{key}: parameters: - name: ledger @@ -1599,6 +1613,12 @@ paths: 2XX: description: Key deleted content: {} + default: + description: Error + content: + application/json: + schema: + $ref: '#/components/schemas/V2ErrorResponse' /v2/{ledger}/stats: get: tags: @@ -3345,6 +3365,7 @@ components: - IMPORT example: VALIDATION V2LedgerInfoResponse: + type: object properties: data: $ref: '#/components/schemas/V2LedgerInfo' @@ -3453,6 +3474,7 @@ components: - type: object properties: data: + type: object properties: id: type: integer @@ -3470,6 +3492,7 @@ components: - type: object properties: data: + type: object properties: targetId: $ref: '#/components/schemas/V2TargetId' diff --git a/components/ledger/openapi/v2.yaml b/components/ledger/openapi/v2.yaml index e94e330ca2..9e2c22f107 100644 --- a/components/ledger/openapi/v2.yaml +++ b/components/ledger/openapi/v2.yaml @@ -4,7 +4,13 @@ info: contact: {} version: "LEDGER_VERSION" +servers: + - url: http://localhost:8080/ + paths: + x-speakeasy-errors: + statusCodes: + - "default" /v2/_info: get: tags: @@ -19,13 +25,18 @@ paths: application/json: schema: $ref: '#/components/schemas/V2ConfigInfoResponse' - default: + "default": + description: Error + content: + application/json: + schema: + $ref: '#/components/schemas/V2ErrorResponse' + "5XX": description: Error content: application/json: schema: $ref: '#/components/schemas/V2ErrorResponse' - /v2: get: summary: List ledgers @@ -61,7 +72,7 @@ paths: application/json: schema: $ref: '#/components/schemas/V2LedgerListResponse' - default: + "default": description: Error content: application/json: @@ -91,7 +102,7 @@ paths: application/json: schema: $ref: '#/components/schemas/V2GetLedgerResponse' - default: + "default": description: Error content: application/json: @@ -113,7 +124,7 @@ paths: "204": description: OK - default: + "default": description: Error content: application/json: @@ -145,7 +156,13 @@ paths: "204": description: OK - default: + "default": + description: Error + content: + application/json: + schema: + $ref: '#/components/schemas/V2ErrorResponse' + "5XX": description: Error content: application/json: @@ -179,7 +196,7 @@ paths: "204": description: OK - default: + "default": description: Error content: application/json: @@ -208,7 +225,7 @@ paths: application/json: schema: $ref: '#/components/schemas/V2LedgerInfoResponse' - default: + "default": description: Error content: application/json: @@ -250,7 +267,7 @@ paths: schema: $ref: '#/components/schemas/V2BulkResponse' - default: + "default": description: Error content: application/json: @@ -293,7 +310,7 @@ paths: type: integer format: bigint minimum: 0 - default: + "default": description: Error content: application/json: @@ -361,7 +378,7 @@ paths: schema: $ref: '#/components/schemas/V2AccountsCursorResponse' - default: + "default": description: Error content: application/json: @@ -413,7 +430,7 @@ paths: application/json: schema: $ref: '#/components/schemas/V2AccountResponse' - default: + "default": description: Error content: application/json: @@ -469,7 +486,7 @@ paths: description: No Content content: {} - default: + "default": description: Error content: application/json: @@ -509,6 +526,12 @@ paths: 2XX: description: Key deleted content: {} + "default": + description: Error + content: + application/json: + schema: + $ref: '#/components/schemas/V2ErrorResponse' /v2/{ledger}/stats: get: @@ -534,7 +557,7 @@ paths: application/json: schema: $ref: '#/components/schemas/V2StatsResponse' - default: + "default": description: Error content: application/json: @@ -577,7 +600,7 @@ paths: type: integer format: int64 minimum: 0 - default: + "default": description: Error content: application/json: @@ -657,7 +680,7 @@ paths: schema: $ref: '#/components/schemas/V2TransactionsCursorResponse' - default: + "default": description: Error content: application/json: @@ -707,7 +730,7 @@ paths: schema: $ref: '#/components/schemas/V2CreateTransactionResponse' - default: + "default": description: Error content: application/json: @@ -758,7 +781,7 @@ paths: schema: $ref: '#/components/schemas/V2GetTransactionResponse' - default: + "default": description: Error content: application/json: @@ -811,7 +834,7 @@ paths: description: No Content content: {} - default: + "default": description: Error content: application/json: @@ -855,7 +878,7 @@ paths: description: Key deleted content: { } - default: + "default": description: Error content: application/json: @@ -906,7 +929,7 @@ paths: schema: $ref: '#/components/schemas/V2RevertTransactionResponse' - default: + "default": description: Error content: application/json: @@ -953,7 +976,7 @@ paths: application/json: schema: $ref: '#/components/schemas/V2AggregateBalancesResponse' - default: + "default": description: Error content: application/json: @@ -1035,7 +1058,7 @@ paths: application/json: schema: $ref: '#/components/schemas/V2VolumesWithBalanceCursorResponse' - default: + "default": description: Error content: application/json: @@ -1097,12 +1120,13 @@ paths: application/json: schema: $ref: '#/components/schemas/V2LogsCursorResponse' - default: + "default": description: Error content: application/json: schema: $ref: '#/components/schemas/V2ErrorResponse' + /v2/{ledger}/logs/import: post: tags: @@ -1125,12 +1149,13 @@ paths: responses: 204: description: Import OK - default: + "default": description: Error content: application/json: schema: $ref: '#/components/schemas/V2ErrorResponse' + /v2/{ledger}/logs/export: post: summary: Export logs @@ -1149,7 +1174,7 @@ paths: responses: 200: description: Import OK - default: + "default": description: Error content: application/octet-stream: @@ -1695,6 +1720,7 @@ components: example: VALIDATION V2LedgerInfoResponse: + type: object properties: data: $ref: '#/components/schemas/V2LedgerInfo' @@ -1813,6 +1839,7 @@ components: - type: object properties: data: + type: object properties: id: type: integer @@ -1831,6 +1858,7 @@ components: - type: object properties: data: + type: object properties: targetId: $ref: '#/components/schemas/V2TargetId' diff --git a/components/ledger/pkg/client/.devcontainer/README.md b/components/ledger/pkg/client/.devcontainer/README.md new file mode 100644 index 0000000000..2540e7dfdc --- /dev/null +++ b/components/ledger/pkg/client/.devcontainer/README.md @@ -0,0 +1,30 @@ + +> **Remember to shutdown a GitHub Codespace when it is not in use!** + +# Dev Containers Quick Start + +The default location for usage snippets is the `samples` directory. + +## Running a Usage Sample + +A sample usage example has been provided in a `root.go` file. As you work with the SDK, it's expected that you will modify these samples to fit your needs. To execute this particular snippet, use the command below. + +``` +go run root.go +``` + +## Generating Additional Usage Samples + +The speakeasy CLI allows you to generate more usage snippets. Here's how: + +- To generate a sample for a specific operation by providing an operation ID, use: + +``` +speakeasy generate usage -s openapi/v2.yaml -l go -i {INPUT_OPERATION_ID} -o ./samples +``` + +- To generate samples for an entire namespace (like a tag or group name), use: + +``` +speakeasy generate usage -s openapi/v2.yaml -l go -n {INPUT_TAG_NAME} -o ./samples +``` diff --git a/components/ledger/pkg/client/.devcontainer/devcontainer.json b/components/ledger/pkg/client/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..2afb19f0b0 --- /dev/null +++ b/components/ledger/pkg/client/.devcontainer/devcontainer.json @@ -0,0 +1,59 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/go +{ + "name": "Go", + "image": "mcr.microsoft.com/devcontainers/go:1-1.20-bullseye", + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "sudo chmod +x ./.devcontainer/setup.sh && ./.devcontainer/setup.sh", + "customizations": { + "vscode": { + "extensions": [ + "golang.go", + "github.vscode-pull-request-github" // Github interaction + ], + "settings": { + "files.eol": "\n", + "editor.formatOnSave": true, + "go.buildTags": "", + "go.toolsEnvVars": { + "CGO_ENABLED": "0" + }, + "go.useLanguageServer": true, + "go.testEnvVars": { + "CGO_ENABLED": "1" + }, + "go.testFlags": [ + "-v", + "-race" + ], + "go.testTimeout": "60s", + "go.coverOnSingleTest": true, + "go.coverOnSingleTestFile": true, + "go.coverOnTestPackage": true, + "go.lintTool": "golangci-lint", + "go.lintOnSave": "package", + "[go]": { + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + }, + "gopls": { + "usePlaceholders": false, + "staticcheck": true, + "vulncheck": "Imports" + } + } + }, + "codespaces": { + "openFiles": [ + ".devcontainer/README.md" + ] + } + } + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} \ No newline at end of file diff --git a/components/ledger/pkg/client/.devcontainer/setup.sh b/components/ledger/pkg/client/.devcontainer/setup.sh new file mode 100644 index 0000000000..f96631bbb7 --- /dev/null +++ b/components/ledger/pkg/client/.devcontainer/setup.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Install the speakeasy CLI +curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/install.sh | sh + +# Setup samples directory +rmdir samples || true +mkdir samples + +# Go module commands +go mod download +go mod tidy + +# Generate starter usage sample with speakeasy +speakeasy generate usage -s openapi/v2.yaml -l go -o samples/root.go \ No newline at end of file diff --git a/components/ledger/pkg/client/.gitattributes b/components/ledger/pkg/client/.gitattributes new file mode 100644 index 0000000000..e6a994416d --- /dev/null +++ b/components/ledger/pkg/client/.gitattributes @@ -0,0 +1,2 @@ +# This allows generated code to be indexed correctly +*.go linguist-generated=false \ No newline at end of file diff --git a/components/ledger/pkg/client/.gitignore b/components/ledger/pkg/client/.gitignore new file mode 100644 index 0000000000..d3c2f597fe --- /dev/null +++ b/components/ledger/pkg/client/.gitignore @@ -0,0 +1 @@ +# .gitignore diff --git a/components/ledger/pkg/client/.speakeasy/gen.lock b/components/ledger/pkg/client/.speakeasy/gen.lock new file mode 100644 index 0000000000..865f46ceb4 --- /dev/null +++ b/components/ledger/pkg/client/.speakeasy/gen.lock @@ -0,0 +1,235 @@ +lockVersion: 2.0.0 +id: a9ac79e1-e429-4ee3-96c4-ec973f19bec3 +management: + docChecksum: 359dd8cb16193447c993d3d336785c37 + docVersion: LEDGER_VERSION + speakeasyVersion: 1.346.0 + generationVersion: 2.379.3 + releaseVersion: 0.2.0 + configChecksum: 09df02129c4cf02489fa2f86475a8a45 +features: + go: + additionalDependencies: 0.1.0 + core: 3.5.2 + defaultEnabledRetries: 0.2.0 + devContainers: 2.90.0 + downloadStreams: 0.1.1 + envVarSecurityUsage: 0.2.0 + errors: 2.81.9 + flattening: 2.81.1 + getRequestBodies: 2.81.1 + globalSecurityCallbacks: 0.1.0 + globalServerURLs: 2.82.2 + intellisenseMarkdownSupport: 0.1.0 + nameOverrides: 2.81.2 + responseFormat: 0.1.2 + retries: 2.83.0 + sdkHooks: 0.1.0 + unions: 2.85.8 +generatedFiles: + - v2.go + - ledger.go + - formance.go + - go.mod + - models/sdkerrors/sdkerror.go + - retry/config.go + - types/bigint.go + - types/date.go + - types/datetime.go + - types/decimal.go + - types/pointers.go + - internal/utils/contenttype.go + - internal/utils/form.go + - internal/utils/headers.go + - internal/utils/json.go + - internal/utils/pathparams.go + - internal/utils/queryparams.go + - internal/utils/requestbody.go + - internal/utils/retries.go + - internal/utils/security.go + - internal/utils/utils.go + - /models/operations/v2getinfo.go + - /models/operations/v2listledgers.go + - /models/operations/v2getledger.go + - /models/operations/v2createledger.go + - /models/operations/v2updateledgermetadata.go + - /models/operations/v2deleteledgermetadata.go + - /models/operations/v2getledgerinfo.go + - /models/operations/v2createbulk.go + - /models/operations/v2countaccounts.go + - /models/operations/v2listaccounts.go + - /models/operations/v2getaccount.go + - /models/operations/v2addmetadatatoaccount.go + - /models/operations/v2deleteaccountmetadata.go + - /models/operations/v2readstats.go + - /models/operations/v2counttransactions.go + - /models/operations/v2listtransactions.go + - /models/operations/v2createtransaction.go + - /models/operations/v2gettransaction.go + - /models/operations/v2addmetadataontransaction.go + - /models/operations/v2deletetransactionmetadata.go + - /models/operations/v2reverttransaction.go + - /models/operations/v2getbalancesaggregated.go + - /models/operations/v2getvolumeswithbalances.go + - /models/operations/v2listlogs.go + - /models/operations/v2importlogs.go + - /models/operations/v2exportlogs.go + - /models/sdkerrors/v2errorresponse.go + - /models/components/v2errorsenum.go + - /models/components/v2configinforesponse.go + - /models/components/httpmetadata.go + - /models/components/v2ledgerlistresponse.go + - /models/components/v2ledger.go + - /models/components/v2getledgerresponse.go + - /models/components/v2createledgerrequest.go + - /models/components/v2ledgerinforesponse.go + - /models/components/v2ledgerinfo.go + - /models/components/v2migrationinfo.go + - /models/components/v2bulkresponse.go + - /models/components/v2bulkelementresult.go + - /models/components/v2transaction.go + - /models/components/v2posting.go + - /models/components/v2bulkelement.go + - /models/components/v2bulkelementcreatetransaction.go + - /models/components/v2posttransaction.go + - /models/components/v2bulkelementaddmetadata.go + - /models/components/v2targettype.go + - /models/components/v2targetid.go + - /models/components/v2bulkelementreverttransaction.go + - /models/components/v2bulkelementdeletemetadata.go + - /models/components/v2accountscursorresponse.go + - /models/components/v2account.go + - /models/components/v2volume.go + - /models/components/v2accountresponse.go + - /models/components/v2statsresponse.go + - /models/components/v2stats.go + - /models/components/v2transactionscursorresponse.go + - /models/components/v2expandedtransaction.go + - /models/components/v2createtransactionresponse.go + - /models/components/v2gettransactionresponse.go + - /models/components/v2reverttransactionresponse.go + - /models/components/v2aggregatebalancesresponse.go + - /models/components/v2volumeswithbalancecursorresponse.go + - /models/components/v2volumeswithbalance.go + - /models/components/v2logscursorresponse.go + - /models/components/v2log.go + - docs/models/operations/v2getinforesponse.md + - docs/models/operations/v2listledgersrequest.md + - docs/models/operations/v2listledgersresponse.md + - docs/models/operations/v2getledgerrequest.md + - docs/models/operations/v2getledgerresponse.md + - docs/models/operations/v2createledgerrequest.md + - docs/models/operations/v2createledgerresponse.md + - docs/models/operations/v2updateledgermetadatarequest.md + - docs/models/operations/v2updateledgermetadataresponse.md + - docs/models/operations/v2deleteledgermetadatarequest.md + - docs/models/operations/v2deleteledgermetadataresponse.md + - docs/models/operations/v2getledgerinforequest.md + - docs/models/operations/v2getledgerinforesponse.md + - docs/models/operations/v2createbulkrequest.md + - docs/models/operations/v2createbulkresponse.md + - docs/models/operations/v2countaccountsrequest.md + - docs/models/operations/v2countaccountsresponse.md + - docs/models/operations/v2listaccountsrequest.md + - docs/models/operations/v2listaccountsresponse.md + - docs/models/operations/v2getaccountrequest.md + - docs/models/operations/v2getaccountresponse.md + - docs/models/operations/v2addmetadatatoaccountrequest.md + - docs/models/operations/v2addmetadatatoaccountresponse.md + - docs/models/operations/v2deleteaccountmetadatarequest.md + - docs/models/operations/v2deleteaccountmetadataresponse.md + - docs/models/operations/v2readstatsrequest.md + - docs/models/operations/v2readstatsresponse.md + - docs/models/operations/v2counttransactionsrequest.md + - docs/models/operations/v2counttransactionsresponse.md + - docs/models/operations/order.md + - docs/models/operations/v2listtransactionsrequest.md + - docs/models/operations/v2listtransactionsresponse.md + - docs/models/operations/v2createtransactionrequest.md + - docs/models/operations/v2createtransactionresponse.md + - docs/models/operations/v2gettransactionrequest.md + - docs/models/operations/v2gettransactionresponse.md + - docs/models/operations/v2addmetadataontransactionrequest.md + - docs/models/operations/v2addmetadataontransactionresponse.md + - docs/models/operations/v2deletetransactionmetadatarequest.md + - docs/models/operations/v2deletetransactionmetadataresponse.md + - docs/models/operations/v2reverttransactionrequest.md + - docs/models/operations/v2reverttransactionresponse.md + - docs/models/operations/v2getbalancesaggregatedrequest.md + - docs/models/operations/v2getbalancesaggregatedresponse.md + - docs/models/operations/v2getvolumeswithbalancesrequest.md + - docs/models/operations/v2getvolumeswithbalancesresponse.md + - docs/models/operations/v2listlogsrequest.md + - docs/models/operations/v2listlogsresponse.md + - docs/models/operations/v2importlogsrequest.md + - docs/models/operations/v2importlogsresponse.md + - docs/models/operations/v2exportlogsrequest.md + - docs/models/operations/v2exportlogsresponse.md + - docs/models/sdkerrors/v2errorresponse.md + - docs/models/components/v2errorsenum.md + - docs/models/components/v2configinforesponse.md + - docs/models/components/httpmetadata.md + - docs/models/components/cursor.md + - docs/models/components/v2ledgerlistresponse.md + - docs/models/components/v2ledger.md + - docs/models/components/v2getledgerresponse.md + - docs/models/components/v2createledgerrequest.md + - docs/models/components/v2ledgerinforesponse.md + - docs/models/components/storage.md + - docs/models/components/v2ledgerinfo.md + - docs/models/components/state.md + - docs/models/components/v2migrationinfo.md + - docs/models/components/v2bulkresponse.md + - docs/models/components/v2bulkelementresulterror.md + - docs/models/components/v2bulkelementresultdeletemetadata.md + - docs/models/components/v2bulkelementresultreverttransaction.md + - docs/models/components/v2bulkelementresultaddmetadata.md + - docs/models/components/v2bulkelementresultcreatetransaction.md + - docs/models/components/v2bulkelementresult.md + - docs/models/components/v2transaction.md + - docs/models/components/v2posting.md + - docs/models/components/v2bulkelement.md + - docs/models/components/v2bulkelementcreatetransaction.md + - docs/models/components/script.md + - docs/models/components/v2posttransaction.md + - docs/models/components/data.md + - docs/models/components/v2bulkelementaddmetadata.md + - docs/models/components/v2targettype.md + - docs/models/components/v2targetid.md + - docs/models/components/v2bulkelementreverttransactiondata.md + - docs/models/components/v2bulkelementreverttransaction.md + - docs/models/components/v2bulkelementdeletemetadatadata.md + - docs/models/components/v2bulkelementdeletemetadata.md + - docs/models/components/v2accountscursorresponsecursor.md + - docs/models/components/v2accountscursorresponse.md + - docs/models/components/v2account.md + - docs/models/components/v2volume.md + - docs/models/components/v2accountresponse.md + - docs/models/components/v2statsresponse.md + - docs/models/components/v2stats.md + - docs/models/components/v2transactionscursorresponsecursor.md + - docs/models/components/v2transactionscursorresponse.md + - docs/models/components/v2expandedtransaction.md + - docs/models/components/v2createtransactionresponse.md + - docs/models/components/v2gettransactionresponse.md + - docs/models/components/v2reverttransactionresponse.md + - docs/models/components/v2aggregatebalancesresponse.md + - docs/models/components/v2volumeswithbalancecursorresponsecursor.md + - docs/models/components/v2volumeswithbalancecursorresponse.md + - docs/models/components/v2volumeswithbalance.md + - docs/models/components/v2logscursorresponsecursor.md + - docs/models/components/v2logscursorresponse.md + - docs/models/components/type.md + - docs/models/components/v2log.md + - docs/sdks/formance/README.md + - docs/sdks/ledger/README.md + - docs/models/operations/option.md + - docs/sdks/v2/README.md + - USAGE.md + - models/operations/options.go + - .gitattributes + - .devcontainer/README.md + - .devcontainer/devcontainer.json + - .devcontainer/setup.sh + - internal/hooks/hooks.go + - CONTRIBUTING.md diff --git a/components/ledger/pkg/client/.speakeasy/gen.yaml b/components/ledger/pkg/client/.speakeasy/gen.yaml new file mode 100644 index 0000000000..6d33de1c5d --- /dev/null +++ b/components/ledger/pkg/client/.speakeasy/gen.yaml @@ -0,0 +1,37 @@ +configVersion: 2.0.0 +generation: + devContainers: + enabled: true + schemaPath: openapi/v2.yaml + sdkClassName: Formance + maintainOpenAPIOrder: true + usageSnippets: + optionalPropertyRendering: withExample + useClassNamesForArrayFields: true + fixes: + nameResolutionDec2023: true + parameterOrderingFeb2024: true + requestResponseComponentNamesFeb2024: true + auth: + oAuth2ClientCredentialsEnabled: true +go: + version: 0.2.0 + additionalDependencies: {} + allowUnknownFieldsInWeakUnions: false + clientServerStatusCodesAsErrors: true + envVarPrefix: FORMANCE + flattenGlobalSecurity: true + imports: + option: openapi + paths: + callbacks: models/callbacks + errors: models/sdkerrors + operations: models/operations + shared: models/components + webhooks: models/webhooks + inputModelSuffix: input + maxMethodParams: 4 + methodArguments: require-security-and-request + outputModelSuffix: output + packageName: github.com/formancehq/stack/ledger/client + responseFormat: envelope-http diff --git a/components/ledger/pkg/client/.speakeasy/workflow.yaml b/components/ledger/pkg/client/.speakeasy/workflow.yaml new file mode 100644 index 0000000000..9b1648d078 --- /dev/null +++ b/components/ledger/pkg/client/.speakeasy/workflow.yaml @@ -0,0 +1,11 @@ +workflowVersion: 1.0.0 +sources: + Formance-OAS: + inputs: + - location: ../../openapi/v2.yaml + registry: + location: registry.speakeasyapi.dev/formance/gfyrag/formance-oas +targets: + formance: + target: go + source: Formance-OAS diff --git a/components/ledger/pkg/client/CONTRIBUTING.md b/components/ledger/pkg/client/CONTRIBUTING.md new file mode 100644 index 0000000000..d585717fca --- /dev/null +++ b/components/ledger/pkg/client/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing to This Repository + +Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements. + +## How to Report Issues + +If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes: + +- A clear and descriptive title +- Steps to reproduce the issue +- Expected and actual behavior +- Any relevant logs, screenshots, or error messages +- Information about your environment (e.g., operating system, software versions) + - For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed + +## Issue Triage and Upstream Fixes + +We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code. + +## Contact + +If you have any questions or need further assistance, please feel free to reach out by opening an issue. + +Thank you for your understanding and cooperation! + +The Maintainers diff --git a/components/ledger/pkg/client/README.md b/components/ledger/pkg/client/README.md new file mode 100644 index 0000000000..3dbb8306aa --- /dev/null +++ b/components/ledger/pkg/client/README.md @@ -0,0 +1,359 @@ +# github.com/formancehq/stack/ledger/client + +Developer-friendly & type-safe Go SDK specifically catered to leverage *github.com/formancehq/stack/ledger/client* API. + +
+ + + + +
+ + +## 🏗 **Welcome to your new SDK!** 🏗 + +It has been generated successfully based on your OpenAPI spec. However, it is not yet ready for production use. Here are some next steps: +- [ ] 🛠 Make your SDK feel handcrafted by [customizing it](https://www.speakeasy.com/docs/customize-sdks) +- [ ] ♻️ Refine your SDK quickly by iterating locally with the [Speakeasy CLI](https://github.com/speakeasy-api/speakeasy) +- [ ] 🎁 Publish your SDK to package managers by [configuring automatic publishing](https://www.speakeasy.com/docs/advanced-setup/publish-sdks) +- [ ] ✨ When ready to productionize, delete this section from the README + + +## Summary + + + + + +## Table of Contents + +* [SDK Installation](#sdk-installation) +* [SDK Example Usage](#sdk-example-usage) +* [Available Resources and Operations](#available-resources-and-operations) +* [Retries](#retries) +* [Error Handling](#error-handling) +* [Server Selection](#server-selection) +* [Custom HTTP Client](#custom-http-client) +* [Special Types](#special-types) + + + +## SDK Installation + +```bash +go get github.com/formancehq/stack/ledger/client +``` + + + +## SDK Example Usage + +### Example + +```go +package main + +import ( + "context" + "github.com/formancehq/stack/ledger/client" + "log" +) + +func main() { + s := client.New() + + ctx := context.Background() + res, err := s.Ledger.V2.GetInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.V2ConfigInfoResponse != nil { + // handle response + } +} + +``` + + + +## Available Resources and Operations + +### [Ledger.V2](docs/sdks/v2/README.md) + +* [GetInfo](docs/sdks/v2/README.md#getinfo) - Show server information +* [ListLedgers](docs/sdks/v2/README.md#listledgers) - List ledgers +* [GetLedger](docs/sdks/v2/README.md#getledger) - Get a ledger +* [CreateLedger](docs/sdks/v2/README.md#createledger) - Create a ledger +* [UpdateLedgerMetadata](docs/sdks/v2/README.md#updateledgermetadata) - Update ledger metadata +* [DeleteLedgerMetadata](docs/sdks/v2/README.md#deleteledgermetadata) - Delete ledger metadata by key +* [GetLedgerInfo](docs/sdks/v2/README.md#getledgerinfo) - Get information about a ledger +* [CreateBulk](docs/sdks/v2/README.md#createbulk) - Bulk request +* [CountAccounts](docs/sdks/v2/README.md#countaccounts) - Count the accounts from a ledger +* [ListAccounts](docs/sdks/v2/README.md#listaccounts) - List accounts from a ledger +* [GetAccount](docs/sdks/v2/README.md#getaccount) - Get account by its address +* [AddMetadataToAccount](docs/sdks/v2/README.md#addmetadatatoaccount) - Add metadata to an account +* [DeleteAccountMetadata](docs/sdks/v2/README.md#deleteaccountmetadata) - Delete metadata by key +* [ReadStats](docs/sdks/v2/README.md#readstats) - Get statistics from a ledger +* [CountTransactions](docs/sdks/v2/README.md#counttransactions) - Count the transactions from a ledger +* [ListTransactions](docs/sdks/v2/README.md#listtransactions) - List transactions from a ledger +* [CreateTransaction](docs/sdks/v2/README.md#createtransaction) - Create a new transaction to a ledger +* [GetTransaction](docs/sdks/v2/README.md#gettransaction) - Get transaction from a ledger by its ID +* [AddMetadataOnTransaction](docs/sdks/v2/README.md#addmetadataontransaction) - Set the metadata of a transaction by its ID +* [DeleteTransactionMetadata](docs/sdks/v2/README.md#deletetransactionmetadata) - Delete metadata by key +* [RevertTransaction](docs/sdks/v2/README.md#reverttransaction) - Revert a ledger transaction by its ID +* [GetBalancesAggregated](docs/sdks/v2/README.md#getbalancesaggregated) - Get the aggregated balances from selected accounts +* [GetVolumesWithBalances](docs/sdks/v2/README.md#getvolumeswithbalances) - Get list of volumes with balances for (account/asset) +* [ListLogs](docs/sdks/v2/README.md#listlogs) - List the logs from a ledger +* [ImportLogs](docs/sdks/v2/README.md#importlogs) +* [ExportLogs](docs/sdks/v2/README.md#exportlogs) - Export logs + + + +## Retries + +Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK. + +To change the default retry strategy for a single API call, simply provide a `retry.Config` object to the call by using the `WithRetries` option: +```go +package main + +import ( + "context" + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/retry" + "log" + "models/operations" +) + +func main() { + s := client.New() + + ctx := context.Background() + res, err := s.Ledger.V2.GetInfo(ctx, operations.WithRetries( + retry.Config{ + Strategy: "backoff", + Backoff: &retry.BackoffStrategy{ + InitialInterval: 1, + MaxInterval: 50, + Exponent: 1.1, + MaxElapsedTime: 100, + }, + RetryConnectionErrors: false, + })) + if err != nil { + log.Fatal(err) + } + if res.V2ConfigInfoResponse != nil { + // handle response + } +} + +``` + +If you'd like to override the default retry strategy for all operations that support retries, you can use the `WithRetryConfig` option at SDK initialization: +```go +package main + +import ( + "context" + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/retry" + "log" +) + +func main() { + s := client.New( + client.WithRetryConfig( + retry.Config{ + Strategy: "backoff", + Backoff: &retry.BackoffStrategy{ + InitialInterval: 1, + MaxInterval: 50, + Exponent: 1.1, + MaxElapsedTime: 100, + }, + RetryConnectionErrors: false, + }), + ) + + ctx := context.Background() + res, err := s.Ledger.V2.GetInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.V2ConfigInfoResponse != nil { + // handle response + } +} + +``` + + + +## Error Handling + +Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass. + +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +### Example + +```go +package main + +import ( + "context" + "errors" + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/sdkerrors" + "log" +) + +func main() { + s := client.New() + + ctx := context.Background() + res, err := s.Ledger.V2.GetInfo(ctx) + if err != nil { + + var e *sdkerrors.V2ErrorResponse + if errors.As(err, &e) { + // handle error + log.Fatal(e.Error()) + } + + var e *sdkerrors.SDKError + if errors.As(err, &e) { + // handle error + log.Fatal(e.Error()) + } + } +} + +``` + + + +## Server Selection + +### Select Server by Index + +You can override the default server globally using the `WithServerIndex` option when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers: + +| # | Server | Variables | +| - | ------ | --------- | +| 0 | `http://localhost:8080/` | None | + +#### Example + +```go +package main + +import ( + "context" + "github.com/formancehq/stack/ledger/client" + "log" +) + +func main() { + s := client.New( + client.WithServerIndex(0), + ) + + ctx := context.Background() + res, err := s.Ledger.V2.GetInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.V2ConfigInfoResponse != nil { + // handle response + } +} + +``` + + +### Override Server URL Per-Client + +The default server can also be overridden globally using the `WithServerURL` option when initializing the SDK client instance. For example: +```go +package main + +import ( + "context" + "github.com/formancehq/stack/ledger/client" + "log" +) + +func main() { + s := client.New( + client.WithServerURL("http://localhost:8080/"), + ) + + ctx := context.Background() + res, err := s.Ledger.V2.GetInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.V2ConfigInfoResponse != nil { + // handle response + } +} + +``` + + + +## Custom HTTP Client + +The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface: + +```go +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} +``` + +The built-in `net/http` client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout. + +```go +import ( + "net/http" + "time" + "github.com/myorg/your-go-sdk" +) + +var ( + httpClient = &http.Client{Timeout: 30 * time.Second} + sdkClient = sdk.New(sdk.WithClient(httpClient)) +) +``` + +This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration. + + + +## Special Types + + + + + + +# Development + +## Maturity + +This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage +to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally +looking for the latest version. + +## Contributions + +While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. +We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release. + +### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=github-com/formancehq/stack/ledger/client&utm_campaign=go) diff --git a/components/ledger/pkg/client/USAGE.md b/components/ledger/pkg/client/USAGE.md new file mode 100644 index 0000000000..8cb61e5621 --- /dev/null +++ b/components/ledger/pkg/client/USAGE.md @@ -0,0 +1,25 @@ + +```go +package main + +import ( + "context" + "github.com/formancehq/stack/ledger/client" + "log" +) + +func main() { + s := client.New() + + ctx := context.Background() + res, err := s.Ledger.V2.GetInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.V2ConfigInfoResponse != nil { + // handle response + } +} + +``` + \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/cursor.md b/components/ledger/pkg/client/docs/models/components/cursor.md new file mode 100644 index 0000000000..55ebac8e71 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/cursor.md @@ -0,0 +1,12 @@ +# Cursor + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.V2Ledger](../../models/components/v2ledger.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/data.md b/components/ledger/pkg/client/docs/models/components/data.md new file mode 100644 index 0000000000..6f135b98b1 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/data.md @@ -0,0 +1,10 @@ +# Data + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `TargetID` | [components.V2TargetID](../../models/components/v2targetid.md) | :heavy_check_mark: | N/A | +| `TargetType` | [components.V2TargetType](../../models/components/v2targettype.md) | :heavy_check_mark: | N/A | +| `Metadata` | map[string]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/httpmetadata.md b/components/ledger/pkg/client/docs/models/components/httpmetadata.md new file mode 100644 index 0000000000..df1fdd59f3 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/httpmetadata.md @@ -0,0 +1,9 @@ +# HTTPMetadata + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `Response` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `Request` | [*http.Request](https://pkg.go.dev/net/http#Request) | :heavy_check_mark: | Raw HTTP request; suitable for debugging | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/script.md b/components/ledger/pkg/client/docs/models/components/script.md new file mode 100644 index 0000000000..cacdfe4dd9 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/script.md @@ -0,0 +1,9 @@ +# Script + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `Plain` | *string* | :heavy_check_mark: | N/A | vars {
account $user
}
send [COIN 10] (
source = @world
destination = $user
)
| +| `Vars` | map[string]*any* | :heavy_minus_sign: | N/A | {
"user": "users:042"
} | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/state.md b/components/ledger/pkg/client/docs/models/components/state.md new file mode 100644 index 0000000000..fa26cf56b0 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/state.md @@ -0,0 +1,9 @@ +# State + + +## Values + +| Name | Value | +| ----------- | ----------- | +| `StateToDo` | TO DO | +| `StateDone` | DONE | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/storage.md b/components/ledger/pkg/client/docs/models/components/storage.md new file mode 100644 index 0000000000..fe76798969 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/storage.md @@ -0,0 +1,8 @@ +# Storage + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `Migrations` | [][components.V2MigrationInfo](../../models/components/v2migrationinfo.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/type.md b/components/ledger/pkg/client/docs/models/components/type.md new file mode 100644 index 0000000000..a039986e85 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/type.md @@ -0,0 +1,10 @@ +# Type + + +## Values + +| Name | Value | +| ------------------------- | ------------------------- | +| `TypeNewTransaction` | NEW_TRANSACTION | +| `TypeSetMetadata` | SET_METADATA | +| `TypeRevertedTransaction` | REVERTED_TRANSACTION | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2account.md b/components/ledger/pkg/client/docs/models/components/v2account.md new file mode 100644 index 0000000000..91b9e84361 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2account.md @@ -0,0 +1,11 @@ +# V2Account + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | +| `Address` | *string* | :heavy_check_mark: | N/A | users:001 | +| `Metadata` | map[string]*string* | :heavy_check_mark: | N/A | {
"admin": "true"
} | +| `Volumes` | map[string][components.V2Volume](../../models/components/v2volume.md) | :heavy_minus_sign: | N/A | {
"USD": {
"input": 100,
"output": 10,
"balance": 90
},
"EUR": {
"input": 100,
"output": 10,
"balance": 90
}
} | +| `EffectiveVolumes` | map[string][components.V2Volume](../../models/components/v2volume.md) | :heavy_minus_sign: | N/A | {
"USD": {
"input": 100,
"output": 10,
"balance": 90
},
"EUR": {
"input": 100,
"output": 10,
"balance": 90
}
} | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2accountresponse.md b/components/ledger/pkg/client/docs/models/components/v2accountresponse.md new file mode 100644 index 0000000000..44ce771c4e --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2accountresponse.md @@ -0,0 +1,8 @@ +# V2AccountResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| `Data` | [components.V2Account](../../models/components/v2account.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2accountscursorresponse.md b/components/ledger/pkg/client/docs/models/components/v2accountscursorresponse.md new file mode 100644 index 0000000000..feed6ea0c4 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2accountscursorresponse.md @@ -0,0 +1,8 @@ +# V2AccountsCursorResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | +| `Cursor` | [components.V2AccountsCursorResponseCursor](../../models/components/v2accountscursorresponsecursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2accountscursorresponsecursor.md b/components/ledger/pkg/client/docs/models/components/v2accountscursorresponsecursor.md new file mode 100644 index 0000000000..f863929984 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2accountscursorresponsecursor.md @@ -0,0 +1,12 @@ +# V2AccountsCursorResponseCursor + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.V2Account](../../models/components/v2account.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2aggregatebalancesresponse.md b/components/ledger/pkg/client/docs/models/components/v2aggregatebalancesresponse.md new file mode 100644 index 0000000000..cc5cd6e777 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2aggregatebalancesresponse.md @@ -0,0 +1,8 @@ +# V2AggregateBalancesResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `Data` | map[string][*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | {
"USD": 100,
"EUR": 12
} | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelement.md b/components/ledger/pkg/client/docs/models/components/v2bulkelement.md new file mode 100644 index 0000000000..b13faa8881 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelement.md @@ -0,0 +1,29 @@ +# V2BulkElement + + +## Supported Types + +### V2BulkElementCreateTransaction + +```go +v2BulkElement := components.CreateV2BulkElementCreateTransaction(components.V2BulkElementCreateTransaction{/* values here */}) +``` + +### V2BulkElementAddMetadata + +```go +v2BulkElement := components.CreateV2BulkElementAddMetadata(components.V2BulkElementAddMetadata{/* values here */}) +``` + +### V2BulkElementRevertTransaction + +```go +v2BulkElement := components.CreateV2BulkElementRevertTransaction(components.V2BulkElementRevertTransaction{/* values here */}) +``` + +### V2BulkElementDeleteMetadata + +```go +v2BulkElement := components.CreateV2BulkElementDeleteMetadata(components.V2BulkElementDeleteMetadata{/* values here */}) +``` + diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementaddmetadata.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementaddmetadata.md new file mode 100644 index 0000000000..ac1e01fbaa --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementaddmetadata.md @@ -0,0 +1,10 @@ +# V2BulkElementAddMetadata + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | +| `Action` | *string* | :heavy_check_mark: | N/A | +| `Ik` | **string* | :heavy_minus_sign: | N/A | +| `Data` | [*components.Data](../../models/components/data.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementcreatetransaction.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementcreatetransaction.md new file mode 100644 index 0000000000..37065f1a73 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementcreatetransaction.md @@ -0,0 +1,10 @@ +# V2BulkElementCreateTransaction + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | +| `Action` | *string* | :heavy_check_mark: | N/A | +| `Ik` | **string* | :heavy_minus_sign: | N/A | +| `Data` | [*components.V2PostTransaction](../../models/components/v2posttransaction.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementdeletemetadata.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementdeletemetadata.md new file mode 100644 index 0000000000..4119dbcfb3 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementdeletemetadata.md @@ -0,0 +1,10 @@ +# V2BulkElementDeleteMetadata + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | +| `Action` | *string* | :heavy_check_mark: | N/A | +| `Ik` | **string* | :heavy_minus_sign: | N/A | +| `Data` | [*components.V2BulkElementDeleteMetadataData](../../models/components/v2bulkelementdeletemetadatadata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementdeletemetadatadata.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementdeletemetadatadata.md new file mode 100644 index 0000000000..eecc527e54 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementdeletemetadatadata.md @@ -0,0 +1,10 @@ +# V2BulkElementDeleteMetadataData + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `TargetID` | [components.V2TargetID](../../models/components/v2targetid.md) | :heavy_check_mark: | N/A | +| `TargetType` | [components.V2TargetType](../../models/components/v2targettype.md) | :heavy_check_mark: | N/A | +| `Key` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementresult.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementresult.md new file mode 100644 index 0000000000..73f93d35a0 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementresult.md @@ -0,0 +1,35 @@ +# V2BulkElementResult + + +## Supported Types + +### V2BulkElementResultCreateTransaction + +```go +v2BulkElementResult := components.CreateV2BulkElementResultCreateTransaction(components.V2BulkElementResultCreateTransaction{/* values here */}) +``` + +### V2BulkElementResultAddMetadata + +```go +v2BulkElementResult := components.CreateV2BulkElementResultAddMetadata(components.V2BulkElementResultAddMetadata{/* values here */}) +``` + +### V2BulkElementResultRevertTransaction + +```go +v2BulkElementResult := components.CreateV2BulkElementResultRevertTransaction(components.V2BulkElementResultRevertTransaction{/* values here */}) +``` + +### V2BulkElementResultDeleteMetadata + +```go +v2BulkElementResult := components.CreateV2BulkElementResultDeleteMetadata(components.V2BulkElementResultDeleteMetadata{/* values here */}) +``` + +### V2BulkElementResultError + +```go +v2BulkElementResult := components.CreateV2BulkElementResultError(components.V2BulkElementResultError{/* values here */}) +``` + diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementresultaddmetadata.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementresultaddmetadata.md new file mode 100644 index 0000000000..5f8d1fefb2 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementresultaddmetadata.md @@ -0,0 +1,8 @@ +# V2BulkElementResultAddMetadata + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `ResponseType` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementresultcreatetransaction.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementresultcreatetransaction.md new file mode 100644 index 0000000000..eac3e3d86a --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementresultcreatetransaction.md @@ -0,0 +1,9 @@ +# V2BulkElementResultCreateTransaction + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `ResponseType` | *string* | :heavy_check_mark: | N/A | +| `Data` | [components.V2Transaction](../../models/components/v2transaction.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementresultdeletemetadata.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementresultdeletemetadata.md new file mode 100644 index 0000000000..40a8844207 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementresultdeletemetadata.md @@ -0,0 +1,8 @@ +# V2BulkElementResultDeleteMetadata + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `ResponseType` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementresulterror.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementresulterror.md new file mode 100644 index 0000000000..1fdefd1253 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementresulterror.md @@ -0,0 +1,11 @@ +# V2BulkElementResultError + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `ResponseType` | *string* | :heavy_check_mark: | N/A | +| `ErrorCode` | *string* | :heavy_check_mark: | N/A | +| `ErrorDescription` | *string* | :heavy_check_mark: | N/A | +| `ErrorDetails` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementresultreverttransaction.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementresultreverttransaction.md new file mode 100644 index 0000000000..b85016b600 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementresultreverttransaction.md @@ -0,0 +1,9 @@ +# V2BulkElementResultRevertTransaction + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `ResponseType` | *string* | :heavy_check_mark: | N/A | +| `Data` | [components.V2Transaction](../../models/components/v2transaction.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementreverttransaction.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementreverttransaction.md new file mode 100644 index 0000000000..189d5711ef --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementreverttransaction.md @@ -0,0 +1,10 @@ +# V2BulkElementRevertTransaction + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | +| `Action` | *string* | :heavy_check_mark: | N/A | +| `Ik` | **string* | :heavy_minus_sign: | N/A | +| `Data` | [*components.V2BulkElementRevertTransactionData](../../models/components/v2bulkelementreverttransactiondata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkelementreverttransactiondata.md b/components/ledger/pkg/client/docs/models/components/v2bulkelementreverttransactiondata.md new file mode 100644 index 0000000000..b15a498c55 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkelementreverttransactiondata.md @@ -0,0 +1,10 @@ +# V2BulkElementRevertTransactionData + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `ID` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | +| `Force` | **bool* | :heavy_minus_sign: | N/A | +| `AtEffectiveDate` | **bool* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2bulkresponse.md b/components/ledger/pkg/client/docs/models/components/v2bulkresponse.md new file mode 100644 index 0000000000..64c4956603 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2bulkresponse.md @@ -0,0 +1,8 @@ +# V2BulkResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `Data` | [][components.V2BulkElementResult](../../models/components/v2bulkelementresult.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2configinforesponse.md b/components/ledger/pkg/client/docs/models/components/v2configinforesponse.md new file mode 100644 index 0000000000..146140e08a --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2configinforesponse.md @@ -0,0 +1,9 @@ +# V2ConfigInfoResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Server` | *string* | :heavy_check_mark: | N/A | +| `Version` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2createledgerrequest.md b/components/ledger/pkg/client/docs/models/components/v2createledgerrequest.md new file mode 100644 index 0000000000..af6e8fd58c --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2createledgerrequest.md @@ -0,0 +1,9 @@ +# V2CreateLedgerRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `Bucket` | **string* | :heavy_minus_sign: | N/A | | +| `Metadata` | map[string]*string* | :heavy_minus_sign: | N/A | {
"admin": "true"
} | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2createtransactionresponse.md b/components/ledger/pkg/client/docs/models/components/v2createtransactionresponse.md new file mode 100644 index 0000000000..d5a3954e4f --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2createtransactionresponse.md @@ -0,0 +1,8 @@ +# V2CreateTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `Data` | [components.V2Transaction](../../models/components/v2transaction.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2errorsenum.md b/components/ledger/pkg/client/docs/models/components/v2errorsenum.md new file mode 100644 index 0000000000..088a86b2a0 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2errorsenum.md @@ -0,0 +1,19 @@ +# V2ErrorsEnum + + +## Values + +| Name | Value | +| ------------------------------- | ------------------------------- | +| `V2ErrorsEnumInternal` | INTERNAL | +| `V2ErrorsEnumInsufficientFund` | INSUFFICIENT_FUND | +| `V2ErrorsEnumValidation` | VALIDATION | +| `V2ErrorsEnumConflict` | CONFLICT | +| `V2ErrorsEnumCompilationFailed` | COMPILATION_FAILED | +| `V2ErrorsEnumMetadataOverride` | METADATA_OVERRIDE | +| `V2ErrorsEnumNotFound` | NOT_FOUND | +| `V2ErrorsEnumRevertOccurring` | REVERT_OCCURRING | +| `V2ErrorsEnumAlreadyRevert` | ALREADY_REVERT | +| `V2ErrorsEnumNoPostings` | NO_POSTINGS | +| `V2ErrorsEnumLedgerNotFound` | LEDGER_NOT_FOUND | +| `V2ErrorsEnumImport` | IMPORT | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2expandedtransaction.md b/components/ledger/pkg/client/docs/models/components/v2expandedtransaction.md new file mode 100644 index 0000000000..6df0fa3a42 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2expandedtransaction.md @@ -0,0 +1,15 @@ +# V2ExpandedTransaction + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| `Timestamp` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | | +| `Postings` | [][components.V2Posting](../../models/components/v2posting.md) | :heavy_check_mark: | N/A | | +| `Reference` | **string* | :heavy_minus_sign: | N/A | ref:001 | +| `Metadata` | map[string]*string* | :heavy_check_mark: | N/A | {
"admin": "true"
} | +| `ID` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | | +| `Reverted` | *bool* | :heavy_check_mark: | N/A | | +| `PreCommitVolumes` | map[string]map[string][components.V2Volume](../../models/components/v2volume.md) | :heavy_minus_sign: | N/A | {
"orders:1": {
"USD": {
"input": 100,
"output": 10,
"balance": 90
}
},
"orders:2": {
"USD": {
"input": 100,
"output": 10,
"balance": 90
}
}
} | +| `PostCommitVolumes` | map[string]map[string][components.V2Volume](../../models/components/v2volume.md) | :heavy_minus_sign: | N/A | {
"orders:1": {
"USD": {
"input": 100,
"output": 10,
"balance": 90
}
},
"orders:2": {
"USD": {
"input": 100,
"output": 10,
"balance": 90
}
}
} | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2getledgerresponse.md b/components/ledger/pkg/client/docs/models/components/v2getledgerresponse.md new file mode 100644 index 0000000000..bb0eae9315 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2getledgerresponse.md @@ -0,0 +1,8 @@ +# V2GetLedgerResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `Data` | [components.V2Ledger](../../models/components/v2ledger.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2gettransactionresponse.md b/components/ledger/pkg/client/docs/models/components/v2gettransactionresponse.md new file mode 100644 index 0000000000..08f98f748a --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2gettransactionresponse.md @@ -0,0 +1,8 @@ +# V2GetTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `Data` | [components.V2ExpandedTransaction](../../models/components/v2expandedtransaction.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2ledger.md b/components/ledger/pkg/client/docs/models/components/v2ledger.md new file mode 100644 index 0000000000..149a5a56b1 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2ledger.md @@ -0,0 +1,11 @@ +# V2Ledger + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | N/A | | +| `AddedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | | +| `Bucket` | *string* | :heavy_check_mark: | N/A | | +| `Metadata` | map[string]*string* | :heavy_minus_sign: | N/A | {
"admin": "true"
} | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2ledgerinfo.md b/components/ledger/pkg/client/docs/models/components/v2ledgerinfo.md new file mode 100644 index 0000000000..242a3b5a96 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2ledgerinfo.md @@ -0,0 +1,9 @@ +# V2LedgerInfo + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | +| `Name` | **string* | :heavy_minus_sign: | N/A | ledger001 | +| `Storage` | [*components.Storage](../../models/components/storage.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2ledgerinforesponse.md b/components/ledger/pkg/client/docs/models/components/v2ledgerinforesponse.md new file mode 100644 index 0000000000..bc3ded5267 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2ledgerinforesponse.md @@ -0,0 +1,8 @@ +# V2LedgerInfoResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | +| `Data` | [*components.V2LedgerInfo](../../models/components/v2ledgerinfo.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2ledgerlistresponse.md b/components/ledger/pkg/client/docs/models/components/v2ledgerlistresponse.md new file mode 100644 index 0000000000..a7cc73e92f --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2ledgerlistresponse.md @@ -0,0 +1,8 @@ +# V2LedgerListResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `Cursor` | [components.Cursor](../../models/components/cursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2log.md b/components/ledger/pkg/client/docs/models/components/v2log.md new file mode 100644 index 0000000000..c1fed5c74f --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2log.md @@ -0,0 +1,12 @@ +# V2Log + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | +| `ID` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | 1234 | +| `Type` | [components.Type](../../models/components/type.md) | :heavy_check_mark: | N/A | | +| `Data` | map[string]*any* | :heavy_check_mark: | N/A | | +| `Hash` | *string* | :heavy_check_mark: | N/A | 9ee060170400f556b7e1575cb13f9db004f150a08355c7431c62bc639166431e | +| `Date` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2logscursorresponse.md b/components/ledger/pkg/client/docs/models/components/v2logscursorresponse.md new file mode 100644 index 0000000000..8d564f7535 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2logscursorresponse.md @@ -0,0 +1,8 @@ +# V2LogsCursorResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `Cursor` | [components.V2LogsCursorResponseCursor](../../models/components/v2logscursorresponsecursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2logscursorresponsecursor.md b/components/ledger/pkg/client/docs/models/components/v2logscursorresponsecursor.md new file mode 100644 index 0000000000..2134beb488 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2logscursorresponsecursor.md @@ -0,0 +1,12 @@ +# V2LogsCursorResponseCursor + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.V2Log](../../models/components/v2log.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2migrationinfo.md b/components/ledger/pkg/client/docs/models/components/v2migrationinfo.md new file mode 100644 index 0000000000..e7a38da508 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2migrationinfo.md @@ -0,0 +1,11 @@ +# V2MigrationInfo + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | +| `Version` | **int64* | :heavy_minus_sign: | N/A | 11 | +| `Name` | **string* | :heavy_minus_sign: | N/A | migrations:001 | +| `Date` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `State` | [*components.State](../../models/components/state.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2posting.md b/components/ledger/pkg/client/docs/models/components/v2posting.md new file mode 100644 index 0000000000..9fa0277b40 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2posting.md @@ -0,0 +1,11 @@ +# V2Posting + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Amount` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | 100 | +| `Asset` | *string* | :heavy_check_mark: | N/A | COIN | +| `Destination` | *string* | :heavy_check_mark: | N/A | users:002 | +| `Source` | *string* | :heavy_check_mark: | N/A | users:001 | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2posttransaction.md b/components/ledger/pkg/client/docs/models/components/v2posttransaction.md new file mode 100644 index 0000000000..714919688e --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2posttransaction.md @@ -0,0 +1,12 @@ +# V2PostTransaction + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `Timestamp` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `Postings` | [][components.V2Posting](../../models/components/v2posting.md) | :heavy_minus_sign: | N/A | | +| `Script` | [*components.Script](../../models/components/script.md) | :heavy_minus_sign: | N/A | | +| `Reference` | **string* | :heavy_minus_sign: | N/A | ref:001 | +| `Metadata` | map[string]*string* | :heavy_check_mark: | N/A | {
"admin": "true"
} | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2reverttransactionresponse.md b/components/ledger/pkg/client/docs/models/components/v2reverttransactionresponse.md new file mode 100644 index 0000000000..db65ff1f7c --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2reverttransactionresponse.md @@ -0,0 +1,8 @@ +# V2RevertTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `Data` | [components.V2Transaction](../../models/components/v2transaction.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2stats.md b/components/ledger/pkg/client/docs/models/components/v2stats.md new file mode 100644 index 0000000000..15e788cd0f --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2stats.md @@ -0,0 +1,9 @@ +# V2Stats + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Accounts` | *int64* | :heavy_check_mark: | N/A | +| `Transactions` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2statsresponse.md b/components/ledger/pkg/client/docs/models/components/v2statsresponse.md new file mode 100644 index 0000000000..ebb1716406 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2statsresponse.md @@ -0,0 +1,8 @@ +# V2StatsResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `Data` | [components.V2Stats](../../models/components/v2stats.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2targetid.md b/components/ledger/pkg/client/docs/models/components/v2targetid.md new file mode 100644 index 0000000000..d10de04d2d --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2targetid.md @@ -0,0 +1,17 @@ +# V2TargetID + + +## Supported Types + +### + +```go +v2TargetID := components.CreateV2TargetIDStr(string{/* values here */}) +``` + +### + +```go +v2TargetID := components.CreateV2TargetIDBigint(*big.Int{/* values here */}) +``` + diff --git a/components/ledger/pkg/client/docs/models/components/v2targettype.md b/components/ledger/pkg/client/docs/models/components/v2targettype.md new file mode 100644 index 0000000000..e50c571508 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2targettype.md @@ -0,0 +1,9 @@ +# V2TargetType + + +## Values + +| Name | Value | +| ------------------------- | ------------------------- | +| `V2TargetTypeTransaction` | TRANSACTION | +| `V2TargetTypeAccount` | ACCOUNT | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2transaction.md b/components/ledger/pkg/client/docs/models/components/v2transaction.md new file mode 100644 index 0000000000..87c7060d13 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2transaction.md @@ -0,0 +1,13 @@ +# V2Transaction + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `Timestamp` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | | +| `Postings` | [][components.V2Posting](../../models/components/v2posting.md) | :heavy_check_mark: | N/A | | +| `Reference` | **string* | :heavy_minus_sign: | N/A | ref:001 | +| `Metadata` | map[string]*string* | :heavy_check_mark: | N/A | {
"admin": "true"
} | +| `ID` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | | +| `Reverted` | *bool* | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2transactionscursorresponse.md b/components/ledger/pkg/client/docs/models/components/v2transactionscursorresponse.md new file mode 100644 index 0000000000..7f2b797fd3 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2transactionscursorresponse.md @@ -0,0 +1,8 @@ +# V2TransactionsCursorResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | +| `Cursor` | [components.V2TransactionsCursorResponseCursor](../../models/components/v2transactionscursorresponsecursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2transactionscursorresponsecursor.md b/components/ledger/pkg/client/docs/models/components/v2transactionscursorresponsecursor.md new file mode 100644 index 0000000000..bb2df69952 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2transactionscursorresponsecursor.md @@ -0,0 +1,12 @@ +# V2TransactionsCursorResponseCursor + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.V2ExpandedTransaction](../../models/components/v2expandedtransaction.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2volume.md b/components/ledger/pkg/client/docs/models/components/v2volume.md new file mode 100644 index 0000000000..1b6c643e56 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2volume.md @@ -0,0 +1,10 @@ +# V2Volume + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Input` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | +| `Output` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | +| `Balance` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2volumeswithbalance.md b/components/ledger/pkg/client/docs/models/components/v2volumeswithbalance.md new file mode 100644 index 0000000000..a76f609f06 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2volumeswithbalance.md @@ -0,0 +1,12 @@ +# V2VolumesWithBalance + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Account` | *string* | :heavy_check_mark: | N/A | +| `Asset` | *string* | :heavy_check_mark: | N/A | +| `Input` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | +| `Output` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | +| `Balance` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2volumeswithbalancecursorresponse.md b/components/ledger/pkg/client/docs/models/components/v2volumeswithbalancecursorresponse.md new file mode 100644 index 0000000000..29fc052934 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2volumeswithbalancecursorresponse.md @@ -0,0 +1,8 @@ +# V2VolumesWithBalanceCursorResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | +| `Cursor` | [components.V2VolumesWithBalanceCursorResponseCursor](../../models/components/v2volumeswithbalancecursorresponsecursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/components/v2volumeswithbalancecursorresponsecursor.md b/components/ledger/pkg/client/docs/models/components/v2volumeswithbalancecursorresponsecursor.md new file mode 100644 index 0000000000..4145611d31 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/components/v2volumeswithbalancecursorresponsecursor.md @@ -0,0 +1,12 @@ +# V2VolumesWithBalanceCursorResponseCursor + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.V2VolumesWithBalance](../../models/components/v2volumeswithbalance.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/option.md b/components/ledger/pkg/client/docs/models/operations/option.md new file mode 100644 index 0000000000..35d8a1e2ad --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/option.md @@ -0,0 +1,37 @@ +## Options + +### WithServerURL + +WithServerURL allows providing an alternative server URL. + +```go +operations.WithServerURL("http://api.example.com") +``` + +## WithTemplatedServerURL + +WithTemplatedServerURL allows providing an alternative server URL with templated parameters. + +```go +operations.WithTemplatedServerURL("http://{host}:{port}", map[string]string{ + "host": "api.example.com", + "port": "8080", +}) +``` + +### WithRetries + +WithRetries allows customizing the default retry configuration. Only usable with methods that mention they support retries. + +```go +operations.WithRetries(retry.Config{ + Strategy: "backoff", + Backoff: retry.BackoffStrategy{ + InitialInterval: 500 * time.Millisecond, + MaxInterval: 60 * time.Second, + Exponent: 1.5, + MaxElapsedTime: 5 * time.Minute, + }, + RetryConnectionErrors: true, +}) +``` \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/order.md b/components/ledger/pkg/client/docs/models/operations/order.md new file mode 100644 index 0000000000..b29bc2b6b5 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/order.md @@ -0,0 +1,8 @@ +# Order + + +## Values + +| Name | Value | +| ---------------- | ---------------- | +| `OrderEffective` | effective | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2addmetadataontransactionrequest.md b/components/ledger/pkg/client/docs/models/operations/v2addmetadataontransactionrequest.md new file mode 100644 index 0000000000..ac45eb811a --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2addmetadataontransactionrequest.md @@ -0,0 +1,12 @@ +# V2AddMetadataOnTransactionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `ID` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `DryRun` | **bool* | :heavy_minus_sign: | Set the dryRun mode. Dry run mode doesn't add the logs to the database or publish a message to the message broker. | true | +| `IdempotencyKey` | **string* | :heavy_minus_sign: | Use an idempotency key | | +| `RequestBody` | map[string]*string* | :heavy_minus_sign: | metadata | {
"admin": "true"
} | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2addmetadataontransactionresponse.md b/components/ledger/pkg/client/docs/models/operations/v2addmetadataontransactionresponse.md new file mode 100644 index 0000000000..e2857cc7fe --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2addmetadataontransactionresponse.md @@ -0,0 +1,8 @@ +# V2AddMetadataOnTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2addmetadatatoaccountrequest.md b/components/ledger/pkg/client/docs/models/operations/v2addmetadatatoaccountrequest.md new file mode 100644 index 0000000000..2d0315b546 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2addmetadatatoaccountrequest.md @@ -0,0 +1,12 @@ +# V2AddMetadataToAccountRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Address` | *string* | :heavy_check_mark: | Exact address of the account. It must match the following regular expressions pattern:
```
^\w+(:\w+)*$
```
| users:001 | +| `DryRun` | **bool* | :heavy_minus_sign: | Set the dry run mode. Dry run mode doesn't add the logs to the database or publish a message to the message broker. | true | +| `IdempotencyKey` | **string* | :heavy_minus_sign: | Use an idempotency key | | +| `RequestBody` | map[string]*string* | :heavy_check_mark: | metadata | {
"admin": "true"
} | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2addmetadatatoaccountresponse.md b/components/ledger/pkg/client/docs/models/operations/v2addmetadatatoaccountresponse.md new file mode 100644 index 0000000000..6ddfee1565 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2addmetadatatoaccountresponse.md @@ -0,0 +1,8 @@ +# V2AddMetadataToAccountResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2countaccountsrequest.md b/components/ledger/pkg/client/docs/models/operations/v2countaccountsrequest.md new file mode 100644 index 0000000000..fdc614bbe5 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2countaccountsrequest.md @@ -0,0 +1,10 @@ +# V2CountAccountsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `RequestBody` | map[string]*any* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2countaccountsresponse.md b/components/ledger/pkg/client/docs/models/operations/v2countaccountsresponse.md new file mode 100644 index 0000000000..67f47e3002 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2countaccountsresponse.md @@ -0,0 +1,9 @@ +# V2CountAccountsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2counttransactionsrequest.md b/components/ledger/pkg/client/docs/models/operations/v2counttransactionsrequest.md new file mode 100644 index 0000000000..9e4c5cd880 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2counttransactionsrequest.md @@ -0,0 +1,10 @@ +# V2CountTransactionsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `RequestBody` | map[string]*any* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2counttransactionsresponse.md b/components/ledger/pkg/client/docs/models/operations/v2counttransactionsresponse.md new file mode 100644 index 0000000000..bb5a46aed4 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2counttransactionsresponse.md @@ -0,0 +1,9 @@ +# V2CountTransactionsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2createbulkrequest.md b/components/ledger/pkg/client/docs/models/operations/v2createbulkrequest.md new file mode 100644 index 0000000000..a3531bc224 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2createbulkrequest.md @@ -0,0 +1,9 @@ +# V2CreateBulkRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `RequestBody` | [][components.V2BulkElement](../../models/components/v2bulkelement.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2createbulkresponse.md b/components/ledger/pkg/client/docs/models/operations/v2createbulkresponse.md new file mode 100644 index 0000000000..692a7dabbe --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2createbulkresponse.md @@ -0,0 +1,9 @@ +# V2CreateBulkResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2BulkResponse` | [*components.V2BulkResponse](../../models/components/v2bulkresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2createledgerrequest.md b/components/ledger/pkg/client/docs/models/operations/v2createledgerrequest.md new file mode 100644 index 0000000000..65276e228c --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2createledgerrequest.md @@ -0,0 +1,9 @@ +# V2CreateLedgerRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `V2CreateLedgerRequest` | [*components.V2CreateLedgerRequest](../../models/components/v2createledgerrequest.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2createledgerresponse.md b/components/ledger/pkg/client/docs/models/operations/v2createledgerresponse.md new file mode 100644 index 0000000000..32651a2d6f --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2createledgerresponse.md @@ -0,0 +1,8 @@ +# V2CreateLedgerResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2createtransactionrequest.md b/components/ledger/pkg/client/docs/models/operations/v2createtransactionrequest.md new file mode 100644 index 0000000000..73fbead129 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2createtransactionrequest.md @@ -0,0 +1,11 @@ +# V2CreateTransactionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `DryRun` | **bool* | :heavy_minus_sign: | Set the dryRun mode. dry run mode doesn't add the logs to the database or publish a message to the message broker. | true | +| `IdempotencyKey` | **string* | :heavy_minus_sign: | Use an idempotency key | | +| `V2PostTransaction` | [components.V2PostTransaction](../../models/components/v2posttransaction.md) | :heavy_check_mark: | The request body must contain at least one of the following objects:
- `postings`: suitable for simple transactions
- `script`: enabling more complex transactions with Numscript
| | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2createtransactionresponse.md b/components/ledger/pkg/client/docs/models/operations/v2createtransactionresponse.md new file mode 100644 index 0000000000..b895b6b041 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2createtransactionresponse.md @@ -0,0 +1,9 @@ +# V2CreateTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2CreateTransactionResponse` | [*components.V2CreateTransactionResponse](../../models/components/v2createtransactionresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2deleteaccountmetadatarequest.md b/components/ledger/pkg/client/docs/models/operations/v2deleteaccountmetadatarequest.md new file mode 100644 index 0000000000..1a9c58e7fc --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2deleteaccountmetadatarequest.md @@ -0,0 +1,10 @@ +# V2DeleteAccountMetadataRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Address` | *string* | :heavy_check_mark: | Account address | | +| `Key` | *string* | :heavy_check_mark: | The key to remove. | foo | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2deleteaccountmetadataresponse.md b/components/ledger/pkg/client/docs/models/operations/v2deleteaccountmetadataresponse.md new file mode 100644 index 0000000000..2988236ef3 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2deleteaccountmetadataresponse.md @@ -0,0 +1,8 @@ +# V2DeleteAccountMetadataResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2deleteledgermetadatarequest.md b/components/ledger/pkg/client/docs/models/operations/v2deleteledgermetadatarequest.md new file mode 100644 index 0000000000..be1e38cd1a --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2deleteledgermetadatarequest.md @@ -0,0 +1,9 @@ +# V2DeleteLedgerMetadataRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Key` | *string* | :heavy_check_mark: | Key to remove. | foo | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2deleteledgermetadataresponse.md b/components/ledger/pkg/client/docs/models/operations/v2deleteledgermetadataresponse.md new file mode 100644 index 0000000000..b85b317a34 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2deleteledgermetadataresponse.md @@ -0,0 +1,8 @@ +# V2DeleteLedgerMetadataResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2deletetransactionmetadatarequest.md b/components/ledger/pkg/client/docs/models/operations/v2deletetransactionmetadatarequest.md new file mode 100644 index 0000000000..4d2ba6adf4 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2deletetransactionmetadatarequest.md @@ -0,0 +1,10 @@ +# V2DeleteTransactionMetadataRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `ID` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `Key` | *string* | :heavy_check_mark: | The key to remove. | foo | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2deletetransactionmetadataresponse.md b/components/ledger/pkg/client/docs/models/operations/v2deletetransactionmetadataresponse.md new file mode 100644 index 0000000000..37b2b98130 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2deletetransactionmetadataresponse.md @@ -0,0 +1,8 @@ +# V2DeleteTransactionMetadataResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2exportlogsrequest.md b/components/ledger/pkg/client/docs/models/operations/v2exportlogsrequest.md new file mode 100644 index 0000000000..5c1c15baab --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2exportlogsrequest.md @@ -0,0 +1,8 @@ +# V2ExportLogsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2exportlogsresponse.md b/components/ledger/pkg/client/docs/models/operations/v2exportlogsresponse.md new file mode 100644 index 0000000000..488d5b56e6 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2exportlogsresponse.md @@ -0,0 +1,8 @@ +# V2ExportLogsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getaccountrequest.md b/components/ledger/pkg/client/docs/models/operations/v2getaccountrequest.md new file mode 100644 index 0000000000..1d25646573 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getaccountrequest.md @@ -0,0 +1,11 @@ +# V2GetAccountRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Address` | *string* | :heavy_check_mark: | Exact address of the account. It must match the following regular expressions pattern:
```
^\w+(:\w+)*$
```
| users:001 | +| `Expand` | **string* | :heavy_minus_sign: | N/A | | +| `Pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getaccountresponse.md b/components/ledger/pkg/client/docs/models/operations/v2getaccountresponse.md new file mode 100644 index 0000000000..9a9d7e5a3a --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getaccountresponse.md @@ -0,0 +1,9 @@ +# V2GetAccountResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2AccountResponse` | [*components.V2AccountResponse](../../models/components/v2accountresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getbalancesaggregatedrequest.md b/components/ledger/pkg/client/docs/models/operations/v2getbalancesaggregatedrequest.md new file mode 100644 index 0000000000..1a6c42684b --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getbalancesaggregatedrequest.md @@ -0,0 +1,11 @@ +# V2GetBalancesAggregatedRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `UseInsertionDate` | **bool* | :heavy_minus_sign: | Use insertion date instead of effective date | | +| `RequestBody` | map[string]*any* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getbalancesaggregatedresponse.md b/components/ledger/pkg/client/docs/models/operations/v2getbalancesaggregatedresponse.md new file mode 100644 index 0000000000..da586c4565 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getbalancesaggregatedresponse.md @@ -0,0 +1,9 @@ +# V2GetBalancesAggregatedResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2AggregateBalancesResponse` | [*components.V2AggregateBalancesResponse](../../models/components/v2aggregatebalancesresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getinforesponse.md b/components/ledger/pkg/client/docs/models/operations/v2getinforesponse.md new file mode 100644 index 0000000000..e7589f89ac --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getinforesponse.md @@ -0,0 +1,10 @@ +# V2GetInfoResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2ConfigInfoResponse` | [*components.V2ConfigInfoResponse](../../models/components/v2configinforesponse.md) | :heavy_minus_sign: | OK | +| `V2ErrorResponse` | **sdkerrors.V2ErrorResponse* | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getledgerinforequest.md b/components/ledger/pkg/client/docs/models/operations/v2getledgerinforequest.md new file mode 100644 index 0000000000..8d240702ee --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getledgerinforequest.md @@ -0,0 +1,8 @@ +# V2GetLedgerInfoRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getledgerinforesponse.md b/components/ledger/pkg/client/docs/models/operations/v2getledgerinforesponse.md new file mode 100644 index 0000000000..ef1f04482a --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getledgerinforesponse.md @@ -0,0 +1,9 @@ +# V2GetLedgerInfoResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2LedgerInfoResponse` | [*components.V2LedgerInfoResponse](../../models/components/v2ledgerinforesponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getledgerrequest.md b/components/ledger/pkg/client/docs/models/operations/v2getledgerrequest.md new file mode 100644 index 0000000000..4114f4395e --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getledgerrequest.md @@ -0,0 +1,8 @@ +# V2GetLedgerRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getledgerresponse.md b/components/ledger/pkg/client/docs/models/operations/v2getledgerresponse.md new file mode 100644 index 0000000000..3592b788da --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getledgerresponse.md @@ -0,0 +1,9 @@ +# V2GetLedgerResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2GetLedgerResponse` | [*components.V2GetLedgerResponse](../../models/components/v2getledgerresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2gettransactionrequest.md b/components/ledger/pkg/client/docs/models/operations/v2gettransactionrequest.md new file mode 100644 index 0000000000..92b7f458a8 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2gettransactionrequest.md @@ -0,0 +1,11 @@ +# V2GetTransactionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `ID` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `Expand` | **string* | :heavy_minus_sign: | N/A | | +| `Pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2gettransactionresponse.md b/components/ledger/pkg/client/docs/models/operations/v2gettransactionresponse.md new file mode 100644 index 0000000000..3d99fcecb0 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2gettransactionresponse.md @@ -0,0 +1,9 @@ +# V2GetTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2GetTransactionResponse` | [*components.V2GetTransactionResponse](../../models/components/v2gettransactionresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getvolumeswithbalancesrequest.md b/components/ledger/pkg/client/docs/models/operations/v2getvolumeswithbalancesrequest.md new file mode 100644 index 0000000000..1d7fa21ded --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getvolumeswithbalancesrequest.md @@ -0,0 +1,15 @@ +# V2GetVolumesWithBalancesRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `PageSize` | **int64* | :heavy_minus_sign: | The maximum number of results to return per page.
| 100 | +| `Cursor` | **string* | :heavy_minus_sign: | Parameter used in pagination requests. Maximum page size is set to 15.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `EndTime` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `StartTime` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `InsertionDate` | **bool* | :heavy_minus_sign: | Use insertion date instead of effective date | | +| `GroupBy` | **int64* | :heavy_minus_sign: | Group volumes and balance by the level of the segment of the address | 3 | +| `RequestBody` | map[string]*any* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2getvolumeswithbalancesresponse.md b/components/ledger/pkg/client/docs/models/operations/v2getvolumeswithbalancesresponse.md new file mode 100644 index 0000000000..2bbf1c9bb8 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2getvolumeswithbalancesresponse.md @@ -0,0 +1,9 @@ +# V2GetVolumesWithBalancesResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2VolumesWithBalanceCursorResponse` | [*components.V2VolumesWithBalanceCursorResponse](../../models/components/v2volumeswithbalancecursorresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2importlogsrequest.md b/components/ledger/pkg/client/docs/models/operations/v2importlogsrequest.md new file mode 100644 index 0000000000..605864e81b --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2importlogsrequest.md @@ -0,0 +1,9 @@ +# V2ImportLogsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `RequestBody` | **string* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2importlogsresponse.md b/components/ledger/pkg/client/docs/models/operations/v2importlogsresponse.md new file mode 100644 index 0000000000..2e24461ea2 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2importlogsresponse.md @@ -0,0 +1,8 @@ +# V2ImportLogsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2listaccountsrequest.md b/components/ledger/pkg/client/docs/models/operations/v2listaccountsrequest.md new file mode 100644 index 0000000000..a55a6bf000 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2listaccountsrequest.md @@ -0,0 +1,13 @@ +# V2ListAccountsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `PageSize` | **int64* | :heavy_minus_sign: | The maximum number of results to return per page.
| 100 | +| `Cursor` | **string* | :heavy_minus_sign: | Parameter used in pagination requests. Maximum page size is set to 15.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | +| `Expand` | **string* | :heavy_minus_sign: | N/A | | +| `Pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `RequestBody` | map[string]*any* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2listaccountsresponse.md b/components/ledger/pkg/client/docs/models/operations/v2listaccountsresponse.md new file mode 100644 index 0000000000..f0c5d3e24c --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2listaccountsresponse.md @@ -0,0 +1,9 @@ +# V2ListAccountsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2AccountsCursorResponse` | [*components.V2AccountsCursorResponse](../../models/components/v2accountscursorresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2listledgersrequest.md b/components/ledger/pkg/client/docs/models/operations/v2listledgersrequest.md new file mode 100644 index 0000000000..9263467fde --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2listledgersrequest.md @@ -0,0 +1,9 @@ +# V2ListLedgersRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `PageSize` | **int64* | :heavy_minus_sign: | The maximum number of results to return per page.
| 100 | +| `Cursor` | **string* | :heavy_minus_sign: | Parameter used in pagination requests. Maximum page size is set to 15.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2listledgersresponse.md b/components/ledger/pkg/client/docs/models/operations/v2listledgersresponse.md new file mode 100644 index 0000000000..d5c67c727a --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2listledgersresponse.md @@ -0,0 +1,9 @@ +# V2ListLedgersResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2LedgerListResponse` | [*components.V2LedgerListResponse](../../models/components/v2ledgerlistresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2listlogsrequest.md b/components/ledger/pkg/client/docs/models/operations/v2listlogsrequest.md new file mode 100644 index 0000000000..19fdb9650d --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2listlogsrequest.md @@ -0,0 +1,12 @@ +# V2ListLogsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `PageSize` | **int64* | :heavy_minus_sign: | The maximum number of results to return per page.
| 100 | +| `Cursor` | **string* | :heavy_minus_sign: | Parameter used in pagination requests. Maximum page size is set to 15.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | +| `Pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `RequestBody` | map[string]*any* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2listlogsresponse.md b/components/ledger/pkg/client/docs/models/operations/v2listlogsresponse.md new file mode 100644 index 0000000000..429514bb3c --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2listlogsresponse.md @@ -0,0 +1,9 @@ +# V2ListLogsResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2LogsCursorResponse` | [*components.V2LogsCursorResponse](../../models/components/v2logscursorresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2listtransactionsrequest.md b/components/ledger/pkg/client/docs/models/operations/v2listtransactionsrequest.md new file mode 100644 index 0000000000..eb6f8c5ea3 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2listtransactionsrequest.md @@ -0,0 +1,15 @@ +# V2ListTransactionsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `PageSize` | **int64* | :heavy_minus_sign: | The maximum number of results to return per page.
| 100 | +| `Cursor` | **string* | :heavy_minus_sign: | Parameter used in pagination requests. Maximum page size is set to 15.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | +| `Expand` | **string* | :heavy_minus_sign: | N/A | | +| `Pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `Order` | [*operations.Order](../../models/operations/order.md) | :heavy_minus_sign: | N/A | | +| `Reverse` | **bool* | :heavy_minus_sign: | N/A | | +| `RequestBody` | map[string]*any* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2listtransactionsresponse.md b/components/ledger/pkg/client/docs/models/operations/v2listtransactionsresponse.md new file mode 100644 index 0000000000..d123903284 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2listtransactionsresponse.md @@ -0,0 +1,9 @@ +# V2ListTransactionsResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2TransactionsCursorResponse` | [*components.V2TransactionsCursorResponse](../../models/components/v2transactionscursorresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2readstatsrequest.md b/components/ledger/pkg/client/docs/models/operations/v2readstatsrequest.md new file mode 100644 index 0000000000..890f0883c5 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2readstatsrequest.md @@ -0,0 +1,8 @@ +# V2ReadStatsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | +| `Ledger` | *string* | :heavy_check_mark: | name of the ledger | ledger001 | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2readstatsresponse.md b/components/ledger/pkg/client/docs/models/operations/v2readstatsresponse.md new file mode 100644 index 0000000000..26fbd3a291 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2readstatsresponse.md @@ -0,0 +1,9 @@ +# V2ReadStatsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2StatsResponse` | [*components.V2StatsResponse](../../models/components/v2statsresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2reverttransactionrequest.md b/components/ledger/pkg/client/docs/models/operations/v2reverttransactionrequest.md new file mode 100644 index 0000000000..58973420d5 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2reverttransactionrequest.md @@ -0,0 +1,11 @@ +# V2RevertTransactionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `ID` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `Force` | **bool* | :heavy_minus_sign: | Force revert | | +| `AtEffectiveDate` | **bool* | :heavy_minus_sign: | Revert transaction at effective date of the original tx | | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2reverttransactionresponse.md b/components/ledger/pkg/client/docs/models/operations/v2reverttransactionresponse.md new file mode 100644 index 0000000000..9f1a7374cb --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2reverttransactionresponse.md @@ -0,0 +1,9 @@ +# V2RevertTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2RevertTransactionResponse` | [*components.V2RevertTransactionResponse](../../models/components/v2reverttransactionresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2updateledgermetadatarequest.md b/components/ledger/pkg/client/docs/models/operations/v2updateledgermetadatarequest.md new file mode 100644 index 0000000000..79b7f1eb5c --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2updateledgermetadatarequest.md @@ -0,0 +1,9 @@ +# V2UpdateLedgerMetadataRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `RequestBody` | map[string]*string* | :heavy_minus_sign: | N/A | {
"admin": "true"
} | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/operations/v2updateledgermetadataresponse.md b/components/ledger/pkg/client/docs/models/operations/v2updateledgermetadataresponse.md new file mode 100644 index 0000000000..c2e3ced729 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/operations/v2updateledgermetadataresponse.md @@ -0,0 +1,9 @@ +# V2UpdateLedgerMetadataResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V2ErrorResponse` | **sdkerrors.V2ErrorResponse* | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/models/sdkerrors/v2errorresponse.md b/components/ledger/pkg/client/docs/models/sdkerrors/v2errorresponse.md new file mode 100644 index 0000000000..a7810cedd0 --- /dev/null +++ b/components/ledger/pkg/client/docs/models/sdkerrors/v2errorresponse.md @@ -0,0 +1,12 @@ +# V2ErrorResponse + +Error + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `ErrorCode` | [components.V2ErrorsEnum](../../models/components/v2errorsenum.md) | :heavy_check_mark: | N/A | VALIDATION | +| `ErrorMessage` | *string* | :heavy_check_mark: | N/A | [VALIDATION] invalid 'cursor' query param | +| `Details` | **string* | :heavy_minus_sign: | N/A | https://play.numscript.org/?payload=eyJlcnJvciI6ImFjY291bnQgaGFkIGluc3VmZmljaWVudCBmdW5kcyJ9 | \ No newline at end of file diff --git a/components/ledger/pkg/client/docs/sdks/formance/README.md b/components/ledger/pkg/client/docs/sdks/formance/README.md new file mode 100644 index 0000000000..158bf7083e --- /dev/null +++ b/components/ledger/pkg/client/docs/sdks/formance/README.md @@ -0,0 +1,7 @@ +# Formance SDK + + +## Overview + +### Available Operations + diff --git a/components/ledger/pkg/client/docs/sdks/ledger/README.md b/components/ledger/pkg/client/docs/sdks/ledger/README.md new file mode 100644 index 0000000000..9609c10c1a --- /dev/null +++ b/components/ledger/pkg/client/docs/sdks/ledger/README.md @@ -0,0 +1,5 @@ +# Ledger +(*Ledger*) + +### Available Operations + diff --git a/components/ledger/pkg/client/docs/sdks/v2/README.md b/components/ledger/pkg/client/docs/sdks/v2/README.md new file mode 100644 index 0000000000..85d6f5552a --- /dev/null +++ b/components/ledger/pkg/client/docs/sdks/v2/README.md @@ -0,0 +1,1438 @@ +# V2 +(*Ledger.V2*) + +### Available Operations + +* [GetInfo](#getinfo) - Show server information +* [ListLedgers](#listledgers) - List ledgers +* [GetLedger](#getledger) - Get a ledger +* [CreateLedger](#createledger) - Create a ledger +* [UpdateLedgerMetadata](#updateledgermetadata) - Update ledger metadata +* [DeleteLedgerMetadata](#deleteledgermetadata) - Delete ledger metadata by key +* [GetLedgerInfo](#getledgerinfo) - Get information about a ledger +* [CreateBulk](#createbulk) - Bulk request +* [CountAccounts](#countaccounts) - Count the accounts from a ledger +* [ListAccounts](#listaccounts) - List accounts from a ledger +* [GetAccount](#getaccount) - Get account by its address +* [AddMetadataToAccount](#addmetadatatoaccount) - Add metadata to an account +* [DeleteAccountMetadata](#deleteaccountmetadata) - Delete metadata by key +* [ReadStats](#readstats) - Get statistics from a ledger +* [CountTransactions](#counttransactions) - Count the transactions from a ledger +* [ListTransactions](#listtransactions) - List transactions from a ledger +* [CreateTransaction](#createtransaction) - Create a new transaction to a ledger +* [GetTransaction](#gettransaction) - Get transaction from a ledger by its ID +* [AddMetadataOnTransaction](#addmetadataontransaction) - Set the metadata of a transaction by its ID +* [DeleteTransactionMetadata](#deletetransactionmetadata) - Delete metadata by key +* [RevertTransaction](#reverttransaction) - Revert a ledger transaction by its ID +* [GetBalancesAggregated](#getbalancesaggregated) - Get the aggregated balances from selected accounts +* [GetVolumesWithBalances](#getvolumeswithbalances) - Get list of volumes with balances for (account/asset) +* [ListLogs](#listlogs) - List the logs from a ledger +* [ImportLogs](#importlogs) +* [ExportLogs](#exportlogs) - Export logs + +## GetInfo + +Show server information + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "context" + "log" +) + +func main() { + s := client.New() + + ctx := context.Background() + res, err := s.Ledger.V2.GetInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.V2ConfigInfoResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.V2GetInfoResponse](../../models/operations/v2getinforesponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## ListLedgers + +List ledgers + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "context" + "log" +) + +func main() { + s := client.New() + var pageSize *int64 = client.Int64(100) + + var cursor *string = client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==") + ctx := context.Background() + res, err := s.Ledger.V2.ListLedgers(ctx, pageSize, cursor) + if err != nil { + log.Fatal(err) + } + if res.V2LedgerListResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `pageSize` | **int64* | :heavy_minus_sign: | The maximum number of results to return per page.
| 100 | +| `cursor` | **string* | :heavy_minus_sign: | Parameter used in pagination requests. Maximum page size is set to 15.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2ListLedgersResponse](../../models/operations/v2listledgersresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## GetLedger + +Get a ledger + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + ctx := context.Background() + res, err := s.Ledger.V2.GetLedger(ctx, ledger) + if err != nil { + log.Fatal(err) + } + if res.V2GetLedgerResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2GetLedgerResponse](../../models/operations/v2getledgerresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## CreateLedger + +Create a ledger + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/components" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var v2CreateLedgerRequest *components.V2CreateLedgerRequest = &components.V2CreateLedgerRequest{ + Metadata: map[string]string{ + "admin": "true", + }, + } + ctx := context.Background() + res, err := s.Ledger.V2.CreateLedger(ctx, ledger, v2CreateLedgerRequest) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `v2CreateLedgerRequest` | [*components.V2CreateLedgerRequest](../../models/components/v2createledgerrequest.md) | :heavy_minus_sign: | N/A | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2CreateLedgerResponse](../../models/operations/v2createledgerresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## UpdateLedgerMetadata + +Update ledger metadata + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var requestBody map[string]string = map[string]string{ + "admin": "true", + } + ctx := context.Background() + res, err := s.Ledger.V2.UpdateLedgerMetadata(ctx, ledger, requestBody) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `requestBody` | map[string]*string* | :heavy_minus_sign: | N/A | {
"admin": "true"
} | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2UpdateLedgerMetadataResponse](../../models/operations/v2updateledgermetadataresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## DeleteLedgerMetadata + +Delete ledger metadata by key + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var key string = "foo" + ctx := context.Background() + res, err := s.Ledger.V2.DeleteLedgerMetadata(ctx, ledger, key) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `key` | *string* | :heavy_check_mark: | Key to remove. | foo | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2DeleteLedgerMetadataResponse](../../models/operations/v2deleteledgermetadataresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## GetLedgerInfo + +Get information about a ledger + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + ctx := context.Background() + res, err := s.Ledger.V2.GetLedgerInfo(ctx, ledger) + if err != nil { + log.Fatal(err) + } + if res.V2LedgerInfoResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2GetLedgerInfoResponse](../../models/operations/v2getledgerinforesponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## CreateBulk + +Bulk request + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/components" + "math/big" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var requestBody []components.V2BulkElement = []components.V2BulkElement{ + components.CreateV2BulkElementV2BulkElementCreateTransaction( + components.V2BulkElementCreateTransaction{ + Action: "", + Data: &components.V2PostTransaction{ + Postings: []components.V2Posting{ + components.V2Posting{ + Amount: big.NewInt(100), + Asset: "COIN", + Destination: "users:002", + Source: "users:001", + }, + }, + Script: &components.Script{ + Plain: "vars { + account $user + } + send [COIN 10] ( + source = @world + destination = $user + ) + ", + Vars: map[string]any{ + "user": "users:042", + }, + }, + Reference: client.String("ref:001"), + Metadata: map[string]string{ + "admin": "true", + }, + }, + }, + ), + } + ctx := context.Background() + res, err := s.Ledger.V2.CreateBulk(ctx, ledger, requestBody) + if err != nil { + log.Fatal(err) + } + if res.V2BulkResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `requestBody` | [][components.V2BulkElement](../../models/components/v2bulkelement.md) | :heavy_minus_sign: | N/A | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2CreateBulkResponse](../../models/operations/v2createbulkresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## CountAccounts + +Count the accounts from a ledger + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "time" + "github.com/formancehq/stack/ledger/client/types" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var pit *time.Time = types.MustNewTimeFromString("2022-10-10T12:32:37.132Z") + + var requestBody map[string]any = map[string]any{ + "key": "", + } + ctx := context.Background() + res, err := s.Ledger.V2.CountAccounts(ctx, ledger, pit, requestBody) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `requestBody` | map[string]*any* | :heavy_minus_sign: | N/A | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2CountAccountsResponse](../../models/operations/v2countaccountsresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## ListAccounts + +List accounts from a ledger, sorted by address in descending order. + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/operations" + "context" + "log" +) + +func main() { + s := client.New() + request := operations.V2ListAccountsRequest{ + Ledger: "ledger001", + PageSize: client.Int64(100), + Cursor: client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="), + } + ctx := context.Background() + res, err := s.Ledger.V2.ListAccounts(ctx, request) + if err != nil { + log.Fatal(err) + } + if res.V2AccountsCursorResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.V2ListAccountsRequest](../../models/operations/v2listaccountsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.V2ListAccountsResponse](../../models/operations/v2listaccountsresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## GetAccount + +Get account by its address + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "time" + "github.com/formancehq/stack/ledger/client/types" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var address string = "users:001" + + var expand *string = client.String("") + + var pit *time.Time = types.MustNewTimeFromString("2022-06-03T07:35:25.275Z") + ctx := context.Background() + res, err := s.Ledger.V2.GetAccount(ctx, ledger, address, expand, pit) + if err != nil { + log.Fatal(err) + } + if res.V2AccountResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `address` | *string* | :heavy_check_mark: | Exact address of the account. It must match the following regular expressions pattern:
```
^\w+(:\w+)*$
```
| users:001 | +| `expand` | **string* | :heavy_minus_sign: | N/A | | +| `pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2GetAccountResponse](../../models/operations/v2getaccountresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## AddMetadataToAccount + +Add metadata to an account + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/operations" + "context" + "log" +) + +func main() { + s := client.New() + request := operations.V2AddMetadataToAccountRequest{ + Ledger: "ledger001", + Address: "users:001", + DryRun: client.Bool(true), + RequestBody: map[string]string{ + "admin": "true", + }, + } + ctx := context.Background() + res, err := s.Ledger.V2.AddMetadataToAccount(ctx, request) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.V2AddMetadataToAccountRequest](../../models/operations/v2addmetadatatoaccountrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.V2AddMetadataToAccountResponse](../../models/operations/v2addmetadatatoaccountresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## DeleteAccountMetadata + +Delete metadata by key + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var address string = "" + + var key string = "foo" + ctx := context.Background() + res, err := s.Ledger.V2.DeleteAccountMetadata(ctx, ledger, address, key) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `address` | *string* | :heavy_check_mark: | Account address | | +| `key` | *string* | :heavy_check_mark: | The key to remove. | foo | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2DeleteAccountMetadataResponse](../../models/operations/v2deleteaccountmetadataresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## ReadStats + +Get statistics from a ledger. (aggregate metrics on accounts and transactions) + + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + ctx := context.Background() + res, err := s.Ledger.V2.ReadStats(ctx, ledger) + if err != nil { + log.Fatal(err) + } + if res.V2StatsResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | name of the ledger | ledger001 | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2ReadStatsResponse](../../models/operations/v2readstatsresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## CountTransactions + +Count the transactions from a ledger + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "time" + "github.com/formancehq/stack/ledger/client/types" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var pit *time.Time = types.MustNewTimeFromString("2023-09-24T09:44:43.830Z") + + var requestBody map[string]any = map[string]any{ + "key": "", + } + ctx := context.Background() + res, err := s.Ledger.V2.CountTransactions(ctx, ledger, pit, requestBody) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `requestBody` | map[string]*any* | :heavy_minus_sign: | N/A | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2CountTransactionsResponse](../../models/operations/v2counttransactionsresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## ListTransactions + +List transactions from a ledger, sorted by id in descending order. + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/operations" + "context" + "log" +) + +func main() { + s := client.New() + request := operations.V2ListTransactionsRequest{ + Ledger: "ledger001", + PageSize: client.Int64(100), + Cursor: client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="), + } + ctx := context.Background() + res, err := s.Ledger.V2.ListTransactions(ctx, request) + if err != nil { + log.Fatal(err) + } + if res.V2TransactionsCursorResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.V2ListTransactionsRequest](../../models/operations/v2listtransactionsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.V2ListTransactionsResponse](../../models/operations/v2listtransactionsresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## CreateTransaction + +Create a new transaction to a ledger + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "math/big" + "github.com/formancehq/stack/ledger/client/models/components" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + v2PostTransaction := components.V2PostTransaction{ + Postings: []components.V2Posting{ + components.V2Posting{ + Amount: big.NewInt(100), + Asset: "COIN", + Destination: "users:002", + Source: "users:001", + }, + }, + Script: &components.Script{ + Plain: "vars { + account $user + } + send [COIN 10] ( + source = @world + destination = $user + ) + ", + Vars: map[string]any{ + "user": "users:042", + }, + }, + Reference: client.String("ref:001"), + Metadata: map[string]string{ + "admin": "true", + }, + } + + var dryRun *bool = client.Bool(true) + + var idempotencyKey *string = client.String("") + ctx := context.Background() + res, err := s.Ledger.V2.CreateTransaction(ctx, ledger, v2PostTransaction, dryRun, idempotencyKey) + if err != nil { + log.Fatal(err) + } + if res.V2CreateTransactionResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `v2PostTransaction` | [components.V2PostTransaction](../../models/components/v2posttransaction.md) | :heavy_check_mark: | The request body must contain at least one of the following objects:
- `postings`: suitable for simple transactions
- `script`: enabling more complex transactions with Numscript
| | +| `dryRun` | **bool* | :heavy_minus_sign: | Set the dryRun mode. dry run mode doesn't add the logs to the database or publish a message to the message broker. | true | +| `idempotencyKey` | **string* | :heavy_minus_sign: | Use an idempotency key | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2CreateTransactionResponse](../../models/operations/v2createtransactionresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## GetTransaction + +Get transaction from a ledger by its ID + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "math/big" + "time" + "github.com/formancehq/stack/ledger/client/types" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var id *big.Int = big.NewInt(1234) + + var expand *string = client.String("") + + var pit *time.Time = types.MustNewTimeFromString("2023-08-22T15:58:06.441Z") + ctx := context.Background() + res, err := s.Ledger.V2.GetTransaction(ctx, ledger, id, expand, pit) + if err != nil { + log.Fatal(err) + } + if res.V2GetTransactionResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `id` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `expand` | **string* | :heavy_minus_sign: | N/A | | +| `pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2GetTransactionResponse](../../models/operations/v2gettransactionresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## AddMetadataOnTransaction + +Set the metadata of a transaction by its ID + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "math/big" + "github.com/formancehq/stack/ledger/client/models/operations" + "context" + "log" +) + +func main() { + s := client.New() + request := operations.V2AddMetadataOnTransactionRequest{ + Ledger: "ledger001", + ID: big.NewInt(1234), + DryRun: client.Bool(true), + RequestBody: map[string]string{ + "admin": "true", + }, + } + ctx := context.Background() + res, err := s.Ledger.V2.AddMetadataOnTransaction(ctx, request) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.V2AddMetadataOnTransactionRequest](../../models/operations/v2addmetadataontransactionrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.V2AddMetadataOnTransactionResponse](../../models/operations/v2addmetadataontransactionresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## DeleteTransactionMetadata + +Delete metadata by key + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "math/big" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var id *big.Int = big.NewInt(1234) + + var key string = "foo" + ctx := context.Background() + res, err := s.Ledger.V2.DeleteTransactionMetadata(ctx, ledger, id, key) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `id` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `key` | *string* | :heavy_check_mark: | The key to remove. | foo | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2DeleteTransactionMetadataResponse](../../models/operations/v2deletetransactionmetadataresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## RevertTransaction + +Revert a ledger transaction by its ID + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "math/big" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var id *big.Int = big.NewInt(1234) + + var force *bool = client.Bool(false) + + var atEffectiveDate *bool = client.Bool(false) + ctx := context.Background() + res, err := s.Ledger.V2.RevertTransaction(ctx, ledger, id, force, atEffectiveDate) + if err != nil { + log.Fatal(err) + } + if res.V2RevertTransactionResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `id` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `force` | **bool* | :heavy_minus_sign: | Force revert | | +| `atEffectiveDate` | **bool* | :heavy_minus_sign: | Revert transaction at effective date of the original tx | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2RevertTransactionResponse](../../models/operations/v2reverttransactionresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## GetBalancesAggregated + +Get the aggregated balances from selected accounts + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "time" + "github.com/formancehq/stack/ledger/client/types" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var pit *time.Time = types.MustNewTimeFromString("2023-02-24T06:23:10.823Z") + + var useInsertionDate *bool = client.Bool(false) + + var requestBody map[string]any = map[string]any{ + "key": "", + } + ctx := context.Background() + res, err := s.Ledger.V2.GetBalancesAggregated(ctx, ledger, pit, useInsertionDate, requestBody) + if err != nil { + log.Fatal(err) + } + if res.V2AggregateBalancesResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `pit` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `useInsertionDate` | **bool* | :heavy_minus_sign: | Use insertion date instead of effective date | | +| `requestBody` | map[string]*any* | :heavy_minus_sign: | N/A | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2GetBalancesAggregatedResponse](../../models/operations/v2getbalancesaggregatedresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## GetVolumesWithBalances + +Get list of volumes with balances for (account/asset) + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/operations" + "context" + "log" +) + +func main() { + s := client.New() + request := operations.V2GetVolumesWithBalancesRequest{ + PageSize: client.Int64(100), + Cursor: client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="), + Ledger: "ledger001", + GroupBy: client.Int64(3), + } + ctx := context.Background() + res, err := s.Ledger.V2.GetVolumesWithBalances(ctx, request) + if err != nil { + log.Fatal(err) + } + if res.V2VolumesWithBalanceCursorResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.V2GetVolumesWithBalancesRequest](../../models/operations/v2getvolumeswithbalancesrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.V2GetVolumesWithBalancesResponse](../../models/operations/v2getvolumeswithbalancesresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## ListLogs + +List the logs from a ledger, sorted by ID in descending order. + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/operations" + "context" + "log" +) + +func main() { + s := client.New() + request := operations.V2ListLogsRequest{ + Ledger: "ledger001", + PageSize: client.Int64(100), + Cursor: client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="), + } + ctx := context.Background() + res, err := s.Ledger.V2.ListLogs(ctx, request) + if err != nil { + log.Fatal(err) + } + if res.V2LogsCursorResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.V2ListLogsRequest](../../models/operations/v2listlogsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.V2ListLogsResponse](../../models/operations/v2listlogsresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## ImportLogs + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + + var requestBody *string = client.String("") + ctx := context.Background() + res, err := s.Ledger.V2.ImportLogs(ctx, ledger, requestBody) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `requestBody` | **string* | :heavy_minus_sign: | N/A | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2ImportLogsResponse](../../models/operations/v2importlogsresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## ExportLogs + +Export logs + +### Example Usage + +```go +package main + +import( + "github.com/formancehq/stack/ledger/client" + "context" + "log" +) + +func main() { + s := client.New() + var ledger string = "ledger001" + ctx := context.Background() + res, err := s.Ledger.V2.ExportLogs(ctx, ledger) + if err != nil { + log.Fatal(err) + } + if res != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.V2ExportLogsResponse](../../models/operations/v2exportlogsresponse.md), error** +| Error Object | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| sdkerrors.SDKError | 4xx-5xx | */* | diff --git a/components/ledger/pkg/client/formance.go b/components/ledger/pkg/client/formance.go new file mode 100644 index 0000000000..93719b35da --- /dev/null +++ b/components/ledger/pkg/client/formance.go @@ -0,0 +1,153 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package client + +import ( + "fmt" + "github.com/formancehq/stack/ledger/client/internal/hooks" + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/retry" + "net/http" + "time" +) + +// ServerList contains the list of servers available to the SDK +var ServerList = []string{ + "http://localhost:8080/", +} + +// HTTPClient provides an interface for suplying the SDK with a custom HTTP client +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +// String provides a helper function to return a pointer to a string +func String(s string) *string { return &s } + +// Bool provides a helper function to return a pointer to a bool +func Bool(b bool) *bool { return &b } + +// Int provides a helper function to return a pointer to an int +func Int(i int) *int { return &i } + +// Int64 provides a helper function to return a pointer to an int64 +func Int64(i int64) *int64 { return &i } + +// Float32 provides a helper function to return a pointer to a float32 +func Float32(f float32) *float32 { return &f } + +// Float64 provides a helper function to return a pointer to a float64 +func Float64(f float64) *float64 { return &f } + +type sdkConfiguration struct { + Client HTTPClient + + ServerURL string + ServerIndex int + Language string + OpenAPIDocVersion string + SDKVersion string + GenVersion string + UserAgent string + RetryConfig *retry.Config + Hooks *hooks.Hooks + Timeout *time.Duration +} + +func (c *sdkConfiguration) GetServerDetails() (string, map[string]string) { + if c.ServerURL != "" { + return c.ServerURL, nil + } + + return ServerList[c.ServerIndex], nil +} + +type Formance struct { + Ledger *Ledger + + sdkConfiguration sdkConfiguration +} + +type SDKOption func(*Formance) + +// WithServerURL allows the overriding of the default server URL +func WithServerURL(serverURL string) SDKOption { + return func(sdk *Formance) { + sdk.sdkConfiguration.ServerURL = serverURL + } +} + +// WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters +func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption { + return func(sdk *Formance) { + if params != nil { + serverURL = utils.ReplaceParameters(serverURL, params) + } + + sdk.sdkConfiguration.ServerURL = serverURL + } +} + +// WithServerIndex allows the overriding of the default server by index +func WithServerIndex(serverIndex int) SDKOption { + return func(sdk *Formance) { + if serverIndex < 0 || serverIndex >= len(ServerList) { + panic(fmt.Errorf("server index %d out of range", serverIndex)) + } + + sdk.sdkConfiguration.ServerIndex = serverIndex + } +} + +// WithClient allows the overriding of the default HTTP client used by the SDK +func WithClient(client HTTPClient) SDKOption { + return func(sdk *Formance) { + sdk.sdkConfiguration.Client = client + } +} + +func WithRetryConfig(retryConfig retry.Config) SDKOption { + return func(sdk *Formance) { + sdk.sdkConfiguration.RetryConfig = &retryConfig + } +} + +// WithTimeout Optional request timeout applied to each operation +func WithTimeout(timeout time.Duration) SDKOption { + return func(sdk *Formance) { + sdk.sdkConfiguration.Timeout = &timeout + } +} + +// New creates a new instance of the SDK with the provided options +func New(opts ...SDKOption) *Formance { + sdk := &Formance{ + sdkConfiguration: sdkConfiguration{ + Language: "go", + OpenAPIDocVersion: "LEDGER_VERSION", + SDKVersion: "0.2.0", + GenVersion: "2.379.3", + UserAgent: "speakeasy-sdk/go 0.2.0 2.379.3 LEDGER_VERSION github.com/formancehq/stack/ledger/client", + Hooks: hooks.New(), + }, + } + for _, opt := range opts { + opt(sdk) + } + + // Use WithClient to override the default client if you would like to customize the timeout + if sdk.sdkConfiguration.Client == nil { + sdk.sdkConfiguration.Client = &http.Client{Timeout: 60 * time.Second} + } + + currentServerURL, _ := sdk.sdkConfiguration.GetServerDetails() + serverURL := currentServerURL + serverURL, sdk.sdkConfiguration.Client = sdk.sdkConfiguration.Hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.Client) + if serverURL != currentServerURL { + sdk.sdkConfiguration.ServerURL = serverURL + } + + sdk.Ledger = newLedger(sdk.sdkConfiguration) + + return sdk +} diff --git a/components/ledger/pkg/client/go.mod b/components/ledger/pkg/client/go.mod new file mode 100644 index 0000000000..4aac575123 --- /dev/null +++ b/components/ledger/pkg/client/go.mod @@ -0,0 +1,10 @@ + +module github.com/formancehq/stack/ledger/client + +go 1.20 + +require ( + github.com/cenkalti/backoff/v4 v4.2.0 + github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 + github.com/spyzhov/ajson v0.8.0 +) diff --git a/components/ledger/pkg/client/go.sum b/components/ledger/pkg/client/go.sum new file mode 100644 index 0000000000..0fee03f70d --- /dev/null +++ b/components/ledger/pkg/client/go.sum @@ -0,0 +1,3 @@ +github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= +github.com/spyzhov/ajson v0.8.0/go.mod h1:63V+CGM6f1Bu/p4nLIN8885ojBdt88TbLoSFzyqMuVA= diff --git a/components/ledger/pkg/client/internal/hooks/hooks.go b/components/ledger/pkg/client/internal/hooks/hooks.go new file mode 100644 index 0000000000..b978f6beff --- /dev/null +++ b/components/ledger/pkg/client/internal/hooks/hooks.go @@ -0,0 +1,144 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package hooks + +import ( + "context" + "errors" + "net/http" +) + +type FailEarly struct { + Cause error +} + +var _ error = (*FailEarly)(nil) + +func (f *FailEarly) Error() string { + return f.Cause.Error() +} + +// HTTPClient provides an interface for supplying the SDK with a custom HTTP client +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +type HookContext struct { + Context context.Context + OperationID string + OAuth2Scopes []string + SecuritySource func(context.Context) (interface{}, error) +} + +type BeforeRequestContext struct { + HookContext +} + +type AfterSuccessContext struct { + HookContext +} + +type AfterErrorContext struct { + HookContext +} + +// sdkInitHook is called when the SDK is initializing. The hook can modify and return a new baseURL and HTTP client to be used by the SDK. +type sdkInitHook interface { + SDKInit(baseURL string, client HTTPClient) (string, HTTPClient) +} + +// beforeRequestHook is called before the SDK sends a request. The hook can modify the request before it is sent or return an error to stop the request from being sent. +type beforeRequestHook interface { + BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error) +} + +// afterSuccessHook is called after the SDK receives a response. The hook can modify the response before it is handled or return an error to stop the response from being handled. +type afterSuccessHook interface { + AfterSuccess(hookCtx AfterSuccessContext, res *http.Response) (*http.Response, error) +} + +// afterErrorHook is called after the SDK encounters an error, or a non-successful response. The hook can modify the response if available otherwise modify the error. +// All afterErrorHook hooks are called and returning an error won't stop the other hooks from being called. But if you want to stop the other hooks from being called, you can return a FailEarly error wrapping your error. +type afterErrorHook interface { + AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error) +} + +type Hooks struct { + sdkInitHooks []sdkInitHook + beforeRequestHook []beforeRequestHook + afterSuccessHook []afterSuccessHook + afterErrorHook []afterErrorHook +} + +func New() *Hooks { + h := &Hooks{ + sdkInitHooks: []sdkInitHook{}, + beforeRequestHook: []beforeRequestHook{}, + afterSuccessHook: []afterSuccessHook{}, + afterErrorHook: []afterErrorHook{}, + } + + initHooks(h) + + return h +} + +// registerSDKInitHook registers a hook to be used by the SDK for the initialization event. +func (h *Hooks) registerSDKInitHook(hook sdkInitHook) { + h.sdkInitHooks = append(h.sdkInitHooks, hook) +} + +// registerBeforeRequestHook registers a hook to be used by the SDK for the before request event. +func (h *Hooks) registerBeforeRequestHook(hook beforeRequestHook) { + h.beforeRequestHook = append(h.beforeRequestHook, hook) +} + +// registerAfterSuccessHook registers a hook to be used by the SDK for the after success event. +func (h *Hooks) registerAfterSuccessHook(hook afterSuccessHook) { + h.afterSuccessHook = append(h.afterSuccessHook, hook) +} + +// registerAfterErrorHook registers a hook to be used by the SDK for the after error event. +func (h *Hooks) registerAfterErrorHook(hook afterErrorHook) { + h.afterErrorHook = append(h.afterErrorHook, hook) +} + +func (h *Hooks) SDKInit(baseURL string, client HTTPClient) (string, HTTPClient) { + for _, hook := range h.sdkInitHooks { + baseURL, client = hook.SDKInit(baseURL, client) + } + return baseURL, client +} + +func (h *Hooks) BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error) { + for _, hook := range h.beforeRequestHook { + var err error + req, err = hook.BeforeRequest(hookCtx, req) + if err != nil { + return req, err + } + } + return req, nil +} + +func (h *Hooks) AfterSuccess(hookCtx AfterSuccessContext, res *http.Response) (*http.Response, error) { + for _, hook := range h.afterSuccessHook { + var err error + res, err = hook.AfterSuccess(hookCtx, res) + if err != nil { + return res, err + } + } + return res, nil +} + +func (h *Hooks) AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error) { + for _, hook := range h.afterErrorHook { + res, err = hook.AfterError(hookCtx, res, err) + var fe *FailEarly + if errors.As(err, &fe) { + return nil, fe.Cause + } + } + return res, err +} diff --git a/components/ledger/pkg/client/internal/hooks/registration.go b/components/ledger/pkg/client/internal/hooks/registration.go new file mode 100644 index 0000000000..fa131be812 --- /dev/null +++ b/components/ledger/pkg/client/internal/hooks/registration.go @@ -0,0 +1,18 @@ +package hooks + +/* + * This file is only ever generated once on the first generation and then is free to be modified. + * Any hooks you wish to add should be registered in the initHooks function. Feel free to define + * your hooks in this file or in separate files in the hooks package. + * + * Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance. + */ + +func initHooks(h *Hooks) { + // exampleHook := &ExampleHook{} + + // h.registerSDKInitHook(exampleHook) + // h.registerBeforeRequestHook(exampleHook) + // h.registerAfterErrorHook(exampleHook) + // h.registerAfterSuccessHook(exampleHook) +} diff --git a/components/ledger/pkg/client/internal/utils/contenttype.go b/components/ledger/pkg/client/internal/utils/contenttype.go new file mode 100644 index 0000000000..81e669d66f --- /dev/null +++ b/components/ledger/pkg/client/internal/utils/contenttype.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package utils + +import ( + "fmt" + "mime" + "strings" +) + +func MatchContentType(contentType string, pattern string) bool { + if contentType == "" { + contentType = "application/octet-stream" + } + + if contentType == pattern || pattern == "*" || pattern == "*/*" { + return true + } + + mediaType, _, err := mime.ParseMediaType(contentType) + if err != nil { + return false + } + + if mediaType == pattern { + return true + } + + parts := strings.Split(mediaType, "/") + if len(parts) == 2 { + if fmt.Sprintf("%s/*", parts[0]) == pattern || fmt.Sprintf("*/%s", parts[1]) == pattern { + return true + } + } + + return false +} diff --git a/components/ledger/pkg/client/internal/utils/form.go b/components/ledger/pkg/client/internal/utils/form.go new file mode 100644 index 0000000000..9768ee81b8 --- /dev/null +++ b/components/ledger/pkg/client/internal/utils/form.go @@ -0,0 +1,117 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package utils + +import ( + "fmt" + "math/big" + "net/url" + "reflect" + "strings" + "time" + + "github.com/ericlagergren/decimal" + + "github.com/formancehq/stack/ledger/client/types" +) + +func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, getFieldName func(reflect.StructField) string) url.Values { + + formValues := url.Values{} + + if isNil(objType, objValue) { + return formValues + } + + if objType.Kind() == reflect.Pointer { + objType = objType.Elem() + objValue = objValue.Elem() + } + + switch objType.Kind() { + case reflect.Struct: + switch objValue.Interface().(type) { + case time.Time: + formValues.Add(paramName, valToString(objValue.Interface())) + case types.Date: + formValues.Add(paramName, valToString(objValue.Interface())) + case big.Int: + formValues.Add(paramName, valToString(objValue.Interface())) + case decimal.Big: + formValues.Add(paramName, valToString(objValue.Interface())) + default: + var items []string + + for i := 0; i < objType.NumField(); i++ { + fieldType := objType.Field(i) + valType := objValue.Field(i) + + if isNil(fieldType.Type, valType) { + continue + } + + if valType.Kind() == reflect.Pointer { + valType = valType.Elem() + } + + fieldName := getFieldName(fieldType) + if fieldName == "" { + continue + } + + if explode { + formValues.Add(fieldName, valToString(valType.Interface())) + } else { + items = append(items, fmt.Sprintf("%s%s%s", fieldName, delimiter, valToString(valType.Interface()))) + } + } + + if len(items) > 0 { + formValues.Add(paramName, strings.Join(items, delimiter)) + } + } + case reflect.Map: + items := []string{} + + iter := objValue.MapRange() + for iter.Next() { + if explode { + formValues.Add(iter.Key().String(), valToString(iter.Value().Interface())) + } else { + items = append(items, fmt.Sprintf("%s%s%s", iter.Key().String(), delimiter, valToString(iter.Value().Interface()))) + } + } + + if len(items) > 0 { + formValues.Add(paramName, strings.Join(items, delimiter)) + } + case reflect.Slice, reflect.Array: + values := parseDelimitedArray(explode, objValue, delimiter) + for _, v := range values { + formValues.Add(paramName, v) + } + default: + formValues.Add(paramName, valToString(objValue.Interface())) + } + + return formValues +} + +func parseDelimitedArray(explode bool, objValue reflect.Value, delimiter string) []string { + values := []string{} + items := []string{} + + for i := 0; i < objValue.Len(); i++ { + if explode { + values = append(values, valToString(objValue.Index(i).Interface())) + } else { + items = append(items, valToString(objValue.Index(i).Interface())) + } + } + + if len(items) > 0 { + values = append(values, strings.Join(items, delimiter)) + } + + return values +} diff --git a/components/ledger/pkg/client/internal/utils/headers.go b/components/ledger/pkg/client/internal/utils/headers.go new file mode 100644 index 0000000000..7af15f9aa5 --- /dev/null +++ b/components/ledger/pkg/client/internal/utils/headers.go @@ -0,0 +1,124 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package utils + +import ( + "context" + "fmt" + "net/http" + "reflect" + "strings" +) + +func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{}) { + globalsAlreadyPopulated := populateHeaders(headers, globals, req.Header, []string{}) + if globals != nil { + _ = populateHeaders(globals, nil, req.Header, globalsAlreadyPopulated) + } +} + +func populateHeaders(headers interface{}, globals interface{}, reqHeaders http.Header, skipFields []string) []string { + headerParamsStructType, headerParamsValType := dereferencePointers(reflect.TypeOf(headers), reflect.ValueOf(headers)) + + globalsAlreadyPopulated := []string{} + + for i := 0; i < headerParamsStructType.NumField(); i++ { + fieldType := headerParamsStructType.Field(i) + valType := headerParamsValType.Field(i) + + if contains(skipFields, fieldType.Name) { + continue + } + + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, headerParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } + + tag := parseParamTag(headerParamTagKey, fieldType, "simple", false) + if tag == nil { + continue + } + + value := serializeHeader(fieldType.Type, valType, tag.Explode) + if value != "" { + reqHeaders.Add(tag.ParamName, value) + } + } + + return globalsAlreadyPopulated +} + +func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string { + if isNil(objType, objValue) { + return "" + } + + if objType.Kind() == reflect.Pointer { + objType = objType.Elem() + objValue = objValue.Elem() + } + + switch objType.Kind() { + case reflect.Struct: + items := []string{} + + for i := 0; i < objType.NumField(); i++ { + fieldType := objType.Field(i) + valType := objValue.Field(i) + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Pointer { + valType = valType.Elem() + } + + tag := parseParamTag(headerParamTagKey, fieldType, "simple", false) + if tag == nil { + continue + } + + fieldName := tag.ParamName + + if fieldName == "" { + continue + } + + if explode { + items = append(items, fmt.Sprintf("%s=%s", fieldName, valToString(valType.Interface()))) + } else { + items = append(items, fieldName, valToString(valType.Interface())) + } + } + + return strings.Join(items, ",") + case reflect.Map: + items := []string{} + + iter := objValue.MapRange() + for iter.Next() { + if explode { + items = append(items, fmt.Sprintf("%s=%s", iter.Key().String(), valToString(iter.Value().Interface()))) + } else { + items = append(items, iter.Key().String(), valToString(iter.Value().Interface())) + } + } + + return strings.Join(items, ",") + case reflect.Slice, reflect.Array: + items := []string{} + + for i := 0; i < objValue.Len(); i++ { + items = append(items, valToString(objValue.Index(i).Interface())) + } + + return strings.Join(items, ",") + default: + return valToString(objValue.Interface()) + } +} diff --git a/components/ledger/pkg/client/internal/utils/json.go b/components/ledger/pkg/client/internal/utils/json.go new file mode 100644 index 0000000000..a0aec02f5d --- /dev/null +++ b/components/ledger/pkg/client/internal/utils/json.go @@ -0,0 +1,670 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package utils + +import ( + "bytes" + "encoding/json" + "fmt" + "math/big" + "reflect" + "strconv" + "strings" + "time" + "unsafe" + + "github.com/formancehq/stack/ledger/client/types" + + "github.com/ericlagergren/decimal" +) + +func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, error) { + typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v)) + + switch { + case isModelType(typ): + if topLevel { + return json.Marshal(v) + } + + if isNil(typ, val) { + return []byte("null"), nil + } + + out := map[string]json.RawMessage{} + + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + fieldVal := val.Field(i) + + fieldName := field.Name + + omitEmpty := false + jsonTag := field.Tag.Get("json") + if jsonTag != "" { + for _, tag := range strings.Split(jsonTag, ",") { + if tag == "omitempty" { + omitEmpty = true + } else { + fieldName = tag + } + } + } + + if isNil(field.Type, fieldVal) && field.Tag.Get("const") == "" { + if omitEmpty { + continue + } + } + + if !field.IsExported() && field.Tag.Get("const") == "" { + continue + } + + additionalProperties := field.Tag.Get("additionalProperties") + if fieldName == "-" && additionalProperties == "" { + continue + } + + if additionalProperties == "true" { + if isNil(field.Type, fieldVal) { + continue + } + fieldVal := trueReflectValue(fieldVal) + if fieldVal.Type().Kind() != reflect.Map { + return nil, fmt.Errorf("additionalProperties must be a map") + } + + for _, key := range fieldVal.MapKeys() { + r, err := marshalValue(fieldVal.MapIndex(key).Interface(), field.Tag) + if err != nil { + return nil, err + } + + out[key.String()] = r + } + + continue + } + + var fv interface{} + + if field.IsExported() { + fv = fieldVal.Interface() + } else { + pt := reflect.New(typ).Elem() + pt.Set(val) + + pf := pt.Field(i) + + fv = reflect.NewAt(pf.Type(), unsafe.Pointer(pf.UnsafeAddr())).Elem().Interface() + } + + r, err := marshalValue(fv, field.Tag) + if err != nil { + return nil, err + } + + out[fieldName] = r + } + + return json.Marshal(out) + default: + return marshalValue(v, tag) + } +} + +func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool, disallowUnknownFields bool) error { + if reflect.TypeOf(v).Kind() != reflect.Ptr { + return fmt.Errorf("v must be a pointer") + } + + typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v)) + + switch { + case isModelType(typ): + if topLevel || bytes.Equal(b, []byte("null")) { + d := json.NewDecoder(bytes.NewReader(b)) + if disallowUnknownFields { + d.DisallowUnknownFields() + } + return d.Decode(v) + } + + var unmarhsaled map[string]json.RawMessage + + if err := json.Unmarshal(b, &unmarhsaled); err != nil { + return err + } + + var additionalPropertiesField *reflect.StructField + var additionalPropertiesValue *reflect.Value + + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + fieldVal := val.Field(i) + + fieldName := field.Name + + jsonTag := field.Tag.Get("json") + if jsonTag != "" { + for _, tag := range strings.Split(jsonTag, ",") { + if tag != "omitempty" { + fieldName = tag + } + } + } + + if field.Tag.Get("additionalProperties") == "true" { + additionalPropertiesField = &field + additionalPropertiesValue = &fieldVal + continue + } + + // If we receive a value for a const field ignore it but mark it as unmarshaled + if field.Tag.Get("const") != "" { + if r, ok := unmarhsaled[fieldName]; ok { + val := string(r) + if strings.HasPrefix(val, `"`) && strings.HasSuffix(val, `"`) { + val = val[1 : len(val)-1] + } + if val != field.Tag.Get("const") { + return fmt.Errorf("const field %s does not match expected value %s", fieldName, field.Tag.Get("const")) + } + + delete(unmarhsaled, fieldName) + } + } else if !field.IsExported() { + continue + } + + value, ok := unmarhsaled[fieldName] + if !ok { + defaultTag := field.Tag.Get("default") + if defaultTag != "" { + value = handleDefaultConstValue(defaultTag, fieldVal.Interface(), field.Tag) + ok = true + } + } else { + delete(unmarhsaled, fieldName) + } + + if ok { + if err := unmarshalValue(value, fieldVal, field.Tag, disallowUnknownFields); err != nil { + return err + } + } + } + + keys := make([]string, 0, len(unmarhsaled)) + for k := range unmarhsaled { + keys = append(keys, k) + } + + if len(keys) > 0 { + if disallowUnknownFields && (additionalPropertiesField == nil || additionalPropertiesValue == nil) { + return fmt.Errorf("unknown fields: %v", keys) + } + + if additionalPropertiesField != nil && additionalPropertiesValue != nil { + typeOfMap := additionalPropertiesField.Type + if additionalPropertiesValue.Type().Kind() == reflect.Interface { + typeOfMap = reflect.TypeOf(map[string]interface{}{}) + } else if additionalPropertiesValue.Type().Kind() != reflect.Map { + return fmt.Errorf("additionalProperties must be a map") + } + + mapValue := reflect.MakeMap(typeOfMap) + + for key, value := range unmarhsaled { + val := reflect.New(typeOfMap.Elem()) + + if err := unmarshalValue(value, val, additionalPropertiesField.Tag, disallowUnknownFields); err != nil { + return err + } + + if val.Elem().Type().String() == typeOfMap.Elem().String() { + mapValue.SetMapIndex(reflect.ValueOf(key), val.Elem()) + } else { + mapValue.SetMapIndex(reflect.ValueOf(key), trueReflectValue(val)) + } + + } + if additionalPropertiesValue.Type().Kind() == reflect.Interface { + additionalPropertiesValue.Set(mapValue) + } else { + additionalPropertiesValue.Set(mapValue) + } + } + } + default: + return unmarshalValue(b, reflect.ValueOf(v), tag, disallowUnknownFields) + } + + return nil +} + +func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error) { + constTag := tag.Get("const") + if constTag != "" { + return handleDefaultConstValue(constTag, v, tag), nil + } + + if isNil(reflect.TypeOf(v), reflect.ValueOf(v)) { + defaultTag := tag.Get("default") + if defaultTag != "" { + return handleDefaultConstValue(defaultTag, v, tag), nil + } + + return []byte("null"), nil + } + + typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v)) + switch typ.Kind() { + case reflect.Int64: + format := tag.Get("integer") + if format == "string" { + b := val.Interface().(int64) + return []byte(fmt.Sprintf(`"%d"`, b)), nil + } + case reflect.Float64: + format := tag.Get("number") + if format == "string" { + b := val.Interface().(float64) + return []byte(fmt.Sprintf(`"%g"`, b)), nil + } + case reflect.Map: + if isNil(typ, val) { + return []byte("null"), nil + } + + out := map[string]json.RawMessage{} + + for _, key := range val.MapKeys() { + itemVal := val.MapIndex(key) + + if isNil(itemVal.Type(), itemVal) { + out[key.String()] = []byte("null") + continue + } + + r, err := marshalValue(itemVal.Interface(), tag) + if err != nil { + return nil, err + } + + out[key.String()] = r + } + + return json.Marshal(out) + case reflect.Slice, reflect.Array: + if isNil(typ, val) { + return []byte("null"), nil + } + + out := []json.RawMessage{} + + for i := 0; i < val.Len(); i++ { + itemVal := val.Index(i) + + if isNil(itemVal.Type(), itemVal) { + out = append(out, []byte("null")) + continue + } + + r, err := marshalValue(itemVal.Interface(), tag) + if err != nil { + return nil, err + } + + out = append(out, r) + } + + return json.Marshal(out) + case reflect.Struct: + switch typ { + case reflect.TypeOf(time.Time{}): + return []byte(fmt.Sprintf(`"%s"`, val.Interface().(time.Time).Format(time.RFC3339Nano))), nil + case reflect.TypeOf(big.Int{}): + format := tag.Get("bigint") + if format == "string" { + b := val.Interface().(big.Int) + return []byte(fmt.Sprintf(`"%s"`, (&b).String())), nil + } + case reflect.TypeOf(decimal.Big{}): + format := tag.Get("decimal") + if format == "number" { + b := val.Interface().(decimal.Big) + f, ok := (&b).Float64() + if ok { + return []byte(b.String()), nil + } + + return []byte(fmt.Sprintf(`%f`, f)), nil + } + } + } + + return json.Marshal(v) +} + +func handleDefaultConstValue(tagValue string, val interface{}, tag reflect.StructTag) json.RawMessage { + if tagValue == "null" { + return []byte("null") + } + + typ := dereferenceTypePointer(reflect.TypeOf(val)) + switch typ { + case reflect.TypeOf(time.Time{}): + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + case reflect.TypeOf(big.Int{}): + bigIntTag := tag.Get("bigint") + if bigIntTag == "string" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(int64(0)): + format := tag.Get("integer") + if format == "string" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(float64(0)): + format := tag.Get("number") + if format == "string" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(decimal.Big{}): + decimalTag := tag.Get("decimal") + if decimalTag != "number" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(types.Date{}): + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + default: + if typ.Kind() == reflect.String { + return []byte(fmt.Sprintf("%q", tagValue)) + } + } + + return []byte(tagValue) +} + +func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTag, disallowUnknownFields bool) error { + if bytes.Equal(value, []byte("null")) { + if v.CanAddr() { + return json.Unmarshal(value, v.Addr().Interface()) + } else { + return json.Unmarshal(value, v.Interface()) + } + } + + typ := dereferenceTypePointer(v.Type()) + + switch typ.Kind() { + case reflect.Int64: + var b int64 + + format := tag.Get("integer") + if format == "string" { + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + var err error + b, err = strconv.ParseInt(s, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse string as int64: %w", err) + } + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(b)) + return nil + } + case reflect.Float64: + var b float64 + + format := tag.Get("number") + if format == "string" { + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + var err error + b, err = strconv.ParseFloat(s, 64) + if err != nil { + return fmt.Errorf("failed to parse string as float64: %w", err) + } + + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(b)) + return nil + } + case reflect.Map: + if bytes.Equal(value, []byte("null")) || !isComplexValueType(dereferenceTypePointer(typ.Elem())) { + if v.CanAddr() { + return json.Unmarshal(value, v.Addr().Interface()) + } else { + return json.Unmarshal(value, v.Interface()) + } + } + + var unmarhsaled map[string]json.RawMessage + + if err := json.Unmarshal(value, &unmarhsaled); err != nil { + return err + } + + m := reflect.MakeMap(typ) + + for k, value := range unmarhsaled { + itemVal := reflect.New(typ.Elem()) + + if err := unmarshalValue(value, itemVal, tag, disallowUnknownFields); err != nil { + return err + } + + m.SetMapIndex(reflect.ValueOf(k), itemVal.Elem()) + } + + v.Set(m) + return nil + case reflect.Slice, reflect.Array: + if bytes.Equal(value, []byte("null")) || !isComplexValueType(dereferenceTypePointer(typ.Elem())) { + if v.CanAddr() { + return json.Unmarshal(value, v.Addr().Interface()) + } else { + return json.Unmarshal(value, v.Interface()) + } + } + + var unmarhsaled []json.RawMessage + + if err := json.Unmarshal(value, &unmarhsaled); err != nil { + return err + } + + arrVal := v + + for _, value := range unmarhsaled { + itemVal := reflect.New(typ.Elem()) + + if err := unmarshalValue(value, itemVal, tag, disallowUnknownFields); err != nil { + return err + } + + arrVal = reflect.Append(arrVal, itemVal.Elem()) + } + + v.Set(arrVal) + return nil + case reflect.Struct: + switch typ { + case reflect.TypeOf(time.Time{}): + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + t, err := time.Parse(time.RFC3339Nano, s) + if err != nil { + return fmt.Errorf("failed to parse string as time.Time: %w", err) + } + + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(t)) + return nil + case reflect.TypeOf(big.Int{}): + var b *big.Int + + format := tag.Get("bigint") + if format == "string" { + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + var ok bool + b, ok = new(big.Int).SetString(s, 10) + if !ok { + return fmt.Errorf("failed to parse string as big.Int") + } + } else { + if err := json.Unmarshal(value, &b); err != nil { + return err + } + } + + if v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Ptr { + v = v.Elem() + } + + v.Set(reflect.ValueOf(b)) + return nil + case reflect.TypeOf(decimal.Big{}): + var d *decimal.Big + format := tag.Get("decimal") + if format == "number" { + var ok bool + d, ok = new(decimal.Big).SetString(string(value)) + if !ok { + return fmt.Errorf("failed to parse number as decimal.Big") + } + } else { + if err := json.Unmarshal(value, &d); err != nil { + return err + } + } + + if v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Ptr { + v = v.Elem() + } + + v.Set(reflect.ValueOf(d)) + return nil + case reflect.TypeOf(types.Date{}): + var s string + + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + d, err := types.DateFromString(s) + if err != nil { + return fmt.Errorf("failed to parse string as types.Date: %w", err) + } + + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(d)) + return nil + } + } + + var val interface{} + + if v.CanAddr() { + val = v.Addr().Interface() + } else { + val = v.Interface() + } + + d := json.NewDecoder(bytes.NewReader(value)) + if disallowUnknownFields { + d.DisallowUnknownFields() + } + return d.Decode(val) +} + +func dereferencePointers(typ reflect.Type, val reflect.Value) (reflect.Type, reflect.Value) { + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + val = val.Elem() + } else { + return typ, val + } + + return dereferencePointers(typ, val) +} + +func dereferenceTypePointer(typ reflect.Type) reflect.Type { + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + } else { + return typ + } + + return dereferenceTypePointer(typ) +} + +func isComplexValueType(typ reflect.Type) bool { + switch typ.Kind() { + case reflect.Struct: + switch typ { + case reflect.TypeOf(time.Time{}): + fallthrough + case reflect.TypeOf(big.Int{}): + fallthrough + case reflect.TypeOf(decimal.Big{}): + fallthrough + case reflect.TypeOf(types.Date{}): + return true + } + } + + return false +} + +func isModelType(typ reflect.Type) bool { + if isComplexValueType(typ) { + return false + } + + if typ.Kind() == reflect.Struct { + return true + } + + return false +} diff --git a/components/ledger/pkg/client/internal/utils/pathparams.go b/components/ledger/pkg/client/internal/utils/pathparams.go new file mode 100644 index 0000000000..58aabb0411 --- /dev/null +++ b/components/ledger/pkg/client/internal/utils/pathparams.go @@ -0,0 +1,172 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package utils + +import ( + "context" + "fmt" + "math/big" + "net/url" + "reflect" + "strings" + "time" + + "github.com/ericlagergren/decimal" + + "github.com/formancehq/stack/ledger/client/types" +) + +func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error) { + uri := strings.TrimSuffix(serverURL, "/") + path + + parsedParameters := map[string]string{} + + globalsAlreadyPopulated, err := populateParsedParameters(pathParams, globals, parsedParameters, []string{}) + if err != nil { + return "", err + } + + if globals != nil { + _, err = populateParsedParameters(globals, nil, parsedParameters, globalsAlreadyPopulated) + if err != nil { + return "", err + } + } + + // TODO should we handle the case where there are no matching path params? + return ReplaceParameters(uri, parsedParameters), nil +} + +func populateParsedParameters(pathParams interface{}, globals interface{}, parsedParameters map[string]string, skipFields []string) ([]string, error) { + pathParamsStructType, pathParamsValType := dereferencePointers(reflect.TypeOf(pathParams), reflect.ValueOf(pathParams)) + + globalsAlreadyPopulated := []string{} + + for i := 0; i < pathParamsStructType.NumField(); i++ { + fieldType := pathParamsStructType.Field(i) + valType := pathParamsValType.Field(i) + + if contains(skipFields, fieldType.Name) { + continue + } + + requestTag := getRequestTag(fieldType) + if requestTag != nil { + continue + } + + ppTag := parseParamTag(pathParamTagKey, fieldType, "simple", false) + if ppTag == nil { + continue + } + + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, pathParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } + + if ppTag.Serialization != "" { + vals, err := populateSerializedParams(ppTag, fieldType.Type, valType) + if err != nil { + return nil, err + } + for k, v := range vals { + parsedParameters[k] = url.PathEscape(v) + } + } else { + // TODO: support other styles + switch ppTag.Style { + case "simple": + simpleParams := getSimplePathParams(ppTag.ParamName, fieldType.Type, valType, ppTag.Explode) + for k, v := range simpleParams { + parsedParameters[k] = v + } + } + } + } + + return globalsAlreadyPopulated, nil +} + +func getSimplePathParams(parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string { + pathParams := make(map[string]string) + + if isNil(objType, objValue) { + return nil + } + + if objType.Kind() == reflect.Ptr { + objType = objType.Elem() + objValue = objValue.Elem() + } + + switch objType.Kind() { + case reflect.Array, reflect.Slice: + if objValue.Len() == 0 { + return nil + } + var ppVals []string + for i := 0; i < objValue.Len(); i++ { + ppVals = append(ppVals, valToString(objValue.Index(i).Interface())) + } + pathParams[parentName] = strings.Join(ppVals, ",") + case reflect.Map: + if objValue.Len() == 0 { + return nil + } + var ppVals []string + objMap := objValue.MapRange() + for objMap.Next() { + if explode { + ppVals = append(ppVals, fmt.Sprintf("%s=%s", objMap.Key().String(), valToString(objMap.Value().Interface()))) + } else { + ppVals = append(ppVals, fmt.Sprintf("%s,%s", objMap.Key().String(), valToString(objMap.Value().Interface()))) + } + } + pathParams[parentName] = strings.Join(ppVals, ",") + case reflect.Struct: + switch objValue.Interface().(type) { + case time.Time: + pathParams[parentName] = valToString(objValue.Interface()) + case types.Date: + pathParams[parentName] = valToString(objValue.Interface()) + case big.Int: + pathParams[parentName] = valToString(objValue.Interface()) + case decimal.Big: + pathParams[parentName] = valToString(objValue.Interface()) + default: + var ppVals []string + for i := 0; i < objType.NumField(); i++ { + fieldType := objType.Field(i) + valType := objValue.Field(i) + + ppTag := parseParamTag(pathParamTagKey, fieldType, "simple", explode) + if ppTag == nil { + continue + } + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Pointer { + valType = valType.Elem() + } + + if explode { + ppVals = append(ppVals, fmt.Sprintf("%s=%s", ppTag.ParamName, valToString(valType.Interface()))) + } else { + ppVals = append(ppVals, fmt.Sprintf("%s,%s", ppTag.ParamName, valToString(valType.Interface()))) + } + } + pathParams[parentName] = strings.Join(ppVals, ",") + } + default: + pathParams[parentName] = valToString(objValue.Interface()) + } + + return pathParams +} diff --git a/components/ledger/pkg/client/internal/utils/queryparams.go b/components/ledger/pkg/client/internal/utils/queryparams.go new file mode 100644 index 0000000000..4e6ed35732 --- /dev/null +++ b/components/ledger/pkg/client/internal/utils/queryparams.go @@ -0,0 +1,259 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package utils + +import ( + "context" + "encoding/json" + "fmt" + "math/big" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/ericlagergren/decimal" + + "github.com/formancehq/stack/ledger/client/types" +) + +func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error { + // Query parameters may already be present from overriding URL + if req.URL.RawQuery != "" { + return nil + } + + values := url.Values{} + + globalsAlreadyPopulated, err := populateQueryParams(queryParams, globals, values, []string{}) + if err != nil { + return err + } + + if globals != nil { + _, err = populateQueryParams(globals, nil, values, globalsAlreadyPopulated) + if err != nil { + return err + } + } + + req.URL.RawQuery = values.Encode() + + return nil +} + +func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) { + queryParamsStructType, queryParamsValType := dereferencePointers(reflect.TypeOf(queryParams), reflect.ValueOf(queryParams)) + + globalsAlreadyPopulated := []string{} + + for i := 0; i < queryParamsStructType.NumField(); i++ { + fieldType := queryParamsStructType.Field(i) + valType := queryParamsValType.Field(i) + + if contains(skipFields, fieldType.Name) { + continue + } + + requestTag := getRequestTag(fieldType) + if requestTag != nil { + continue + } + + qpTag := parseQueryParamTag(fieldType) + if qpTag == nil { + continue + } + + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } + + if qpTag.Serialization != "" { + vals, err := populateSerializedParams(qpTag, fieldType.Type, valType) + if err != nil { + return nil, err + } + for k, v := range vals { + values.Add(k, v) + } + } else { + switch qpTag.Style { + case "deepObject": + vals := populateDeepObjectParams(qpTag, fieldType.Type, valType) + for k, v := range vals { + for _, vv := range v { + values.Add(k, vv) + } + } + case "form": + vals := populateFormParams(qpTag, fieldType.Type, valType, ",") + for k, v := range vals { + for _, vv := range v { + values.Add(k, vv) + } + } + case "pipeDelimited": + vals := populateFormParams(qpTag, fieldType.Type, valType, "|") + for k, v := range vals { + for _, vv := range v { + values.Add(k, vv) + } + } + default: + return nil, fmt.Errorf("unsupported style: %s", qpTag.Style) + } + } + } + + return globalsAlreadyPopulated, nil +} + +func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) { + if isNil(objType, objValue) { + return nil, nil + } + + if objType.Kind() == reflect.Pointer { + objValue = objValue.Elem() + } + + values := map[string]string{} + + switch tag.Serialization { + case "json": + data, err := json.Marshal(objValue.Interface()) + if err != nil { + return nil, fmt.Errorf("error marshaling json: %v", err) + } + values[tag.ParamName] = string(data) + } + + return values, nil +} + +func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values { + values := url.Values{} + + if isNil(objType, objValue) { + return values + } + + if objValue.Kind() == reflect.Pointer { + objValue = objValue.Elem() + } + + switch objValue.Kind() { + case reflect.Map: + populateDeepObjectParamsMap(values, tag.ParamName, objValue) + case reflect.Struct: + populateDeepObjectParamsStruct(values, tag.ParamName, objValue) + } + + return values +} + +func populateDeepObjectParamsArray(qsValues url.Values, priorScope string, value reflect.Value) { + if value.Kind() != reflect.Array && value.Kind() != reflect.Slice { + return + } + + for i := 0; i < value.Len(); i++ { + qsValues.Add(priorScope, valToString(value.Index(i).Interface())) + } +} + +func populateDeepObjectParamsMap(qsValues url.Values, priorScope string, mapValue reflect.Value) { + if mapValue.Kind() != reflect.Map { + return + } + + iter := mapValue.MapRange() + + for iter.Next() { + scope := priorScope + "[" + iter.Key().String() + "]" + iterValue := iter.Value() + + switch iterValue.Kind() { + case reflect.Array, reflect.Slice: + populateDeepObjectParamsArray(qsValues, scope, iterValue) + case reflect.Map: + populateDeepObjectParamsMap(qsValues, scope, iterValue) + default: + qsValues.Add(scope, valToString(iterValue.Interface())) + } + } +} + +func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, structValue reflect.Value) { + if structValue.Kind() != reflect.Struct { + return + } + + structType := structValue.Type() + + for i := 0; i < structType.NumField(); i++ { + field := structType.Field(i) + fieldValue := structValue.Field(i) + + if isNil(field.Type, fieldValue) { + continue + } + + if fieldValue.Kind() == reflect.Pointer { + fieldValue = fieldValue.Elem() + } + + qpTag := parseQueryParamTag(field) + + if qpTag == nil { + continue + } + + scope := priorScope + "[" + qpTag.ParamName + "]" + + switch fieldValue.Kind() { + case reflect.Array, reflect.Slice: + populateDeepObjectParamsArray(qsValues, scope, fieldValue) + case reflect.Map: + populateDeepObjectParamsMap(qsValues, scope, fieldValue) + case reflect.Struct: + switch fieldValue.Type() { + case reflect.TypeOf(big.Int{}), reflect.TypeOf(decimal.Big{}), reflect.TypeOf(time.Time{}), reflect.TypeOf(types.Date{}): + qsValues.Add(scope, valToString(fieldValue.Interface())) + + continue + } + + populateDeepObjectParamsStruct(qsValues, scope, fieldValue) + default: + qsValues.Add(scope, valToString(fieldValue.Interface())) + } + } +} + +func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values { + return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string { + qpTag := parseQueryParamTag(fieldType) + if qpTag == nil { + return "" + } + + return qpTag.ParamName + }) +} + +type paramTag struct { + Style string + Explode bool + ParamName string + Serialization string +} + +func parseQueryParamTag(field reflect.StructField) *paramTag { + return parseParamTag(queryParamTagKey, field, "form", true) +} diff --git a/components/ledger/pkg/client/internal/utils/requestbody.go b/components/ledger/pkg/client/internal/utils/requestbody.go new file mode 100644 index 0000000000..b4e2b8b390 --- /dev/null +++ b/components/ledger/pkg/client/internal/utils/requestbody.go @@ -0,0 +1,409 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package utils + +import ( + "bytes" + "context" + "fmt" + "io" + "mime/multipart" + "net/url" + "reflect" + "regexp" +) + +const ( + requestTagKey = "request" + multipartFormTagKey = "multipartForm" + formTagKey = "form" +) + +var ( + jsonEncodingRegex = regexp.MustCompile(`(application|text)\/.*?\+*json.*`) + multipartEncodingRegex = regexp.MustCompile(`multipart\/.*`) + urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`) +) + +func SerializeRequestBody(_ context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { + bodyReader, contentType, err := serializeRequestBody(request, nullable, optional, requestFieldName, serializationMethod, tag) + if err != nil { + return nil, "", fmt.Errorf("error serializing request body: %w", err) + } + + if bodyReader == nil && !optional { + return nil, "", fmt.Errorf("request body is required") + } + + return bodyReader, contentType, nil +} + +func serializeRequestBody(request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { + requestStructType := reflect.TypeOf(request) + requestValType := reflect.ValueOf(request) + + if isNil(requestStructType, requestValType) { + if !nullable && optional { + return nil, "", nil + } + + return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], requestValType, tag) + } + + if requestStructType.Kind() == reflect.Pointer { + requestStructType = requestStructType.Elem() + requestValType = requestValType.Elem() + } + + if requestStructType.Kind() != reflect.Struct { + return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], requestValType, tag) + } + + requestField, ok := requestStructType.FieldByName(requestFieldName) + + if ok { + tag := getRequestTag(requestField) + if tag != nil { + // request object (non-flattened) + requestVal := requestValType.FieldByName(requestFieldName) + if isNil(requestField.Type, requestVal) { + if !nullable && optional { + return nil, "", nil + } + + return serializeContentType(requestFieldName, tag.MediaType, requestVal, string(requestField.Tag)) + } + + return serializeContentType(requestFieldName, tag.MediaType, requestVal, string(requestField.Tag)) + } + } + + // flattened request object + return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], reflect.ValueOf(request), tag) +} + +func serializeContentType(fieldName string, mediaType string, val reflect.Value, tag string) (*bytes.Buffer, string, error) { + buf := &bytes.Buffer{} + + if isNil(val.Type(), val) { + // TODO: what does a null mean for other content types? Just returning an empty buffer for now + if jsonEncodingRegex.MatchString(mediaType) { + if _, err := buf.Write([]byte("null")); err != nil { + return nil, "", err + } + } + + return buf, mediaType, nil + } + + switch { + case jsonEncodingRegex.MatchString(mediaType): + data, err := MarshalJSON(val.Interface(), reflect.StructTag(tag), true) + if err != nil { + return nil, "", err + } + + if _, err := buf.Write(data); err != nil { + return nil, "", err + } + case multipartEncodingRegex.MatchString(mediaType): + var err error + mediaType, err = encodeMultipartFormData(buf, val.Interface()) + if err != nil { + return nil, "", err + } + case urlEncodedEncodingRegex.MatchString(mediaType): + if err := encodeFormData(fieldName, buf, val.Interface()); err != nil { + return nil, "", err + } + default: + val = reflect.Indirect(val) + + switch { + case val.Type().Kind() == reflect.String: + if _, err := buf.WriteString(valToString(val.Interface())); err != nil { + return nil, "", err + } + case val.Type() == reflect.TypeOf([]byte(nil)): + if _, err := buf.Write(val.Bytes()); err != nil { + return nil, "", err + } + default: + return nil, "", fmt.Errorf("invalid request body type %s for mediaType %s", val.Type(), mediaType) + } + } + + return buf, mediaType, nil +} + +func encodeMultipartFormData(w io.Writer, data interface{}) (string, error) { + requestStructType := reflect.TypeOf(data) + requestValType := reflect.ValueOf(data) + + if requestStructType.Kind() == reflect.Pointer { + requestStructType = requestStructType.Elem() + requestValType = requestValType.Elem() + } + + writer := multipart.NewWriter(w) + + for i := 0; i < requestStructType.NumField(); i++ { + field := requestStructType.Field(i) + fieldType := field.Type + valType := requestValType.Field(i) + + if isNil(fieldType, valType) { + continue + } + + if fieldType.Kind() == reflect.Pointer { + fieldType = fieldType.Elem() + valType = valType.Elem() + } + + tag := parseMultipartFormTag(field) + if tag.File { + if err := encodeMultipartFormDataFile(writer, fieldType, valType); err != nil { + writer.Close() + return "", err + } + } else if tag.JSON { + jw, err := writer.CreateFormField(tag.Name) + if err != nil { + writer.Close() + return "", err + } + d, err := MarshalJSON(valType.Interface(), field.Tag, true) + if err != nil { + writer.Close() + return "", err + } + if _, err := jw.Write(d); err != nil { + writer.Close() + return "", err + } + } else { + switch fieldType.Kind() { + case reflect.Slice, reflect.Array: + values := parseDelimitedArray(true, valType, ",") + for _, v := range values { + if err := writer.WriteField(tag.Name+"[]", v); err != nil { + writer.Close() + return "", err + } + } + default: + if err := writer.WriteField(tag.Name, valToString(valType.Interface())); err != nil { + writer.Close() + return "", err + } + } + } + } + + if err := writer.Close(); err != nil { + return "", err + } + + return writer.FormDataContentType(), nil +} + +func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, valType reflect.Value) error { + if fieldType.Kind() != reflect.Struct { + return fmt.Errorf("invalid type %s for multipart/form-data file", valType.Type()) + } + + var fieldName string + var fileName string + var content []byte + + for i := 0; i < fieldType.NumField(); i++ { + field := fieldType.Field(i) + val := valType.Field(i) + + tag := parseMultipartFormTag(field) + if !tag.Content && tag.Name == "" { + continue + } + + if tag.Content { + content = val.Bytes() + } else { + fieldName = tag.Name + fileName = val.String() + } + } + + if fieldName == "" || fileName == "" || content == nil { + return fmt.Errorf("invalid multipart/form-data file") + } + + fw, err := w.CreateFormFile(fieldName, fileName) + if err != nil { + return err + } + if _, err := fw.Write(content); err != nil { + return err + } + + return nil +} + +func encodeFormData(fieldName string, w io.Writer, data interface{}) error { + requestType := reflect.TypeOf(data) + requestValType := reflect.ValueOf(data) + + if requestType.Kind() == reflect.Pointer { + requestType = requestType.Elem() + requestValType = requestValType.Elem() + } + + dataValues := url.Values{} + + switch requestType.Kind() { + case reflect.Struct: + for i := 0; i < requestType.NumField(); i++ { + field := requestType.Field(i) + fieldType := field.Type + valType := requestValType.Field(i) + + if isNil(fieldType, valType) { + continue + } + + if fieldType.Kind() == reflect.Pointer { + fieldType = fieldType.Elem() + valType = valType.Elem() + } + + tag := parseFormTag(field) + if tag.JSON { + data, err := MarshalJSON(valType.Interface(), field.Tag, true) + if err != nil { + return err + } + dataValues.Set(tag.Name, string(data)) + } else { + switch tag.Style { + // TODO: support other styles + case "form": + values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", func(sf reflect.StructField) string { + tag := parseFormTag(field) + if tag == nil { + return "" + } + + return tag.Name + }) + for k, v := range values { + for _, vv := range v { + dataValues.Add(k, vv) + } + } + } + } + } + case reflect.Map: + for _, k := range requestValType.MapKeys() { + v := requestValType.MapIndex(k) + dataValues.Set(fmt.Sprintf("%v", k.Interface()), valToString(v.Interface())) + } + case reflect.Slice, reflect.Array: + for i := 0; i < requestValType.Len(); i++ { + v := requestValType.Index(i) + dataValues.Set(fieldName, valToString(v.Interface())) + } + } + + if _, err := w.Write([]byte(dataValues.Encode())); err != nil { + return err + } + + return nil +} + +type requestTag struct { + MediaType string +} + +func getRequestTag(field reflect.StructField) *requestTag { + // example `request:"mediaType=multipart/form-data"` + values := parseStructTag(requestTagKey, field) + if values == nil { + return nil + } + + tag := &requestTag{ + MediaType: "application/octet-stream", + } + + for k, v := range values { + switch k { + case "mediaType": + tag.MediaType = v + } + } + + return tag +} + +type multipartFormTag struct { + File bool + Content bool + JSON bool + Name string +} + +func parseMultipartFormTag(field reflect.StructField) *multipartFormTag { + // example `multipartForm:"name=file"` + values := parseStructTag(multipartFormTagKey, field) + + tag := &multipartFormTag{} + + for k, v := range values { + switch k { + case "file": + tag.File = v == "true" + case "content": + tag.Content = v == "true" + case "name": + tag.Name = v + case "json": + tag.JSON = v == "true" + } + } + + return tag +} + +type formTag struct { + Name string + JSON bool + Style string + Explode bool +} + +func parseFormTag(field reflect.StructField) *formTag { + // example `form:"name=propName,style=spaceDelimited,explode"` + values := parseStructTag(formTagKey, field) + + tag := &formTag{ + Style: "form", + Explode: true, + } + + for k, v := range values { + switch k { + case "name": + tag.Name = v + case "json": + tag.JSON = v == "true" + case "style": + tag.Style = v + case "explode": + tag.Explode = v == "true" + } + } + + return tag +} diff --git a/components/ledger/pkg/client/internal/utils/retries.go b/components/ledger/pkg/client/internal/utils/retries.go new file mode 100644 index 0000000000..06d404088f --- /dev/null +++ b/components/ledger/pkg/client/internal/utils/retries.go @@ -0,0 +1,110 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package utils + +import ( + "context" + "errors" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/formancehq/stack/ledger/client/retry" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +var errRequestFailed = errors.New("request failed") + +// Deprecated: Use retry.BackoffStrategy instead. +type BackoffStrategy = retry.BackoffStrategy + +// Deprecated: Use retry.Config instead. +type RetryConfig = retry.Config + +type Retries struct { + Config *retry.Config + StatusCodes []string +} + +func Retry(ctx context.Context, r Retries, action func() (*http.Response, error)) (*http.Response, error) { + switch r.Config.Strategy { + case "backoff": + if r.Config.Backoff == nil { + return action() + } + + config := backoff.NewExponentialBackOff() + config.InitialInterval = time.Duration(r.Config.Backoff.InitialInterval) * time.Millisecond + config.MaxInterval = time.Duration(r.Config.Backoff.MaxInterval) * time.Millisecond + config.Multiplier = r.Config.Backoff.Exponent + config.MaxElapsedTime = time.Duration(r.Config.Backoff.MaxElapsedTime) * time.Millisecond + config.Reset() + + var resp *http.Response + + err := backoff.Retry(func() error { + if resp != nil { + resp.Body.Close() + } + + select { + case <-ctx.Done(): + return backoff.Permanent(ctx.Err()) + default: + } + + res, err := action() + if err != nil { + urlError := new(url.Error) + if errors.As(err, &urlError) { + if (urlError.Temporary() || urlError.Timeout()) && r.Config.RetryConnectionErrors { + return err + } + } + + return backoff.Permanent(err) + } + resp = res + if res == nil { + return fmt.Errorf("no response") + } + + for _, code := range r.StatusCodes { + if strings.Contains(strings.ToUpper(code), "X") { + codeRange, err := strconv.Atoi(code[:1]) + if err != nil { + continue + } + + s := res.StatusCode / 100 + + if s >= codeRange && s < codeRange+1 { + return errRequestFailed + } + } else { + parsedCode, err := strconv.Atoi(code) + if err != nil { + continue + } + + if res.StatusCode == parsedCode { + return errRequestFailed + } + } + } + + resp = res + + return nil + }, config) + if err != nil && !errors.Is(err, errRequestFailed) { + return nil, err + } + + return resp, nil + default: + return action() + } +} diff --git a/components/ledger/pkg/client/internal/utils/security.go b/components/ledger/pkg/client/internal/utils/security.go new file mode 100644 index 0000000000..ace81f714d --- /dev/null +++ b/components/ledger/pkg/client/internal/utils/security.go @@ -0,0 +1,274 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package utils + +import ( + "context" + "encoding/base64" + "fmt" + "net/http" + "reflect" + "strings" +) + +const ( + securityTagKey = "security" +) + +type securityTag struct { + Option bool + Scheme bool + Name string + Type string + SubType string +} + +func PopulateSecurity(ctx context.Context, req *http.Request, securitySource func(context.Context) (interface{}, error)) error { + if securitySource == nil { + return nil + } + + security, err := securitySource(ctx) + if err != nil { + return err + } + + headers := make(map[string]string) + queryParams := make(map[string]string) + + securityValType := trueReflectValue(reflect.ValueOf(security)) + securityStructType := securityValType.Type() + + if isNil(securityStructType, securityValType) { + return nil + } + + if securityStructType.Kind() == reflect.Ptr { + securityStructType = securityStructType.Elem() + securityValType = securityValType.Elem() + } + + for i := 0; i < securityStructType.NumField(); i++ { + fieldType := securityStructType.Field(i) + valType := securityValType.Field(i) + + kind := valType.Kind() + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Pointer { + kind = valType.Elem().Kind() + } + + secTag := parseSecurityTag(fieldType) + if secTag != nil { + if secTag.Option { + handleSecurityOption(headers, queryParams, valType.Interface()) + } else if secTag.Scheme { + // Special case for basic auth which could be a flattened struct + if secTag.SubType == "basic" && kind != reflect.Struct { + parseSecurityScheme(headers, queryParams, secTag, security) + } else { + parseSecurityScheme(headers, queryParams, secTag, valType.Interface()) + } + } + } + } + + for key, value := range headers { + req.Header.Add(key, value) + } + + query := req.URL.Query() + for key, value := range queryParams { + query.Add(key, value) + } + req.URL.RawQuery = query.Encode() + + return nil +} + +func handleSecurityOption(headers, queryParams map[string]string, option interface{}) { + optionValType := trueReflectValue(reflect.ValueOf(option)) + optionStructType := optionValType.Type() + + if isNil(optionStructType, optionValType) { + return + } + + for i := 0; i < optionStructType.NumField(); i++ { + fieldType := optionStructType.Field(i) + valType := optionValType.Field(i) + + secTag := parseSecurityTag(fieldType) + if secTag != nil && secTag.Scheme { + parseSecurityScheme(headers, queryParams, secTag, valType.Interface()) + } + } +} + +func parseSecurityScheme(headers, queryParams map[string]string, schemeTag *securityTag, scheme interface{}) { + schemeVal := trueReflectValue(reflect.ValueOf(scheme)) + schemeType := schemeVal.Type() + + if isNil(schemeType, schemeVal) { + return + } + + if schemeType.Kind() == reflect.Struct { + if schemeTag.Type == "http" && schemeTag.SubType == "basic" { + handleBasicAuthScheme(headers, schemeVal.Interface()) + return + } + + for i := 0; i < schemeType.NumField(); i++ { + fieldType := schemeType.Field(i) + valType := schemeVal.Field(i) + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Ptr { + valType = valType.Elem() + } + + secTag := parseSecurityTag(fieldType) + if secTag == nil || secTag.Name == "" { + return + } + + parseSecuritySchemeValue(headers, queryParams, schemeTag, secTag, valType.Interface()) + } + } else { + parseSecuritySchemeValue(headers, queryParams, schemeTag, schemeTag, schemeVal.Interface()) + } +} + +func parseSecuritySchemeValue(headers, queryParams map[string]string, schemeTag *securityTag, secTag *securityTag, val interface{}) { + switch schemeTag.Type { + case "apiKey": + switch schemeTag.SubType { + case "header": + headers[secTag.Name] = valToString(val) + case "query": + queryParams[secTag.Name] = valToString(val) + case "cookie": + headers["Cookie"] = fmt.Sprintf("%s=%s", secTag.Name, valToString(val)) + default: + panic("not supported") + } + case "openIdConnect": + headers[secTag.Name] = prefixBearer(valToString(val)) + case "oauth2": + if schemeTag.SubType != "client_credentials" { + headers[secTag.Name] = prefixBearer(valToString(val)) + } + case "http": + switch schemeTag.SubType { + case "bearer": + headers[secTag.Name] = prefixBearer(valToString(val)) + default: + panic("not supported") + } + default: + panic("not supported") + } +} + +func prefixBearer(authHeaderValue string) string { + if strings.HasPrefix(strings.ToLower(authHeaderValue), "bearer ") { + return authHeaderValue + } + + return fmt.Sprintf("Bearer %s", authHeaderValue) +} + +func handleBasicAuthScheme(headers map[string]string, scheme interface{}) { + schemeStructType := reflect.TypeOf(scheme) + schemeValType := reflect.ValueOf(scheme) + + var username, password string + + for i := 0; i < schemeStructType.NumField(); i++ { + fieldType := schemeStructType.Field(i) + valType := schemeValType.Field(i) + + if fieldType.Type.Kind() == reflect.Ptr { + valType = valType.Elem() + } + + secTag := parseSecurityTag(fieldType) + if secTag == nil || secTag.Name == "" { + continue + } + + switch secTag.Name { + case "username": + username = valType.String() + case "password": + password = valType.String() + } + } + + headers["Authorization"] = fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", username, password)))) +} + +func parseSecurityTag(field reflect.StructField) *securityTag { + tag := field.Tag.Get(securityTagKey) + if tag == "" { + return nil + } + + option := false + scheme := false + name := "" + securityType := "" + securitySubType := "" + + options := strings.Split(tag, ",") + for _, optionConf := range options { + parts := strings.Split(optionConf, "=") + if len(parts) < 1 || len(parts) > 2 { + continue + } + + switch parts[0] { + case "name": + name = parts[1] + case "type": + securityType = parts[1] + case "subtype": + securitySubType = parts[1] + case "option": + option = true + case "scheme": + scheme = true + } + } + + // TODO: validate tag? + + return &securityTag{ + Option: option, + Scheme: scheme, + Name: name, + Type: securityType, + SubType: securitySubType, + } +} + +func trueReflectValue(val reflect.Value) reflect.Value { + kind := val.Type().Kind() + for kind == reflect.Interface || kind == reflect.Ptr { + innerVal := val.Elem() + if !innerVal.IsValid() { + break + } + val = innerVal + kind = val.Type().Kind() + } + return val +} diff --git a/components/ledger/pkg/client/internal/utils/utils.go b/components/ledger/pkg/client/internal/utils/utils.go new file mode 100644 index 0000000000..50482f2e0a --- /dev/null +++ b/components/ledger/pkg/client/internal/utils/utils.go @@ -0,0 +1,230 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package utils + +import ( + "context" + "fmt" + "io" + "math/big" + "reflect" + "regexp" + "strconv" + "strings" + "time" + + "github.com/ericlagergren/decimal" +) + +const ( + queryParamTagKey = "queryParam" + headerParamTagKey = "header" + pathParamTagKey = "pathParam" +) + +var ( + paramRegex = regexp.MustCompile(`({.*?})`) + SerializationMethodToContentType = map[string]string{ + "json": "application/json", + "form": "application/x-www-form-urlencoded", + "multipart": "multipart/form-data", + "raw": "application/octet-stream", + "string": "text/plain", + } +) + +func UnmarshalJsonFromResponseBody(body io.Reader, out interface{}, tag string) error { + data, err := io.ReadAll(body) + if err != nil { + return fmt.Errorf("error reading response body: %w", err) + } + if err := UnmarshalJSON(data, out, reflect.StructTag(tag), true, false); err != nil { + return fmt.Errorf("error unmarshalling json response body: %w", err) + } + + return nil +} + +func ReplaceParameters(stringWithParams string, params map[string]string) string { + if len(params) == 0 { + return stringWithParams + } + + return paramRegex.ReplaceAllStringFunc(stringWithParams, func(match string) string { + match = match[1 : len(match)-1] + return params[match] + }) +} + +func Contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} + +func MatchStatusCodes(expectedCodes []string, statusCode int) bool { + for _, codeStr := range expectedCodes { + code, err := strconv.Atoi(codeStr) + if err == nil { + if code == statusCode { + return true + } + continue + } + + codeRange, err := strconv.Atoi(string(codeStr[0])) + if err != nil { + continue + } + + if statusCode >= (codeRange*100) && statusCode < ((codeRange+1)*100) { + return true + } + } + + return false +} + +func AsSecuritySource(security interface{}) func(context.Context) (interface{}, error) { + return func(context.Context) (interface{}, error) { + return security, nil + } +} + +func parseStructTag(tagKey string, field reflect.StructField) map[string]string { + tag := field.Tag.Get(tagKey) + if tag == "" { + return nil + } + + values := map[string]string{} + + options := strings.Split(tag, ",") + for _, optionConf := range options { + parts := strings.Split(optionConf, "=") + + switch len(parts) { + case 1: + // flag option + parts = append(parts, "true") + case 2: + // key=value option + default: + // invalid option + continue + } + + values[parts[0]] = parts[1] + } + + return values +} + +func parseParamTag(tagKey string, field reflect.StructField, defaultStyle string, defaultExplode bool) *paramTag { + // example `{tagKey}:"style=simple,explode=false,name=apiID"` + values := parseStructTag(tagKey, field) + if values == nil { + return nil + } + + tag := ¶mTag{ + Style: defaultStyle, + Explode: defaultExplode, + ParamName: strings.ToLower(field.Name), + } + + for k, v := range values { + switch k { + case "style": + tag.Style = v + case "explode": + tag.Explode = v == "true" + case "name": + tag.ParamName = v + case "serialization": + tag.Serialization = v + } + } + + return tag +} + +func valToString(val interface{}) string { + switch v := val.(type) { + case time.Time: + return v.Format(time.RFC3339Nano) + case big.Int: + return v.String() + case decimal.Big: + return v.String() + default: + return fmt.Sprintf("%v", v) + } +} + +func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals interface{}) (reflect.StructField, reflect.Value, bool) { + if globals == nil { + return fieldType, valType, false + } + + globalsStruct := reflect.TypeOf(globals) + globalsStructVal := reflect.ValueOf(globals) + + globalsField, found := globalsStruct.FieldByName(fieldType.Name) + if !found { + return fieldType, valType, false + } + + if fieldType.Type.Kind() != reflect.Ptr || !valType.IsNil() { + return fieldType, valType, true + } + + globalsVal := globalsStructVal.FieldByName(fieldType.Name) + + if !globalsVal.IsValid() { + return fieldType, valType, false + } + + switch paramType { + case queryParamTagKey: + qpTag := parseQueryParamTag(globalsField) + if qpTag == nil { + return fieldType, valType, false + } + default: + tag := parseParamTag(paramType, fieldType, "simple", false) + if tag == nil { + return fieldType, valType, false + } + } + + return globalsField, globalsVal, true +} + +func isNil(typ reflect.Type, val reflect.Value) bool { + // `reflect.TypeOf(nil) == nil` so calling typ.Kind() will cause a nil pointer + // dereference panic. Catch it and return early. + // https://github.com/golang/go/issues/51649 + // https://github.com/golang/go/issues/54208 + if typ == nil { + return true + } + + if typ.Kind() == reflect.Ptr || typ.Kind() == reflect.Map || typ.Kind() == reflect.Slice || typ.Kind() == reflect.Interface { + return val.IsNil() + } + + return false +} + +func contains(arr []string, str string) bool { + for _, a := range arr { + if a == str { + return true + } + } + return false +} diff --git a/components/ledger/pkg/client/ledger.go b/components/ledger/pkg/client/ledger.go new file mode 100644 index 0000000000..71248e1a24 --- /dev/null +++ b/components/ledger/pkg/client/ledger.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package client + +type Ledger struct { + V2 *V2 + + sdkConfiguration sdkConfiguration +} + +func newLedger(sdkConfig sdkConfiguration) *Ledger { + return &Ledger{ + sdkConfiguration: sdkConfig, + V2: newV2(sdkConfig), + } +} diff --git a/components/ledger/pkg/client/models/components/httpmetadata.go b/components/ledger/pkg/client/models/components/httpmetadata.go new file mode 100644 index 0000000000..7487a5b0bc --- /dev/null +++ b/components/ledger/pkg/client/models/components/httpmetadata.go @@ -0,0 +1,28 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "net/http" +) + +type HTTPMetadata struct { + // Raw HTTP response; suitable for custom response parsing + Response *http.Response `json:"-"` + // Raw HTTP request; suitable for debugging + Request *http.Request `json:"-"` +} + +func (o *HTTPMetadata) GetResponse() *http.Response { + if o == nil { + return nil + } + return o.Response +} + +func (o *HTTPMetadata) GetRequest() *http.Request { + if o == nil { + return nil + } + return o.Request +} diff --git a/components/ledger/pkg/client/models/components/v2account.go b/components/ledger/pkg/client/models/components/v2account.go new file mode 100644 index 0000000000..ae75c8304d --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2account.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2Account struct { + Address string `json:"address"` + Metadata map[string]string `json:"metadata"` + Volumes map[string]V2Volume `json:"volumes,omitempty"` + EffectiveVolumes map[string]V2Volume `json:"effectiveVolumes,omitempty"` +} + +func (o *V2Account) GetAddress() string { + if o == nil { + return "" + } + return o.Address +} + +func (o *V2Account) GetMetadata() map[string]string { + if o == nil { + return map[string]string{} + } + return o.Metadata +} + +func (o *V2Account) GetVolumes() map[string]V2Volume { + if o == nil { + return nil + } + return o.Volumes +} + +func (o *V2Account) GetEffectiveVolumes() map[string]V2Volume { + if o == nil { + return nil + } + return o.EffectiveVolumes +} diff --git a/components/ledger/pkg/client/models/components/v2accountresponse.go b/components/ledger/pkg/client/models/components/v2accountresponse.go new file mode 100644 index 0000000000..82470b6928 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2accountresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2AccountResponse struct { + Data V2Account `json:"data"` +} + +func (o *V2AccountResponse) GetData() V2Account { + if o == nil { + return V2Account{} + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2accountscursorresponse.go b/components/ledger/pkg/client/models/components/v2accountscursorresponse.go new file mode 100644 index 0000000000..1f0a921a8b --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2accountscursorresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2AccountsCursorResponseCursor struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitempty"` + Next *string `json:"next,omitempty"` + Data []V2Account `json:"data"` +} + +func (o *V2AccountsCursorResponseCursor) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *V2AccountsCursorResponseCursor) GetHasMore() bool { + if o == nil { + return false + } + return o.HasMore +} + +func (o *V2AccountsCursorResponseCursor) GetPrevious() *string { + if o == nil { + return nil + } + return o.Previous +} + +func (o *V2AccountsCursorResponseCursor) GetNext() *string { + if o == nil { + return nil + } + return o.Next +} + +func (o *V2AccountsCursorResponseCursor) GetData() []V2Account { + if o == nil { + return []V2Account{} + } + return o.Data +} + +type V2AccountsCursorResponse struct { + Cursor V2AccountsCursorResponseCursor `json:"cursor"` +} + +func (o *V2AccountsCursorResponse) GetCursor() V2AccountsCursorResponseCursor { + if o == nil { + return V2AccountsCursorResponseCursor{} + } + return o.Cursor +} diff --git a/components/ledger/pkg/client/models/components/v2aggregatebalancesresponse.go b/components/ledger/pkg/client/models/components/v2aggregatebalancesresponse.go new file mode 100644 index 0000000000..6f23e95320 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2aggregatebalancesresponse.go @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" +) + +type V2AggregateBalancesResponse struct { + Data map[string]*big.Int `json:"data"` +} + +func (v V2AggregateBalancesResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2AggregateBalancesResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2AggregateBalancesResponse) GetData() map[string]*big.Int { + if o == nil { + return map[string]*big.Int{} + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2bulkelement.go b/components/ledger/pkg/client/models/components/v2bulkelement.go new file mode 100644 index 0000000000..ad4c3c9bb3 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2bulkelement.go @@ -0,0 +1,149 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "errors" + "fmt" + "github.com/formancehq/stack/ledger/client/internal/utils" +) + +type V2BulkElementType string + +const ( + V2BulkElementTypeCreateTransaction V2BulkElementType = "CREATE_TRANSACTION" + V2BulkElementTypeAddMetadata V2BulkElementType = "ADD_METADATA" + V2BulkElementTypeRevertTransaction V2BulkElementType = "REVERT_TRANSACTION" + V2BulkElementTypeDeleteMetadata V2BulkElementType = "DELETE_METADATA" +) + +type V2BulkElement struct { + V2BulkElementCreateTransaction *V2BulkElementCreateTransaction + V2BulkElementAddMetadata *V2BulkElementAddMetadata + V2BulkElementRevertTransaction *V2BulkElementRevertTransaction + V2BulkElementDeleteMetadata *V2BulkElementDeleteMetadata + + Type V2BulkElementType +} + +func CreateV2BulkElementCreateTransaction(createTransaction V2BulkElementCreateTransaction) V2BulkElement { + typ := V2BulkElementTypeCreateTransaction + + typStr := string(typ) + createTransaction.Action = typStr + + return V2BulkElement{ + V2BulkElementCreateTransaction: &createTransaction, + Type: typ, + } +} + +func CreateV2BulkElementAddMetadata(addMetadata V2BulkElementAddMetadata) V2BulkElement { + typ := V2BulkElementTypeAddMetadata + + typStr := string(typ) + addMetadata.Action = typStr + + return V2BulkElement{ + V2BulkElementAddMetadata: &addMetadata, + Type: typ, + } +} + +func CreateV2BulkElementRevertTransaction(revertTransaction V2BulkElementRevertTransaction) V2BulkElement { + typ := V2BulkElementTypeRevertTransaction + + typStr := string(typ) + revertTransaction.Action = typStr + + return V2BulkElement{ + V2BulkElementRevertTransaction: &revertTransaction, + Type: typ, + } +} + +func CreateV2BulkElementDeleteMetadata(deleteMetadata V2BulkElementDeleteMetadata) V2BulkElement { + typ := V2BulkElementTypeDeleteMetadata + + typStr := string(typ) + deleteMetadata.Action = typStr + + return V2BulkElement{ + V2BulkElementDeleteMetadata: &deleteMetadata, + Type: typ, + } +} + +func (u *V2BulkElement) UnmarshalJSON(data []byte) error { + + type discriminator struct { + Action string `json:"action"` + } + + dis := new(discriminator) + if err := json.Unmarshal(data, &dis); err != nil { + return fmt.Errorf("could not unmarshal discriminator: %w", err) + } + + switch dis.Action { + case "CREATE_TRANSACTION": + v2BulkElementCreateTransaction := new(V2BulkElementCreateTransaction) + if err := utils.UnmarshalJSON(data, &v2BulkElementCreateTransaction, "", true, false); err != nil { + return fmt.Errorf("could not unmarshal `%s` into expected (Action == CREATE_TRANSACTION) type V2BulkElementCreateTransaction within V2BulkElement: %w", string(data), err) + } + + u.V2BulkElementCreateTransaction = v2BulkElementCreateTransaction + u.Type = V2BulkElementTypeCreateTransaction + return nil + case "ADD_METADATA": + v2BulkElementAddMetadata := new(V2BulkElementAddMetadata) + if err := utils.UnmarshalJSON(data, &v2BulkElementAddMetadata, "", true, false); err != nil { + return fmt.Errorf("could not unmarshal `%s` into expected (Action == ADD_METADATA) type V2BulkElementAddMetadata within V2BulkElement: %w", string(data), err) + } + + u.V2BulkElementAddMetadata = v2BulkElementAddMetadata + u.Type = V2BulkElementTypeAddMetadata + return nil + case "REVERT_TRANSACTION": + v2BulkElementRevertTransaction := new(V2BulkElementRevertTransaction) + if err := utils.UnmarshalJSON(data, &v2BulkElementRevertTransaction, "", true, false); err != nil { + return fmt.Errorf("could not unmarshal `%s` into expected (Action == REVERT_TRANSACTION) type V2BulkElementRevertTransaction within V2BulkElement: %w", string(data), err) + } + + u.V2BulkElementRevertTransaction = v2BulkElementRevertTransaction + u.Type = V2BulkElementTypeRevertTransaction + return nil + case "DELETE_METADATA": + v2BulkElementDeleteMetadata := new(V2BulkElementDeleteMetadata) + if err := utils.UnmarshalJSON(data, &v2BulkElementDeleteMetadata, "", true, false); err != nil { + return fmt.Errorf("could not unmarshal `%s` into expected (Action == DELETE_METADATA) type V2BulkElementDeleteMetadata within V2BulkElement: %w", string(data), err) + } + + u.V2BulkElementDeleteMetadata = v2BulkElementDeleteMetadata + u.Type = V2BulkElementTypeDeleteMetadata + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for V2BulkElement", string(data)) +} + +func (u V2BulkElement) MarshalJSON() ([]byte, error) { + if u.V2BulkElementCreateTransaction != nil { + return utils.MarshalJSON(u.V2BulkElementCreateTransaction, "", true) + } + + if u.V2BulkElementAddMetadata != nil { + return utils.MarshalJSON(u.V2BulkElementAddMetadata, "", true) + } + + if u.V2BulkElementRevertTransaction != nil { + return utils.MarshalJSON(u.V2BulkElementRevertTransaction, "", true) + } + + if u.V2BulkElementDeleteMetadata != nil { + return utils.MarshalJSON(u.V2BulkElementDeleteMetadata, "", true) + } + + return nil, errors.New("could not marshal union type V2BulkElement: all fields are null") +} diff --git a/components/ledger/pkg/client/models/components/v2bulkelementaddmetadata.go b/components/ledger/pkg/client/models/components/v2bulkelementaddmetadata.go new file mode 100644 index 0000000000..f059cdf0ba --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2bulkelementaddmetadata.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type Data struct { + TargetID V2TargetID `json:"targetId"` + TargetType V2TargetType `json:"targetType"` + Metadata map[string]string `json:"metadata"` +} + +func (o *Data) GetTargetID() V2TargetID { + if o == nil { + return V2TargetID{} + } + return o.TargetID +} + +func (o *Data) GetTargetType() V2TargetType { + if o == nil { + return V2TargetType("") + } + return o.TargetType +} + +func (o *Data) GetMetadata() map[string]string { + if o == nil { + return map[string]string{} + } + return o.Metadata +} + +type V2BulkElementAddMetadata struct { + Action string `json:"action"` + Ik *string `json:"ik,omitempty"` + Data *Data `json:"data,omitempty"` +} + +func (o *V2BulkElementAddMetadata) GetAction() string { + if o == nil { + return "" + } + return o.Action +} + +func (o *V2BulkElementAddMetadata) GetIk() *string { + if o == nil { + return nil + } + return o.Ik +} + +func (o *V2BulkElementAddMetadata) GetData() *Data { + if o == nil { + return nil + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2bulkelementcreatetransaction.go b/components/ledger/pkg/client/models/components/v2bulkelementcreatetransaction.go new file mode 100644 index 0000000000..d06abc2dc2 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2bulkelementcreatetransaction.go @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2BulkElementCreateTransaction struct { + Action string `json:"action"` + Ik *string `json:"ik,omitempty"` + Data *V2PostTransaction `json:"data,omitempty"` +} + +func (o *V2BulkElementCreateTransaction) GetAction() string { + if o == nil { + return "" + } + return o.Action +} + +func (o *V2BulkElementCreateTransaction) GetIk() *string { + if o == nil { + return nil + } + return o.Ik +} + +func (o *V2BulkElementCreateTransaction) GetData() *V2PostTransaction { + if o == nil { + return nil + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2bulkelementdeletemetadata.go b/components/ledger/pkg/client/models/components/v2bulkelementdeletemetadata.go new file mode 100644 index 0000000000..a4b351642f --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2bulkelementdeletemetadata.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2BulkElementDeleteMetadataData struct { + TargetID V2TargetID `json:"targetId"` + TargetType V2TargetType `json:"targetType"` + Key string `json:"key"` +} + +func (o *V2BulkElementDeleteMetadataData) GetTargetID() V2TargetID { + if o == nil { + return V2TargetID{} + } + return o.TargetID +} + +func (o *V2BulkElementDeleteMetadataData) GetTargetType() V2TargetType { + if o == nil { + return V2TargetType("") + } + return o.TargetType +} + +func (o *V2BulkElementDeleteMetadataData) GetKey() string { + if o == nil { + return "" + } + return o.Key +} + +type V2BulkElementDeleteMetadata struct { + Action string `json:"action"` + Ik *string `json:"ik,omitempty"` + Data *V2BulkElementDeleteMetadataData `json:"data,omitempty"` +} + +func (o *V2BulkElementDeleteMetadata) GetAction() string { + if o == nil { + return "" + } + return o.Action +} + +func (o *V2BulkElementDeleteMetadata) GetIk() *string { + if o == nil { + return nil + } + return o.Ik +} + +func (o *V2BulkElementDeleteMetadata) GetData() *V2BulkElementDeleteMetadataData { + if o == nil { + return nil + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2bulkelementresult.go b/components/ledger/pkg/client/models/components/v2bulkelementresult.go new file mode 100644 index 0000000000..6730a0bc17 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2bulkelementresult.go @@ -0,0 +1,271 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "errors" + "fmt" + "github.com/formancehq/stack/ledger/client/internal/utils" +) + +type V2BulkElementResultError struct { + ResponseType string `json:"responseType"` + ErrorCode string `json:"errorCode"` + ErrorDescription string `json:"errorDescription"` + ErrorDetails *string `json:"errorDetails,omitempty"` +} + +func (o *V2BulkElementResultError) GetResponseType() string { + if o == nil { + return "" + } + return o.ResponseType +} + +func (o *V2BulkElementResultError) GetErrorCode() string { + if o == nil { + return "" + } + return o.ErrorCode +} + +func (o *V2BulkElementResultError) GetErrorDescription() string { + if o == nil { + return "" + } + return o.ErrorDescription +} + +func (o *V2BulkElementResultError) GetErrorDetails() *string { + if o == nil { + return nil + } + return o.ErrorDetails +} + +type V2BulkElementResultDeleteMetadata struct { + ResponseType string `json:"responseType"` +} + +func (o *V2BulkElementResultDeleteMetadata) GetResponseType() string { + if o == nil { + return "" + } + return o.ResponseType +} + +type V2BulkElementResultRevertTransaction struct { + ResponseType string `json:"responseType"` + Data V2Transaction `json:"data"` +} + +func (o *V2BulkElementResultRevertTransaction) GetResponseType() string { + if o == nil { + return "" + } + return o.ResponseType +} + +func (o *V2BulkElementResultRevertTransaction) GetData() V2Transaction { + if o == nil { + return V2Transaction{} + } + return o.Data +} + +type V2BulkElementResultAddMetadata struct { + ResponseType string `json:"responseType"` +} + +func (o *V2BulkElementResultAddMetadata) GetResponseType() string { + if o == nil { + return "" + } + return o.ResponseType +} + +type V2BulkElementResultCreateTransaction struct { + ResponseType string `json:"responseType"` + Data V2Transaction `json:"data"` +} + +func (o *V2BulkElementResultCreateTransaction) GetResponseType() string { + if o == nil { + return "" + } + return o.ResponseType +} + +func (o *V2BulkElementResultCreateTransaction) GetData() V2Transaction { + if o == nil { + return V2Transaction{} + } + return o.Data +} + +type V2BulkElementResultType string + +const ( + V2BulkElementResultTypeCreateTransaction V2BulkElementResultType = "CREATE_TRANSACTION" + V2BulkElementResultTypeAddMetadata V2BulkElementResultType = "ADD_METADATA" + V2BulkElementResultTypeRevertTransaction V2BulkElementResultType = "REVERT_TRANSACTION" + V2BulkElementResultTypeDeleteMetadata V2BulkElementResultType = "DELETE_METADATA" + V2BulkElementResultTypeError V2BulkElementResultType = "ERROR" +) + +type V2BulkElementResult struct { + V2BulkElementResultCreateTransaction *V2BulkElementResultCreateTransaction + V2BulkElementResultAddMetadata *V2BulkElementResultAddMetadata + V2BulkElementResultRevertTransaction *V2BulkElementResultRevertTransaction + V2BulkElementResultDeleteMetadata *V2BulkElementResultDeleteMetadata + V2BulkElementResultError *V2BulkElementResultError + + Type V2BulkElementResultType +} + +func CreateV2BulkElementResultCreateTransaction(createTransaction V2BulkElementResultCreateTransaction) V2BulkElementResult { + typ := V2BulkElementResultTypeCreateTransaction + + typStr := string(typ) + createTransaction.ResponseType = typStr + + return V2BulkElementResult{ + V2BulkElementResultCreateTransaction: &createTransaction, + Type: typ, + } +} + +func CreateV2BulkElementResultAddMetadata(addMetadata V2BulkElementResultAddMetadata) V2BulkElementResult { + typ := V2BulkElementResultTypeAddMetadata + + typStr := string(typ) + addMetadata.ResponseType = typStr + + return V2BulkElementResult{ + V2BulkElementResultAddMetadata: &addMetadata, + Type: typ, + } +} + +func CreateV2BulkElementResultRevertTransaction(revertTransaction V2BulkElementResultRevertTransaction) V2BulkElementResult { + typ := V2BulkElementResultTypeRevertTransaction + + typStr := string(typ) + revertTransaction.ResponseType = typStr + + return V2BulkElementResult{ + V2BulkElementResultRevertTransaction: &revertTransaction, + Type: typ, + } +} + +func CreateV2BulkElementResultDeleteMetadata(deleteMetadata V2BulkElementResultDeleteMetadata) V2BulkElementResult { + typ := V2BulkElementResultTypeDeleteMetadata + + typStr := string(typ) + deleteMetadata.ResponseType = typStr + + return V2BulkElementResult{ + V2BulkElementResultDeleteMetadata: &deleteMetadata, + Type: typ, + } +} + +func CreateV2BulkElementResultError(error V2BulkElementResultError) V2BulkElementResult { + typ := V2BulkElementResultTypeError + + typStr := string(typ) + error.ResponseType = typStr + + return V2BulkElementResult{ + V2BulkElementResultError: &error, + Type: typ, + } +} + +func (u *V2BulkElementResult) UnmarshalJSON(data []byte) error { + + type discriminator struct { + ResponseType string `json:"responseType"` + } + + dis := new(discriminator) + if err := json.Unmarshal(data, &dis); err != nil { + return fmt.Errorf("could not unmarshal discriminator: %w", err) + } + + switch dis.ResponseType { + case "CREATE_TRANSACTION": + v2BulkElementResultCreateTransaction := new(V2BulkElementResultCreateTransaction) + if err := utils.UnmarshalJSON(data, &v2BulkElementResultCreateTransaction, "", true, false); err != nil { + return fmt.Errorf("could not unmarshal `%s` into expected (ResponseType == CREATE_TRANSACTION) type V2BulkElementResultCreateTransaction within V2BulkElementResult: %w", string(data), err) + } + + u.V2BulkElementResultCreateTransaction = v2BulkElementResultCreateTransaction + u.Type = V2BulkElementResultTypeCreateTransaction + return nil + case "ADD_METADATA": + v2BulkElementResultAddMetadata := new(V2BulkElementResultAddMetadata) + if err := utils.UnmarshalJSON(data, &v2BulkElementResultAddMetadata, "", true, false); err != nil { + return fmt.Errorf("could not unmarshal `%s` into expected (ResponseType == ADD_METADATA) type V2BulkElementResultAddMetadata within V2BulkElementResult: %w", string(data), err) + } + + u.V2BulkElementResultAddMetadata = v2BulkElementResultAddMetadata + u.Type = V2BulkElementResultTypeAddMetadata + return nil + case "REVERT_TRANSACTION": + v2BulkElementResultRevertTransaction := new(V2BulkElementResultRevertTransaction) + if err := utils.UnmarshalJSON(data, &v2BulkElementResultRevertTransaction, "", true, false); err != nil { + return fmt.Errorf("could not unmarshal `%s` into expected (ResponseType == REVERT_TRANSACTION) type V2BulkElementResultRevertTransaction within V2BulkElementResult: %w", string(data), err) + } + + u.V2BulkElementResultRevertTransaction = v2BulkElementResultRevertTransaction + u.Type = V2BulkElementResultTypeRevertTransaction + return nil + case "DELETE_METADATA": + v2BulkElementResultDeleteMetadata := new(V2BulkElementResultDeleteMetadata) + if err := utils.UnmarshalJSON(data, &v2BulkElementResultDeleteMetadata, "", true, false); err != nil { + return fmt.Errorf("could not unmarshal `%s` into expected (ResponseType == DELETE_METADATA) type V2BulkElementResultDeleteMetadata within V2BulkElementResult: %w", string(data), err) + } + + u.V2BulkElementResultDeleteMetadata = v2BulkElementResultDeleteMetadata + u.Type = V2BulkElementResultTypeDeleteMetadata + return nil + case "ERROR": + v2BulkElementResultError := new(V2BulkElementResultError) + if err := utils.UnmarshalJSON(data, &v2BulkElementResultError, "", true, false); err != nil { + return fmt.Errorf("could not unmarshal `%s` into expected (ResponseType == ERROR) type V2BulkElementResultError within V2BulkElementResult: %w", string(data), err) + } + + u.V2BulkElementResultError = v2BulkElementResultError + u.Type = V2BulkElementResultTypeError + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for V2BulkElementResult", string(data)) +} + +func (u V2BulkElementResult) MarshalJSON() ([]byte, error) { + if u.V2BulkElementResultCreateTransaction != nil { + return utils.MarshalJSON(u.V2BulkElementResultCreateTransaction, "", true) + } + + if u.V2BulkElementResultAddMetadata != nil { + return utils.MarshalJSON(u.V2BulkElementResultAddMetadata, "", true) + } + + if u.V2BulkElementResultRevertTransaction != nil { + return utils.MarshalJSON(u.V2BulkElementResultRevertTransaction, "", true) + } + + if u.V2BulkElementResultDeleteMetadata != nil { + return utils.MarshalJSON(u.V2BulkElementResultDeleteMetadata, "", true) + } + + if u.V2BulkElementResultError != nil { + return utils.MarshalJSON(u.V2BulkElementResultError, "", true) + } + + return nil, errors.New("could not marshal union type V2BulkElementResult: all fields are null") +} diff --git a/components/ledger/pkg/client/models/components/v2bulkelementreverttransaction.go b/components/ledger/pkg/client/models/components/v2bulkelementreverttransaction.go new file mode 100644 index 0000000000..e1f4c5b194 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2bulkelementreverttransaction.go @@ -0,0 +1,73 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" +) + +type V2BulkElementRevertTransactionData struct { + ID *big.Int `json:"id"` + Force *bool `json:"force,omitempty"` + AtEffectiveDate *bool `json:"atEffectiveDate,omitempty"` +} + +func (v V2BulkElementRevertTransactionData) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2BulkElementRevertTransactionData) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2BulkElementRevertTransactionData) GetID() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.ID +} + +func (o *V2BulkElementRevertTransactionData) GetForce() *bool { + if o == nil { + return nil + } + return o.Force +} + +func (o *V2BulkElementRevertTransactionData) GetAtEffectiveDate() *bool { + if o == nil { + return nil + } + return o.AtEffectiveDate +} + +type V2BulkElementRevertTransaction struct { + Action string `json:"action"` + Ik *string `json:"ik,omitempty"` + Data *V2BulkElementRevertTransactionData `json:"data,omitempty"` +} + +func (o *V2BulkElementRevertTransaction) GetAction() string { + if o == nil { + return "" + } + return o.Action +} + +func (o *V2BulkElementRevertTransaction) GetIk() *string { + if o == nil { + return nil + } + return o.Ik +} + +func (o *V2BulkElementRevertTransaction) GetData() *V2BulkElementRevertTransactionData { + if o == nil { + return nil + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2bulkresponse.go b/components/ledger/pkg/client/models/components/v2bulkresponse.go new file mode 100644 index 0000000000..2d5cd5c746 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2bulkresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2BulkResponse struct { + Data []V2BulkElementResult `json:"data"` +} + +func (o *V2BulkResponse) GetData() []V2BulkElementResult { + if o == nil { + return []V2BulkElementResult{} + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2configinforesponse.go b/components/ledger/pkg/client/models/components/v2configinforesponse.go new file mode 100644 index 0000000000..e4d2d8c187 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2configinforesponse.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2ConfigInfoResponse struct { + Server string `json:"server"` + Version string `json:"version"` +} + +func (o *V2ConfigInfoResponse) GetServer() string { + if o == nil { + return "" + } + return o.Server +} + +func (o *V2ConfigInfoResponse) GetVersion() string { + if o == nil { + return "" + } + return o.Version +} diff --git a/components/ledger/pkg/client/models/components/v2createledgerrequest.go b/components/ledger/pkg/client/models/components/v2createledgerrequest.go new file mode 100644 index 0000000000..9f1aed0f4b --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2createledgerrequest.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2CreateLedgerRequest struct { + Bucket *string `json:"bucket,omitempty"` + Metadata map[string]string `json:"metadata,omitempty"` +} + +func (o *V2CreateLedgerRequest) GetBucket() *string { + if o == nil { + return nil + } + return o.Bucket +} + +func (o *V2CreateLedgerRequest) GetMetadata() map[string]string { + if o == nil { + return nil + } + return o.Metadata +} diff --git a/components/ledger/pkg/client/models/components/v2createtransactionresponse.go b/components/ledger/pkg/client/models/components/v2createtransactionresponse.go new file mode 100644 index 0000000000..0fea3d18a7 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2createtransactionresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2CreateTransactionResponse struct { + Data V2Transaction `json:"data"` +} + +func (o *V2CreateTransactionResponse) GetData() V2Transaction { + if o == nil { + return V2Transaction{} + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2errorsenum.go b/components/ledger/pkg/client/models/components/v2errorsenum.go new file mode 100644 index 0000000000..cde83a3257 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2errorsenum.go @@ -0,0 +1,64 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" +) + +type V2ErrorsEnum string + +const ( + V2ErrorsEnumInternal V2ErrorsEnum = "INTERNAL" + V2ErrorsEnumInsufficientFund V2ErrorsEnum = "INSUFFICIENT_FUND" + V2ErrorsEnumValidation V2ErrorsEnum = "VALIDATION" + V2ErrorsEnumConflict V2ErrorsEnum = "CONFLICT" + V2ErrorsEnumCompilationFailed V2ErrorsEnum = "COMPILATION_FAILED" + V2ErrorsEnumMetadataOverride V2ErrorsEnum = "METADATA_OVERRIDE" + V2ErrorsEnumNotFound V2ErrorsEnum = "NOT_FOUND" + V2ErrorsEnumRevertOccurring V2ErrorsEnum = "REVERT_OCCURRING" + V2ErrorsEnumAlreadyRevert V2ErrorsEnum = "ALREADY_REVERT" + V2ErrorsEnumNoPostings V2ErrorsEnum = "NO_POSTINGS" + V2ErrorsEnumLedgerNotFound V2ErrorsEnum = "LEDGER_NOT_FOUND" + V2ErrorsEnumImport V2ErrorsEnum = "IMPORT" +) + +func (e V2ErrorsEnum) ToPointer() *V2ErrorsEnum { + return &e +} +func (e *V2ErrorsEnum) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "INTERNAL": + fallthrough + case "INSUFFICIENT_FUND": + fallthrough + case "VALIDATION": + fallthrough + case "CONFLICT": + fallthrough + case "COMPILATION_FAILED": + fallthrough + case "METADATA_OVERRIDE": + fallthrough + case "NOT_FOUND": + fallthrough + case "REVERT_OCCURRING": + fallthrough + case "ALREADY_REVERT": + fallthrough + case "NO_POSTINGS": + fallthrough + case "LEDGER_NOT_FOUND": + fallthrough + case "IMPORT": + *e = V2ErrorsEnum(v) + return nil + default: + return fmt.Errorf("invalid value for V2ErrorsEnum: %v", v) + } +} diff --git a/components/ledger/pkg/client/models/components/v2expandedtransaction.go b/components/ledger/pkg/client/models/components/v2expandedtransaction.go new file mode 100644 index 0000000000..518cbd3fdf --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2expandedtransaction.go @@ -0,0 +1,87 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" + "time" +) + +type V2ExpandedTransaction struct { + Timestamp time.Time `json:"timestamp"` + Postings []V2Posting `json:"postings"` + Reference *string `json:"reference,omitempty"` + Metadata map[string]string `json:"metadata"` + ID *big.Int `json:"id"` + Reverted bool `json:"reverted"` + PreCommitVolumes map[string]map[string]V2Volume `json:"preCommitVolumes,omitempty"` + PostCommitVolumes map[string]map[string]V2Volume `json:"postCommitVolumes,omitempty"` +} + +func (v V2ExpandedTransaction) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2ExpandedTransaction) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2ExpandedTransaction) GetTimestamp() time.Time { + if o == nil { + return time.Time{} + } + return o.Timestamp +} + +func (o *V2ExpandedTransaction) GetPostings() []V2Posting { + if o == nil { + return []V2Posting{} + } + return o.Postings +} + +func (o *V2ExpandedTransaction) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *V2ExpandedTransaction) GetMetadata() map[string]string { + if o == nil { + return map[string]string{} + } + return o.Metadata +} + +func (o *V2ExpandedTransaction) GetID() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.ID +} + +func (o *V2ExpandedTransaction) GetReverted() bool { + if o == nil { + return false + } + return o.Reverted +} + +func (o *V2ExpandedTransaction) GetPreCommitVolumes() map[string]map[string]V2Volume { + if o == nil { + return nil + } + return o.PreCommitVolumes +} + +func (o *V2ExpandedTransaction) GetPostCommitVolumes() map[string]map[string]V2Volume { + if o == nil { + return nil + } + return o.PostCommitVolumes +} diff --git a/components/ledger/pkg/client/models/components/v2getledgerresponse.go b/components/ledger/pkg/client/models/components/v2getledgerresponse.go new file mode 100644 index 0000000000..9d4c134adc --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2getledgerresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2GetLedgerResponse struct { + Data V2Ledger `json:"data"` +} + +func (o *V2GetLedgerResponse) GetData() V2Ledger { + if o == nil { + return V2Ledger{} + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2gettransactionresponse.go b/components/ledger/pkg/client/models/components/v2gettransactionresponse.go new file mode 100644 index 0000000000..8033f820cd --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2gettransactionresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2GetTransactionResponse struct { + Data V2ExpandedTransaction `json:"data"` +} + +func (o *V2GetTransactionResponse) GetData() V2ExpandedTransaction { + if o == nil { + return V2ExpandedTransaction{} + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2ledger.go b/components/ledger/pkg/client/models/components/v2ledger.go new file mode 100644 index 0000000000..4b15cc99a1 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2ledger.go @@ -0,0 +1,54 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "time" +) + +type V2Ledger struct { + Name string `json:"name"` + AddedAt time.Time `json:"addedAt"` + Bucket string `json:"bucket"` + Metadata map[string]string `json:"metadata,omitempty"` +} + +func (v V2Ledger) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2Ledger) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2Ledger) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *V2Ledger) GetAddedAt() time.Time { + if o == nil { + return time.Time{} + } + return o.AddedAt +} + +func (o *V2Ledger) GetBucket() string { + if o == nil { + return "" + } + return o.Bucket +} + +func (o *V2Ledger) GetMetadata() map[string]string { + if o == nil { + return nil + } + return o.Metadata +} diff --git a/components/ledger/pkg/client/models/components/v2ledgerinfo.go b/components/ledger/pkg/client/models/components/v2ledgerinfo.go new file mode 100644 index 0000000000..2047a9a4f9 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2ledgerinfo.go @@ -0,0 +1,33 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type Storage struct { + Migrations []V2MigrationInfo `json:"migrations,omitempty"` +} + +func (o *Storage) GetMigrations() []V2MigrationInfo { + if o == nil { + return nil + } + return o.Migrations +} + +type V2LedgerInfo struct { + Name *string `json:"name,omitempty"` + Storage *Storage `json:"storage,omitempty"` +} + +func (o *V2LedgerInfo) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *V2LedgerInfo) GetStorage() *Storage { + if o == nil { + return nil + } + return o.Storage +} diff --git a/components/ledger/pkg/client/models/components/v2ledgerinforesponse.go b/components/ledger/pkg/client/models/components/v2ledgerinforesponse.go new file mode 100644 index 0000000000..a07fccb051 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2ledgerinforesponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2LedgerInfoResponse struct { + Data *V2LedgerInfo `json:"data,omitempty"` +} + +func (o *V2LedgerInfoResponse) GetData() *V2LedgerInfo { + if o == nil { + return nil + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2ledgerlistresponse.go b/components/ledger/pkg/client/models/components/v2ledgerlistresponse.go new file mode 100644 index 0000000000..1aa4b35d52 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2ledgerlistresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type Cursor struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitempty"` + Next *string `json:"next,omitempty"` + Data []V2Ledger `json:"data"` +} + +func (o *Cursor) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *Cursor) GetHasMore() bool { + if o == nil { + return false + } + return o.HasMore +} + +func (o *Cursor) GetPrevious() *string { + if o == nil { + return nil + } + return o.Previous +} + +func (o *Cursor) GetNext() *string { + if o == nil { + return nil + } + return o.Next +} + +func (o *Cursor) GetData() []V2Ledger { + if o == nil { + return []V2Ledger{} + } + return o.Data +} + +type V2LedgerListResponse struct { + Cursor Cursor `json:"cursor"` +} + +func (o *V2LedgerListResponse) GetCursor() Cursor { + if o == nil { + return Cursor{} + } + return o.Cursor +} diff --git a/components/ledger/pkg/client/models/components/v2log.go b/components/ledger/pkg/client/models/components/v2log.go new file mode 100644 index 0000000000..c81489095e --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2log.go @@ -0,0 +1,94 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" + "time" +) + +type Type string + +const ( + TypeNewTransaction Type = "NEW_TRANSACTION" + TypeSetMetadata Type = "SET_METADATA" + TypeRevertedTransaction Type = "REVERTED_TRANSACTION" +) + +func (e Type) ToPointer() *Type { + return &e +} +func (e *Type) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "NEW_TRANSACTION": + fallthrough + case "SET_METADATA": + fallthrough + case "REVERTED_TRANSACTION": + *e = Type(v) + return nil + default: + return fmt.Errorf("invalid value for Type: %v", v) + } +} + +type V2Log struct { + ID *big.Int `json:"id"` + Type Type `json:"type"` + Data map[string]any `json:"data"` + Hash string `json:"hash"` + Date time.Time `json:"date"` +} + +func (v V2Log) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2Log) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2Log) GetID() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.ID +} + +func (o *V2Log) GetType() Type { + if o == nil { + return Type("") + } + return o.Type +} + +func (o *V2Log) GetData() map[string]any { + if o == nil { + return map[string]any{} + } + return o.Data +} + +func (o *V2Log) GetHash() string { + if o == nil { + return "" + } + return o.Hash +} + +func (o *V2Log) GetDate() time.Time { + if o == nil { + return time.Time{} + } + return o.Date +} diff --git a/components/ledger/pkg/client/models/components/v2logscursorresponse.go b/components/ledger/pkg/client/models/components/v2logscursorresponse.go new file mode 100644 index 0000000000..f74346dde0 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2logscursorresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2LogsCursorResponseCursor struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitempty"` + Next *string `json:"next,omitempty"` + Data []V2Log `json:"data"` +} + +func (o *V2LogsCursorResponseCursor) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *V2LogsCursorResponseCursor) GetHasMore() bool { + if o == nil { + return false + } + return o.HasMore +} + +func (o *V2LogsCursorResponseCursor) GetPrevious() *string { + if o == nil { + return nil + } + return o.Previous +} + +func (o *V2LogsCursorResponseCursor) GetNext() *string { + if o == nil { + return nil + } + return o.Next +} + +func (o *V2LogsCursorResponseCursor) GetData() []V2Log { + if o == nil { + return []V2Log{} + } + return o.Data +} + +type V2LogsCursorResponse struct { + Cursor V2LogsCursorResponseCursor `json:"cursor"` +} + +func (o *V2LogsCursorResponse) GetCursor() V2LogsCursorResponseCursor { + if o == nil { + return V2LogsCursorResponseCursor{} + } + return o.Cursor +} diff --git a/components/ledger/pkg/client/models/components/v2migrationinfo.go b/components/ledger/pkg/client/models/components/v2migrationinfo.go new file mode 100644 index 0000000000..8cef4660b6 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2migrationinfo.go @@ -0,0 +1,82 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" + "github.com/formancehq/stack/ledger/client/internal/utils" + "time" +) + +type State string + +const ( + StateToDo State = "TO DO" + StateDone State = "DONE" +) + +func (e State) ToPointer() *State { + return &e +} +func (e *State) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "TO DO": + fallthrough + case "DONE": + *e = State(v) + return nil + default: + return fmt.Errorf("invalid value for State: %v", v) + } +} + +type V2MigrationInfo struct { + Version *int64 `json:"version,omitempty"` + Name *string `json:"name,omitempty"` + Date *time.Time `json:"date,omitempty"` + State *State `json:"state,omitempty"` +} + +func (v V2MigrationInfo) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2MigrationInfo) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2MigrationInfo) GetVersion() *int64 { + if o == nil { + return nil + } + return o.Version +} + +func (o *V2MigrationInfo) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *V2MigrationInfo) GetDate() *time.Time { + if o == nil { + return nil + } + return o.Date +} + +func (o *V2MigrationInfo) GetState() *State { + if o == nil { + return nil + } + return o.State +} diff --git a/components/ledger/pkg/client/models/components/v2posting.go b/components/ledger/pkg/client/models/components/v2posting.go new file mode 100644 index 0000000000..c9466d6c61 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2posting.go @@ -0,0 +1,54 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" +) + +type V2Posting struct { + Amount *big.Int `json:"amount"` + Asset string `json:"asset"` + Destination string `json:"destination"` + Source string `json:"source"` +} + +func (v V2Posting) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2Posting) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2Posting) GetAmount() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Amount +} + +func (o *V2Posting) GetAsset() string { + if o == nil { + return "" + } + return o.Asset +} + +func (o *V2Posting) GetDestination() string { + if o == nil { + return "" + } + return o.Destination +} + +func (o *V2Posting) GetSource() string { + if o == nil { + return "" + } + return o.Source +} diff --git a/components/ledger/pkg/client/models/components/v2posttransaction.go b/components/ledger/pkg/client/models/components/v2posttransaction.go new file mode 100644 index 0000000000..c99ba1a7d7 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2posttransaction.go @@ -0,0 +1,81 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "time" +) + +type Script struct { + Plain string `json:"plain"` + Vars map[string]any `json:"vars,omitempty"` +} + +func (o *Script) GetPlain() string { + if o == nil { + return "" + } + return o.Plain +} + +func (o *Script) GetVars() map[string]any { + if o == nil { + return nil + } + return o.Vars +} + +type V2PostTransaction struct { + Timestamp *time.Time `json:"timestamp,omitempty"` + Postings []V2Posting `json:"postings,omitempty"` + Script *Script `json:"script,omitempty"` + Reference *string `json:"reference,omitempty"` + Metadata map[string]string `json:"metadata"` +} + +func (v V2PostTransaction) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2PostTransaction) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2PostTransaction) GetTimestamp() *time.Time { + if o == nil { + return nil + } + return o.Timestamp +} + +func (o *V2PostTransaction) GetPostings() []V2Posting { + if o == nil { + return nil + } + return o.Postings +} + +func (o *V2PostTransaction) GetScript() *Script { + if o == nil { + return nil + } + return o.Script +} + +func (o *V2PostTransaction) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *V2PostTransaction) GetMetadata() map[string]string { + if o == nil { + return map[string]string{} + } + return o.Metadata +} diff --git a/components/ledger/pkg/client/models/components/v2reverttransactionresponse.go b/components/ledger/pkg/client/models/components/v2reverttransactionresponse.go new file mode 100644 index 0000000000..61ef5e3fe0 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2reverttransactionresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2RevertTransactionResponse struct { + Data V2Transaction `json:"data"` +} + +func (o *V2RevertTransactionResponse) GetData() V2Transaction { + if o == nil { + return V2Transaction{} + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2stats.go b/components/ledger/pkg/client/models/components/v2stats.go new file mode 100644 index 0000000000..fab3171ca4 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2stats.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" +) + +type V2Stats struct { + Accounts int64 `json:"accounts"` + Transactions *big.Int `json:"transactions"` +} + +func (v V2Stats) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2Stats) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2Stats) GetAccounts() int64 { + if o == nil { + return 0 + } + return o.Accounts +} + +func (o *V2Stats) GetTransactions() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Transactions +} diff --git a/components/ledger/pkg/client/models/components/v2statsresponse.go b/components/ledger/pkg/client/models/components/v2statsresponse.go new file mode 100644 index 0000000000..1242429ca2 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2statsresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2StatsResponse struct { + Data V2Stats `json:"data"` +} + +func (o *V2StatsResponse) GetData() V2Stats { + if o == nil { + return V2Stats{} + } + return o.Data +} diff --git a/components/ledger/pkg/client/models/components/v2targetid.go b/components/ledger/pkg/client/models/components/v2targetid.go new file mode 100644 index 0000000000..d6fbb53bd1 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2targetid.go @@ -0,0 +1,73 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "errors" + "fmt" + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" +) + +type V2TargetIDType string + +const ( + V2TargetIDTypeStr V2TargetIDType = "str" + V2TargetIDTypeBigint V2TargetIDType = "bigint" +) + +type V2TargetID struct { + Str *string + Bigint *big.Int + + Type V2TargetIDType +} + +func CreateV2TargetIDStr(str string) V2TargetID { + typ := V2TargetIDTypeStr + + return V2TargetID{ + Str: &str, + Type: typ, + } +} + +func CreateV2TargetIDBigint(bigint *big.Int) V2TargetID { + typ := V2TargetIDTypeBigint + + return V2TargetID{ + Bigint: bigint, + Type: typ, + } +} + +func (u *V2TargetID) UnmarshalJSON(data []byte) error { + + var str string = "" + if err := utils.UnmarshalJSON(data, &str, "", true, true); err == nil { + u.Str = &str + u.Type = V2TargetIDTypeStr + return nil + } + + var bigint *big.Int = big.NewInt(0) + if err := utils.UnmarshalJSON(data, &bigint, "", true, true); err == nil { + u.Bigint = bigint + u.Type = V2TargetIDTypeBigint + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for V2TargetID", string(data)) +} + +func (u V2TargetID) MarshalJSON() ([]byte, error) { + if u.Str != nil { + return utils.MarshalJSON(u.Str, "", true) + } + + if u.Bigint != nil { + return utils.MarshalJSON(u.Bigint, "", true) + } + + return nil, errors.New("could not marshal union type V2TargetID: all fields are null") +} diff --git a/components/ledger/pkg/client/models/components/v2targettype.go b/components/ledger/pkg/client/models/components/v2targettype.go new file mode 100644 index 0000000000..c5e16fb804 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2targettype.go @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" +) + +type V2TargetType string + +const ( + V2TargetTypeTransaction V2TargetType = "TRANSACTION" + V2TargetTypeAccount V2TargetType = "ACCOUNT" +) + +func (e V2TargetType) ToPointer() *V2TargetType { + return &e +} +func (e *V2TargetType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "TRANSACTION": + fallthrough + case "ACCOUNT": + *e = V2TargetType(v) + return nil + default: + return fmt.Errorf("invalid value for V2TargetType: %v", v) + } +} diff --git a/components/ledger/pkg/client/models/components/v2transaction.go b/components/ledger/pkg/client/models/components/v2transaction.go new file mode 100644 index 0000000000..fd1371ec70 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2transaction.go @@ -0,0 +1,71 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" + "time" +) + +type V2Transaction struct { + Timestamp time.Time `json:"timestamp"` + Postings []V2Posting `json:"postings"` + Reference *string `json:"reference,omitempty"` + Metadata map[string]string `json:"metadata"` + ID *big.Int `json:"id"` + Reverted bool `json:"reverted"` +} + +func (v V2Transaction) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2Transaction) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2Transaction) GetTimestamp() time.Time { + if o == nil { + return time.Time{} + } + return o.Timestamp +} + +func (o *V2Transaction) GetPostings() []V2Posting { + if o == nil { + return []V2Posting{} + } + return o.Postings +} + +func (o *V2Transaction) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *V2Transaction) GetMetadata() map[string]string { + if o == nil { + return map[string]string{} + } + return o.Metadata +} + +func (o *V2Transaction) GetID() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.ID +} + +func (o *V2Transaction) GetReverted() bool { + if o == nil { + return false + } + return o.Reverted +} diff --git a/components/ledger/pkg/client/models/components/v2transactionscursorresponse.go b/components/ledger/pkg/client/models/components/v2transactionscursorresponse.go new file mode 100644 index 0000000000..d6744db482 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2transactionscursorresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2TransactionsCursorResponseCursor struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitempty"` + Next *string `json:"next,omitempty"` + Data []V2ExpandedTransaction `json:"data"` +} + +func (o *V2TransactionsCursorResponseCursor) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *V2TransactionsCursorResponseCursor) GetHasMore() bool { + if o == nil { + return false + } + return o.HasMore +} + +func (o *V2TransactionsCursorResponseCursor) GetPrevious() *string { + if o == nil { + return nil + } + return o.Previous +} + +func (o *V2TransactionsCursorResponseCursor) GetNext() *string { + if o == nil { + return nil + } + return o.Next +} + +func (o *V2TransactionsCursorResponseCursor) GetData() []V2ExpandedTransaction { + if o == nil { + return []V2ExpandedTransaction{} + } + return o.Data +} + +type V2TransactionsCursorResponse struct { + Cursor V2TransactionsCursorResponseCursor `json:"cursor"` +} + +func (o *V2TransactionsCursorResponse) GetCursor() V2TransactionsCursorResponseCursor { + if o == nil { + return V2TransactionsCursorResponseCursor{} + } + return o.Cursor +} diff --git a/components/ledger/pkg/client/models/components/v2volume.go b/components/ledger/pkg/client/models/components/v2volume.go new file mode 100644 index 0000000000..fb8a374224 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2volume.go @@ -0,0 +1,46 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" +) + +type V2Volume struct { + Input *big.Int `json:"input"` + Output *big.Int `json:"output"` + Balance *big.Int `json:"balance,omitempty"` +} + +func (v V2Volume) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2Volume) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2Volume) GetInput() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Input +} + +func (o *V2Volume) GetOutput() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Output +} + +func (o *V2Volume) GetBalance() *big.Int { + if o == nil { + return nil + } + return o.Balance +} diff --git a/components/ledger/pkg/client/models/components/v2volumeswithbalance.go b/components/ledger/pkg/client/models/components/v2volumeswithbalance.go new file mode 100644 index 0000000000..dca503d0fc --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2volumeswithbalance.go @@ -0,0 +1,62 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" +) + +type V2VolumesWithBalance struct { + Account string `json:"account"` + Asset string `json:"asset"` + Input *big.Int `json:"input"` + Output *big.Int `json:"output"` + Balance *big.Int `json:"balance"` +} + +func (v V2VolumesWithBalance) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2VolumesWithBalance) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2VolumesWithBalance) GetAccount() string { + if o == nil { + return "" + } + return o.Account +} + +func (o *V2VolumesWithBalance) GetAsset() string { + if o == nil { + return "" + } + return o.Asset +} + +func (o *V2VolumesWithBalance) GetInput() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Input +} + +func (o *V2VolumesWithBalance) GetOutput() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Output +} + +func (o *V2VolumesWithBalance) GetBalance() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Balance +} diff --git a/components/ledger/pkg/client/models/components/v2volumeswithbalancecursorresponse.go b/components/ledger/pkg/client/models/components/v2volumeswithbalancecursorresponse.go new file mode 100644 index 0000000000..35e7a0afa1 --- /dev/null +++ b/components/ledger/pkg/client/models/components/v2volumeswithbalancecursorresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package components + +type V2VolumesWithBalanceCursorResponseCursor struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitempty"` + Next *string `json:"next,omitempty"` + Data []V2VolumesWithBalance `json:"data"` +} + +func (o *V2VolumesWithBalanceCursorResponseCursor) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *V2VolumesWithBalanceCursorResponseCursor) GetHasMore() bool { + if o == nil { + return false + } + return o.HasMore +} + +func (o *V2VolumesWithBalanceCursorResponseCursor) GetPrevious() *string { + if o == nil { + return nil + } + return o.Previous +} + +func (o *V2VolumesWithBalanceCursorResponseCursor) GetNext() *string { + if o == nil { + return nil + } + return o.Next +} + +func (o *V2VolumesWithBalanceCursorResponseCursor) GetData() []V2VolumesWithBalance { + if o == nil { + return []V2VolumesWithBalance{} + } + return o.Data +} + +type V2VolumesWithBalanceCursorResponse struct { + Cursor V2VolumesWithBalanceCursorResponseCursor `json:"cursor"` +} + +func (o *V2VolumesWithBalanceCursorResponse) GetCursor() V2VolumesWithBalanceCursorResponseCursor { + if o == nil { + return V2VolumesWithBalanceCursorResponseCursor{} + } + return o.Cursor +} diff --git a/components/ledger/pkg/client/models/operations/options.go b/components/ledger/pkg/client/models/operations/options.go new file mode 100644 index 0000000000..85fc63930e --- /dev/null +++ b/components/ledger/pkg/client/models/operations/options.go @@ -0,0 +1,116 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "errors" + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/retry" + "time" +) + +var ErrUnsupportedOption = errors.New("unsupported option") + +const ( + SupportedOptionServerURL = "serverURL" + SupportedOptionRetries = "retries" + SupportedOptionTimeout = "timeout" + SupportedOptionAcceptHeaderOverride = "acceptHeaderOverride" + SupportedOptionURLOverride = "urlOverride" +) + +type AcceptHeaderEnum string + +const ( + AcceptHeaderEnumApplicationJson AcceptHeaderEnum = "application/json" + AcceptHeaderEnumWildcardWildcard AcceptHeaderEnum = "*/*" +) + +func (e AcceptHeaderEnum) ToPointer() *AcceptHeaderEnum { + return &e +} + +type Options struct { + ServerURL *string + Retries *retry.Config + Timeout *time.Duration + AcceptHeaderOverride *AcceptHeaderEnum + URLOverride *string +} + +type Option func(*Options, ...string) error + +// WithServerURL allows providing an alternative server URL. +func WithServerURL(serverURL string) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionServerURL) { + return ErrUnsupportedOption + } + + opts.ServerURL = &serverURL + return nil + } +} + +// WithTemplatedServerURL allows providing an alternative server URL with templated parameters. +func WithTemplatedServerURL(serverURL string, params map[string]string) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionServerURL) { + return ErrUnsupportedOption + } + + if params != nil { + serverURL = utils.ReplaceParameters(serverURL, params) + } + + opts.ServerURL = &serverURL + return nil + } +} + +// WithRetries allows customizing the default retry configuration. +func WithRetries(config retry.Config) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionRetries) { + return ErrUnsupportedOption + } + + opts.Retries = &config + return nil + } +} + +// WithOperationTimeout allows setting the request timeout applied for an operation. +func WithOperationTimeout(timeout time.Duration) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionRetries) { + return ErrUnsupportedOption + } + + opts.Timeout = &timeout + return nil + } +} + +func WithAcceptHeaderOverride(acceptHeaderOverride AcceptHeaderEnum) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionAcceptHeaderOverride) { + return ErrUnsupportedOption + } + + opts.AcceptHeaderOverride = &acceptHeaderOverride + return nil + } +} + +// WithURLOverride allows overriding the URL. +func WithURLOverride(urlOverride string) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionURLOverride) { + return ErrUnsupportedOption + } + + opts.URLOverride = &urlOverride + return nil + } +} diff --git a/components/ledger/pkg/client/models/operations/v2addmetadataontransaction.go b/components/ledger/pkg/client/models/operations/v2addmetadataontransaction.go new file mode 100644 index 0000000000..ed2cdfa2e0 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2addmetadataontransaction.go @@ -0,0 +1,79 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "math/big" +) + +type V2AddMetadataOnTransactionRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Transaction ID. + ID *big.Int `pathParam:"style=simple,explode=false,name=id"` + // Set the dryRun mode. Dry run mode doesn't add the logs to the database or publish a message to the message broker. + DryRun *bool `queryParam:"style=form,explode=true,name=dryRun"` + // Use an idempotency key + IdempotencyKey *string `header:"style=simple,explode=false,name=Idempotency-Key"` + // metadata + RequestBody map[string]string `request:"mediaType=application/json"` +} + +func (v V2AddMetadataOnTransactionRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2AddMetadataOnTransactionRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2AddMetadataOnTransactionRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2AddMetadataOnTransactionRequest) GetID() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.ID +} + +func (o *V2AddMetadataOnTransactionRequest) GetDryRun() *bool { + if o == nil { + return nil + } + return o.DryRun +} + +func (o *V2AddMetadataOnTransactionRequest) GetIdempotencyKey() *string { + if o == nil { + return nil + } + return o.IdempotencyKey +} + +func (o *V2AddMetadataOnTransactionRequest) GetRequestBody() map[string]string { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2AddMetadataOnTransactionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` +} + +func (o *V2AddMetadataOnTransactionResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/components/ledger/pkg/client/models/operations/v2addmetadatatoaccount.go b/components/ledger/pkg/client/models/operations/v2addmetadatatoaccount.go new file mode 100644 index 0000000000..488ca4eff6 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2addmetadatatoaccount.go @@ -0,0 +1,70 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2AddMetadataToAccountRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Exact address of the account. It must match the following regular expressions pattern: + // ``` + // ^\w+(:\w+)*$ + // ``` + // + Address string `pathParam:"style=simple,explode=false,name=address"` + // Set the dry run mode. Dry run mode doesn't add the logs to the database or publish a message to the message broker. + DryRun *bool `queryParam:"style=form,explode=true,name=dryRun"` + // Use an idempotency key + IdempotencyKey *string `header:"style=simple,explode=false,name=Idempotency-Key"` + // metadata + RequestBody map[string]string `request:"mediaType=application/json"` +} + +func (o *V2AddMetadataToAccountRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2AddMetadataToAccountRequest) GetAddress() string { + if o == nil { + return "" + } + return o.Address +} + +func (o *V2AddMetadataToAccountRequest) GetDryRun() *bool { + if o == nil { + return nil + } + return o.DryRun +} + +func (o *V2AddMetadataToAccountRequest) GetIdempotencyKey() *string { + if o == nil { + return nil + } + return o.IdempotencyKey +} + +func (o *V2AddMetadataToAccountRequest) GetRequestBody() map[string]string { + if o == nil { + return map[string]string{} + } + return o.RequestBody +} + +type V2AddMetadataToAccountResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` +} + +func (o *V2AddMetadataToAccountResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/components/ledger/pkg/client/models/operations/v2countaccounts.go b/components/ledger/pkg/client/models/operations/v2countaccounts.go new file mode 100644 index 0000000000..e3338f5f07 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2countaccounts.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +type V2CountAccountsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + Pit *time.Time `queryParam:"style=form,explode=true,name=pit"` + RequestBody map[string]any `request:"mediaType=application/json"` +} + +func (v V2CountAccountsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2CountAccountsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2CountAccountsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2CountAccountsRequest) GetPit() *time.Time { + if o == nil { + return nil + } + return o.Pit +} + +func (o *V2CountAccountsRequest) GetRequestBody() map[string]any { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2CountAccountsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + Headers map[string][]string +} + +func (o *V2CountAccountsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2CountAccountsResponse) GetHeaders() map[string][]string { + if o == nil { + return map[string][]string{} + } + return o.Headers +} diff --git a/components/ledger/pkg/client/models/operations/v2counttransactions.go b/components/ledger/pkg/client/models/operations/v2counttransactions.go new file mode 100644 index 0000000000..b8d04f0777 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2counttransactions.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +type V2CountTransactionsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + Pit *time.Time `queryParam:"style=form,explode=true,name=pit"` + RequestBody map[string]any `request:"mediaType=application/json"` +} + +func (v V2CountTransactionsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2CountTransactionsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2CountTransactionsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2CountTransactionsRequest) GetPit() *time.Time { + if o == nil { + return nil + } + return o.Pit +} + +func (o *V2CountTransactionsRequest) GetRequestBody() map[string]any { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2CountTransactionsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + Headers map[string][]string +} + +func (o *V2CountTransactionsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2CountTransactionsResponse) GetHeaders() map[string][]string { + if o == nil { + return map[string][]string{} + } + return o.Headers +} diff --git a/components/ledger/pkg/client/models/operations/v2createbulk.go b/components/ledger/pkg/client/models/operations/v2createbulk.go new file mode 100644 index 0000000000..c66e0e8252 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2createbulk.go @@ -0,0 +1,47 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2CreateBulkRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + RequestBody []components.V2BulkElement `request:"mediaType=application/json"` +} + +func (o *V2CreateBulkRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2CreateBulkRequest) GetRequestBody() []components.V2BulkElement { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2CreateBulkResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2BulkResponse *components.V2BulkResponse +} + +func (o *V2CreateBulkResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2CreateBulkResponse) GetV2BulkResponse() *components.V2BulkResponse { + if o == nil { + return nil + } + return o.V2BulkResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2createledger.go b/components/ledger/pkg/client/models/operations/v2createledger.go new file mode 100644 index 0000000000..dcad13ceb7 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2createledger.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2CreateLedgerRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + V2CreateLedgerRequest *components.V2CreateLedgerRequest `request:"mediaType=application/json"` +} + +func (o *V2CreateLedgerRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2CreateLedgerRequest) GetV2CreateLedgerRequest() *components.V2CreateLedgerRequest { + if o == nil { + return nil + } + return o.V2CreateLedgerRequest +} + +type V2CreateLedgerResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` +} + +func (o *V2CreateLedgerResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/components/ledger/pkg/client/models/operations/v2createtransaction.go b/components/ledger/pkg/client/models/operations/v2createtransaction.go new file mode 100644 index 0000000000..d0877f3a31 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2createtransaction.go @@ -0,0 +1,69 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2CreateTransactionRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Set the dryRun mode. dry run mode doesn't add the logs to the database or publish a message to the message broker. + DryRun *bool `queryParam:"style=form,explode=true,name=dryRun"` + // Use an idempotency key + IdempotencyKey *string `header:"style=simple,explode=false,name=Idempotency-Key"` + // The request body must contain at least one of the following objects: + // - `postings`: suitable for simple transactions + // - `script`: enabling more complex transactions with Numscript + // + V2PostTransaction components.V2PostTransaction `request:"mediaType=application/json"` +} + +func (o *V2CreateTransactionRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2CreateTransactionRequest) GetDryRun() *bool { + if o == nil { + return nil + } + return o.DryRun +} + +func (o *V2CreateTransactionRequest) GetIdempotencyKey() *string { + if o == nil { + return nil + } + return o.IdempotencyKey +} + +func (o *V2CreateTransactionRequest) GetV2PostTransaction() components.V2PostTransaction { + if o == nil { + return components.V2PostTransaction{} + } + return o.V2PostTransaction +} + +type V2CreateTransactionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2CreateTransactionResponse *components.V2CreateTransactionResponse +} + +func (o *V2CreateTransactionResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2CreateTransactionResponse) GetV2CreateTransactionResponse() *components.V2CreateTransactionResponse { + if o == nil { + return nil + } + return o.V2CreateTransactionResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2deleteaccountmetadata.go b/components/ledger/pkg/client/models/operations/v2deleteaccountmetadata.go new file mode 100644 index 0000000000..f879e039f0 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2deleteaccountmetadata.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2DeleteAccountMetadataRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Account address + Address string `pathParam:"style=simple,explode=false,name=address"` + // The key to remove. + Key string `pathParam:"style=simple,explode=false,name=key"` +} + +func (o *V2DeleteAccountMetadataRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2DeleteAccountMetadataRequest) GetAddress() string { + if o == nil { + return "" + } + return o.Address +} + +func (o *V2DeleteAccountMetadataRequest) GetKey() string { + if o == nil { + return "" + } + return o.Key +} + +type V2DeleteAccountMetadataResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` +} + +func (o *V2DeleteAccountMetadataResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/components/ledger/pkg/client/models/operations/v2deleteledgermetadata.go b/components/ledger/pkg/client/models/operations/v2deleteledgermetadata.go new file mode 100644 index 0000000000..95c965fa63 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2deleteledgermetadata.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2DeleteLedgerMetadataRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Key to remove. + Key string `pathParam:"style=simple,explode=false,name=key"` +} + +func (o *V2DeleteLedgerMetadataRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2DeleteLedgerMetadataRequest) GetKey() string { + if o == nil { + return "" + } + return o.Key +} + +type V2DeleteLedgerMetadataResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` +} + +func (o *V2DeleteLedgerMetadataResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/components/ledger/pkg/client/models/operations/v2deletetransactionmetadata.go b/components/ledger/pkg/client/models/operations/v2deletetransactionmetadata.go new file mode 100644 index 0000000000..8afabd9bcd --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2deletetransactionmetadata.go @@ -0,0 +1,61 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "math/big" +) + +type V2DeleteTransactionMetadataRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Transaction ID. + ID *big.Int `pathParam:"style=simple,explode=false,name=id"` + // The key to remove. + Key string `pathParam:"style=simple,explode=false,name=key"` +} + +func (v V2DeleteTransactionMetadataRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2DeleteTransactionMetadataRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2DeleteTransactionMetadataRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2DeleteTransactionMetadataRequest) GetID() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.ID +} + +func (o *V2DeleteTransactionMetadataRequest) GetKey() string { + if o == nil { + return "" + } + return o.Key +} + +type V2DeleteTransactionMetadataResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` +} + +func (o *V2DeleteTransactionMetadataResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/components/ledger/pkg/client/models/operations/v2exportlogs.go b/components/ledger/pkg/client/models/operations/v2exportlogs.go new file mode 100644 index 0000000000..d809a63d59 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2exportlogs.go @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2ExportLogsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` +} + +func (o *V2ExportLogsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +type V2ExportLogsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` +} + +func (o *V2ExportLogsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/components/ledger/pkg/client/models/operations/v2getaccount.go b/components/ledger/pkg/client/models/operations/v2getaccount.go new file mode 100644 index 0000000000..fe39e1406c --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2getaccount.go @@ -0,0 +1,81 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +type V2GetAccountRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Exact address of the account. It must match the following regular expressions pattern: + // ``` + // ^\w+(:\w+)*$ + // ``` + // + Address string `pathParam:"style=simple,explode=false,name=address"` + Expand *string `queryParam:"style=form,explode=true,name=expand"` + Pit *time.Time `queryParam:"style=form,explode=true,name=pit"` +} + +func (v V2GetAccountRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2GetAccountRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2GetAccountRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2GetAccountRequest) GetAddress() string { + if o == nil { + return "" + } + return o.Address +} + +func (o *V2GetAccountRequest) GetExpand() *string { + if o == nil { + return nil + } + return o.Expand +} + +func (o *V2GetAccountRequest) GetPit() *time.Time { + if o == nil { + return nil + } + return o.Pit +} + +type V2GetAccountResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2AccountResponse *components.V2AccountResponse +} + +func (o *V2GetAccountResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2GetAccountResponse) GetV2AccountResponse() *components.V2AccountResponse { + if o == nil { + return nil + } + return o.V2AccountResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2getbalancesaggregated.go b/components/ledger/pkg/client/models/operations/v2getbalancesaggregated.go new file mode 100644 index 0000000000..246e207ab8 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2getbalancesaggregated.go @@ -0,0 +1,77 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +type V2GetBalancesAggregatedRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + Pit *time.Time `queryParam:"style=form,explode=true,name=pit"` + // Use insertion date instead of effective date + UseInsertionDate *bool `queryParam:"style=form,explode=true,name=useInsertionDate"` + RequestBody map[string]any `request:"mediaType=application/json"` +} + +func (v V2GetBalancesAggregatedRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2GetBalancesAggregatedRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2GetBalancesAggregatedRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2GetBalancesAggregatedRequest) GetPit() *time.Time { + if o == nil { + return nil + } + return o.Pit +} + +func (o *V2GetBalancesAggregatedRequest) GetUseInsertionDate() *bool { + if o == nil { + return nil + } + return o.UseInsertionDate +} + +func (o *V2GetBalancesAggregatedRequest) GetRequestBody() map[string]any { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2GetBalancesAggregatedResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2AggregateBalancesResponse *components.V2AggregateBalancesResponse +} + +func (o *V2GetBalancesAggregatedResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2GetBalancesAggregatedResponse) GetV2AggregateBalancesResponse() *components.V2AggregateBalancesResponse { + if o == nil { + return nil + } + return o.V2AggregateBalancesResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2getinfo.go b/components/ledger/pkg/client/models/operations/v2getinfo.go new file mode 100644 index 0000000000..b0d35667e1 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2getinfo.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" + "github.com/formancehq/stack/ledger/client/models/sdkerrors" +) + +type V2GetInfoResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2ConfigInfoResponse *components.V2ConfigInfoResponse + // Error + V2ErrorResponse *sdkerrors.V2ErrorResponse +} + +func (o *V2GetInfoResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2GetInfoResponse) GetV2ConfigInfoResponse() *components.V2ConfigInfoResponse { + if o == nil { + return nil + } + return o.V2ConfigInfoResponse +} + +func (o *V2GetInfoResponse) GetV2ErrorResponse() *sdkerrors.V2ErrorResponse { + if o == nil { + return nil + } + return o.V2ErrorResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2getledger.go b/components/ledger/pkg/client/models/operations/v2getledger.go new file mode 100644 index 0000000000..55ae63db65 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2getledger.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2GetLedgerRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` +} + +func (o *V2GetLedgerRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +type V2GetLedgerResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2GetLedgerResponse *components.V2GetLedgerResponse +} + +func (o *V2GetLedgerResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2GetLedgerResponse) GetV2GetLedgerResponse() *components.V2GetLedgerResponse { + if o == nil { + return nil + } + return o.V2GetLedgerResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2getledgerinfo.go b/components/ledger/pkg/client/models/operations/v2getledgerinfo.go new file mode 100644 index 0000000000..6f4a731d1a --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2getledgerinfo.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2GetLedgerInfoRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` +} + +func (o *V2GetLedgerInfoRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +type V2GetLedgerInfoResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2LedgerInfoResponse *components.V2LedgerInfoResponse +} + +func (o *V2GetLedgerInfoResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2GetLedgerInfoResponse) GetV2LedgerInfoResponse() *components.V2LedgerInfoResponse { + if o == nil { + return nil + } + return o.V2LedgerInfoResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2gettransaction.go b/components/ledger/pkg/client/models/operations/v2gettransaction.go new file mode 100644 index 0000000000..41374e832d --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2gettransaction.go @@ -0,0 +1,78 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "math/big" + "time" +) + +type V2GetTransactionRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Transaction ID. + ID *big.Int `pathParam:"style=simple,explode=false,name=id"` + Expand *string `queryParam:"style=form,explode=true,name=expand"` + Pit *time.Time `queryParam:"style=form,explode=true,name=pit"` +} + +func (v V2GetTransactionRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2GetTransactionRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2GetTransactionRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2GetTransactionRequest) GetID() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.ID +} + +func (o *V2GetTransactionRequest) GetExpand() *string { + if o == nil { + return nil + } + return o.Expand +} + +func (o *V2GetTransactionRequest) GetPit() *time.Time { + if o == nil { + return nil + } + return o.Pit +} + +type V2GetTransactionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2GetTransactionResponse *components.V2GetTransactionResponse +} + +func (o *V2GetTransactionResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2GetTransactionResponse) GetV2GetTransactionResponse() *components.V2GetTransactionResponse { + if o == nil { + return nil + } + return o.V2GetTransactionResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2getvolumeswithbalances.go b/components/ledger/pkg/client/models/operations/v2getvolumeswithbalances.go new file mode 100644 index 0000000000..f16a8e9554 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2getvolumeswithbalances.go @@ -0,0 +1,117 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +type V2GetVolumesWithBalancesRequest struct { + // The maximum number of results to return per page. + // + PageSize *int64 `queryParam:"style=form,explode=true,name=pageSize"` + // Parameter used in pagination requests. Maximum page size is set to 15. + // Set to the value of next for the next page of results. + // Set to the value of previous for the previous page of results. + // No other parameters can be set when this parameter is set. + // + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + EndTime *time.Time `queryParam:"style=form,explode=true,name=endTime"` + StartTime *time.Time `queryParam:"style=form,explode=true,name=startTime"` + // Use insertion date instead of effective date + InsertionDate *bool `queryParam:"style=form,explode=true,name=insertionDate"` + // Group volumes and balance by the level of the segment of the address + GroupBy *int64 `queryParam:"style=form,explode=true,name=groupBy"` + RequestBody map[string]any `request:"mediaType=application/json"` +} + +func (v V2GetVolumesWithBalancesRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2GetVolumesWithBalancesRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2GetVolumesWithBalancesRequest) GetPageSize() *int64 { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *V2GetVolumesWithBalancesRequest) GetCursor() *string { + if o == nil { + return nil + } + return o.Cursor +} + +func (o *V2GetVolumesWithBalancesRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2GetVolumesWithBalancesRequest) GetEndTime() *time.Time { + if o == nil { + return nil + } + return o.EndTime +} + +func (o *V2GetVolumesWithBalancesRequest) GetStartTime() *time.Time { + if o == nil { + return nil + } + return o.StartTime +} + +func (o *V2GetVolumesWithBalancesRequest) GetInsertionDate() *bool { + if o == nil { + return nil + } + return o.InsertionDate +} + +func (o *V2GetVolumesWithBalancesRequest) GetGroupBy() *int64 { + if o == nil { + return nil + } + return o.GroupBy +} + +func (o *V2GetVolumesWithBalancesRequest) GetRequestBody() map[string]any { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2GetVolumesWithBalancesResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2VolumesWithBalanceCursorResponse *components.V2VolumesWithBalanceCursorResponse +} + +func (o *V2GetVolumesWithBalancesResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2GetVolumesWithBalancesResponse) GetV2VolumesWithBalanceCursorResponse() *components.V2VolumesWithBalanceCursorResponse { + if o == nil { + return nil + } + return o.V2VolumesWithBalanceCursorResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2importlogs.go b/components/ledger/pkg/client/models/operations/v2importlogs.go new file mode 100644 index 0000000000..ba8760967e --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2importlogs.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2ImportLogsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + RequestBody *string `request:"mediaType=application/octet-stream"` +} + +func (o *V2ImportLogsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2ImportLogsRequest) GetRequestBody() *string { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2ImportLogsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` +} + +func (o *V2ImportLogsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/components/ledger/pkg/client/models/operations/v2listaccounts.go b/components/ledger/pkg/client/models/operations/v2listaccounts.go new file mode 100644 index 0000000000..85162a159e --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2listaccounts.go @@ -0,0 +1,99 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +type V2ListAccountsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // The maximum number of results to return per page. + // + PageSize *int64 `queryParam:"style=form,explode=true,name=pageSize"` + // Parameter used in pagination requests. Maximum page size is set to 15. + // Set to the value of next for the next page of results. + // Set to the value of previous for the previous page of results. + // No other parameters can be set when this parameter is set. + // + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` + Expand *string `queryParam:"style=form,explode=true,name=expand"` + Pit *time.Time `queryParam:"style=form,explode=true,name=pit"` + RequestBody map[string]any `request:"mediaType=application/json"` +} + +func (v V2ListAccountsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2ListAccountsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2ListAccountsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2ListAccountsRequest) GetPageSize() *int64 { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *V2ListAccountsRequest) GetCursor() *string { + if o == nil { + return nil + } + return o.Cursor +} + +func (o *V2ListAccountsRequest) GetExpand() *string { + if o == nil { + return nil + } + return o.Expand +} + +func (o *V2ListAccountsRequest) GetPit() *time.Time { + if o == nil { + return nil + } + return o.Pit +} + +func (o *V2ListAccountsRequest) GetRequestBody() map[string]any { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2ListAccountsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2AccountsCursorResponse *components.V2AccountsCursorResponse +} + +func (o *V2ListAccountsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2ListAccountsResponse) GetV2AccountsCursorResponse() *components.V2AccountsCursorResponse { + if o == nil { + return nil + } + return o.V2AccountsCursorResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2listledgers.go b/components/ledger/pkg/client/models/operations/v2listledgers.go new file mode 100644 index 0000000000..30eac55525 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2listledgers.go @@ -0,0 +1,53 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2ListLedgersRequest struct { + // The maximum number of results to return per page. + // + PageSize *int64 `queryParam:"style=form,explode=true,name=pageSize"` + // Parameter used in pagination requests. Maximum page size is set to 15. + // Set to the value of next for the next page of results. + // Set to the value of previous for the previous page of results. + // No other parameters can be set when this parameter is set. + // + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` +} + +func (o *V2ListLedgersRequest) GetPageSize() *int64 { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *V2ListLedgersRequest) GetCursor() *string { + if o == nil { + return nil + } + return o.Cursor +} + +type V2ListLedgersResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2LedgerListResponse *components.V2LedgerListResponse +} + +func (o *V2ListLedgersResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2ListLedgersResponse) GetV2LedgerListResponse() *components.V2LedgerListResponse { + if o == nil { + return nil + } + return o.V2LedgerListResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2listlogs.go b/components/ledger/pkg/client/models/operations/v2listlogs.go new file mode 100644 index 0000000000..ac959703f6 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2listlogs.go @@ -0,0 +1,91 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +type V2ListLogsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // The maximum number of results to return per page. + // + PageSize *int64 `queryParam:"style=form,explode=true,name=pageSize"` + // Parameter used in pagination requests. Maximum page size is set to 15. + // Set to the value of next for the next page of results. + // Set to the value of previous for the previous page of results. + // No other parameters can be set when this parameter is set. + // + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` + Pit *time.Time `queryParam:"style=form,explode=true,name=pit"` + RequestBody map[string]any `request:"mediaType=application/json"` +} + +func (v V2ListLogsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2ListLogsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2ListLogsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2ListLogsRequest) GetPageSize() *int64 { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *V2ListLogsRequest) GetCursor() *string { + if o == nil { + return nil + } + return o.Cursor +} + +func (o *V2ListLogsRequest) GetPit() *time.Time { + if o == nil { + return nil + } + return o.Pit +} + +func (o *V2ListLogsRequest) GetRequestBody() map[string]any { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2ListLogsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2LogsCursorResponse *components.V2LogsCursorResponse +} + +func (o *V2ListLogsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2ListLogsResponse) GetV2LogsCursorResponse() *components.V2LogsCursorResponse { + if o == nil { + return nil + } + return o.V2LogsCursorResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2listtransactions.go b/components/ledger/pkg/client/models/operations/v2listtransactions.go new file mode 100644 index 0000000000..68164b1d11 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2listtransactions.go @@ -0,0 +1,140 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "encoding/json" + "fmt" + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +type Order string + +const ( + OrderEffective Order = "effective" +) + +func (e Order) ToPointer() *Order { + return &e +} +func (e *Order) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "effective": + *e = Order(v) + return nil + default: + return fmt.Errorf("invalid value for Order: %v", v) + } +} + +type V2ListTransactionsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // The maximum number of results to return per page. + // + PageSize *int64 `queryParam:"style=form,explode=true,name=pageSize"` + // Parameter used in pagination requests. Maximum page size is set to 15. + // Set to the value of next for the next page of results. + // Set to the value of previous for the previous page of results. + // No other parameters can be set when this parameter is set. + // + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` + Expand *string `queryParam:"style=form,explode=true,name=expand"` + Pit *time.Time `queryParam:"style=form,explode=true,name=pit"` + Order *Order `queryParam:"style=form,explode=true,name=order"` + Reverse *bool `queryParam:"style=form,explode=true,name=reverse"` + RequestBody map[string]any `request:"mediaType=application/json"` +} + +func (v V2ListTransactionsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2ListTransactionsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2ListTransactionsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2ListTransactionsRequest) GetPageSize() *int64 { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *V2ListTransactionsRequest) GetCursor() *string { + if o == nil { + return nil + } + return o.Cursor +} + +func (o *V2ListTransactionsRequest) GetExpand() *string { + if o == nil { + return nil + } + return o.Expand +} + +func (o *V2ListTransactionsRequest) GetPit() *time.Time { + if o == nil { + return nil + } + return o.Pit +} + +func (o *V2ListTransactionsRequest) GetOrder() *Order { + if o == nil { + return nil + } + return o.Order +} + +func (o *V2ListTransactionsRequest) GetReverse() *bool { + if o == nil { + return nil + } + return o.Reverse +} + +func (o *V2ListTransactionsRequest) GetRequestBody() map[string]any { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2ListTransactionsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2TransactionsCursorResponse *components.V2TransactionsCursorResponse +} + +func (o *V2ListTransactionsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2ListTransactionsResponse) GetV2TransactionsCursorResponse() *components.V2TransactionsCursorResponse { + if o == nil { + return nil + } + return o.V2TransactionsCursorResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2readstats.go b/components/ledger/pkg/client/models/operations/v2readstats.go new file mode 100644 index 0000000000..8047b44bb3 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2readstats.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type V2ReadStatsRequest struct { + // name of the ledger + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` +} + +func (o *V2ReadStatsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +type V2ReadStatsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2StatsResponse *components.V2StatsResponse +} + +func (o *V2ReadStatsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2ReadStatsResponse) GetV2StatsResponse() *components.V2StatsResponse { + if o == nil { + return nil + } + return o.V2StatsResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2reverttransaction.go b/components/ledger/pkg/client/models/operations/v2reverttransaction.go new file mode 100644 index 0000000000..d5d9e992cb --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2reverttransaction.go @@ -0,0 +1,79 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "math/big" +) + +type V2RevertTransactionRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Transaction ID. + ID *big.Int `pathParam:"style=simple,explode=false,name=id"` + // Force revert + Force *bool `queryParam:"style=form,explode=true,name=force"` + // Revert transaction at effective date of the original tx + AtEffectiveDate *bool `queryParam:"style=form,explode=true,name=atEffectiveDate"` +} + +func (v V2RevertTransactionRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *V2RevertTransactionRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *V2RevertTransactionRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2RevertTransactionRequest) GetID() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.ID +} + +func (o *V2RevertTransactionRequest) GetForce() *bool { + if o == nil { + return nil + } + return o.Force +} + +func (o *V2RevertTransactionRequest) GetAtEffectiveDate() *bool { + if o == nil { + return nil + } + return o.AtEffectiveDate +} + +type V2RevertTransactionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + V2RevertTransactionResponse *components.V2RevertTransactionResponse +} + +func (o *V2RevertTransactionResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2RevertTransactionResponse) GetV2RevertTransactionResponse() *components.V2RevertTransactionResponse { + if o == nil { + return nil + } + return o.V2RevertTransactionResponse +} diff --git a/components/ledger/pkg/client/models/operations/v2updateledgermetadata.go b/components/ledger/pkg/client/models/operations/v2updateledgermetadata.go new file mode 100644 index 0000000000..aa5c6db141 --- /dev/null +++ b/components/ledger/pkg/client/models/operations/v2updateledgermetadata.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" + "github.com/formancehq/stack/ledger/client/models/sdkerrors" +) + +type V2UpdateLedgerMetadataRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + RequestBody map[string]string `request:"mediaType=application/json"` +} + +func (o *V2UpdateLedgerMetadataRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *V2UpdateLedgerMetadataRequest) GetRequestBody() map[string]string { + if o == nil { + return nil + } + return o.RequestBody +} + +type V2UpdateLedgerMetadataResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + V2ErrorResponse *sdkerrors.V2ErrorResponse +} + +func (o *V2UpdateLedgerMetadataResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V2UpdateLedgerMetadataResponse) GetV2ErrorResponse() *sdkerrors.V2ErrorResponse { + if o == nil { + return nil + } + return o.V2ErrorResponse +} diff --git a/components/ledger/pkg/client/models/sdkerrors/sdkerror.go b/components/ledger/pkg/client/models/sdkerrors/sdkerror.go new file mode 100644 index 0000000000..b72f471b2b --- /dev/null +++ b/components/ledger/pkg/client/models/sdkerrors/sdkerror.go @@ -0,0 +1,35 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package sdkerrors + +import ( + "fmt" + "net/http" +) + +type SDKError struct { + Message string + StatusCode int + Body string + RawResponse *http.Response +} + +var _ error = &SDKError{} + +func NewSDKError(message string, statusCode int, body string, httpRes *http.Response) *SDKError { + return &SDKError{ + Message: message, + StatusCode: statusCode, + Body: body, + RawResponse: httpRes, + } +} + +func (e *SDKError) Error() string { + body := "" + if len(e.Body) > 0 { + body = fmt.Sprintf("\n%s", e.Body) + } + + return fmt.Sprintf("%s: Status %d%s", e.Message, e.StatusCode, body) +} diff --git a/components/ledger/pkg/client/models/sdkerrors/v2errorresponse.go b/components/ledger/pkg/client/models/sdkerrors/v2errorresponse.go new file mode 100644 index 0000000000..15e9fc1c78 --- /dev/null +++ b/components/ledger/pkg/client/models/sdkerrors/v2errorresponse.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package sdkerrors + +import ( + "encoding/json" + "github.com/formancehq/stack/ledger/client/models/components" +) + +// V2ErrorResponse - Error +type V2ErrorResponse struct { + ErrorCode components.V2ErrorsEnum `json:"errorCode"` + ErrorMessage string `json:"errorMessage"` + Details *string `json:"details,omitempty"` +} + +var _ error = &V2ErrorResponse{} + +func (e *V2ErrorResponse) Error() string { + data, _ := json.Marshal(e) + return string(data) +} diff --git a/components/ledger/pkg/client/retry/config.go b/components/ledger/pkg/client/retry/config.go new file mode 100644 index 0000000000..a9b559bc37 --- /dev/null +++ b/components/ledger/pkg/client/retry/config.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package retry + +type BackoffStrategy struct { + InitialInterval int + MaxInterval int + Exponent float64 + MaxElapsedTime int +} + +type Config struct { + Strategy string + Backoff *BackoffStrategy + RetryConnectionErrors bool +} diff --git a/components/ledger/pkg/client/types/bigint.go b/components/ledger/pkg/client/types/bigint.go new file mode 100644 index 0000000000..4765ef2028 --- /dev/null +++ b/components/ledger/pkg/client/types/bigint.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package types + +import ( + "fmt" + "math/big" +) + +// MustNewBigIntFromString returns an instance of big.Int from a string +// The string is assumed to be base 10 and if it is not a valid big.Int +// then the function panics. +// Avoid using this function in production code. +func MustNewBigIntFromString(s string) *big.Int { + i, ok := new(big.Int).SetString(s, 10) + if !ok { + panic(fmt.Errorf("failed to parse string as big.Int")) + } + + return i +} diff --git a/components/ledger/pkg/client/types/date.go b/components/ledger/pkg/client/types/date.go new file mode 100644 index 0000000000..131f364d53 --- /dev/null +++ b/components/ledger/pkg/client/types/date.go @@ -0,0 +1,90 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package types + +import ( + "encoding/json" + "fmt" + "strings" + "time" +) + +// Date is a wrapper around time.Time that allows for JSON marshaling a date string formatted as "2006-01-02". +type Date struct { + time.Time +} + +var ( + _ json.Marshaler = &Date{} + _ json.Unmarshaler = &Date{} + _ fmt.Stringer = &Date{} +) + +// NewDate returns an instance of Date from a time.Time. +func NewDate(t time.Time) *Date { + d := DateFromTime(t) + return &d +} + +// DateFromTime returns a Date from a time.Time. +func DateFromTime(t time.Time) Date { + return Date{t} +} + +// NewDateFromString returns an instance of Date from a string formatted as "2006-01-02". +func NewDateFromString(str string) (*Date, error) { + d, err := DateFromString(str) + if err != nil { + return nil, err + } + + return &d, nil +} + +// DateFromString returns a Date from a string formatted as "2006-01-02". +func DateFromString(str string) (Date, error) { + var d Date + var err error + + d.Time, err = time.Parse("2006-01-02", str) + return d, err +} + +// MustNewDateFromString returns an instance of Date from a string formatted as "2006-01-02" or panics. +// Avoid using this function in production code. +func MustNewDateFromString(str string) *Date { + d := MustDateFromString(str) + return &d +} + +// MustDateFromString returns a Date from a string formatted as "2006-01-02" or panics. +// Avoid using this function in production code. +func MustDateFromString(str string) Date { + d, err := DateFromString(str) + if err != nil { + panic(err) + } + return d +} + +func (d Date) GetTime() time.Time { + return d.Time +} + +func (d Date) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf(`"%s"`, d.Time.Format("2006-01-02"))), nil +} + +func (d *Date) UnmarshalJSON(data []byte) error { + var err error + + str := string(data) + str = strings.Trim(str, `"`) + + d.Time, err = time.Parse("2006-01-02", str) + return err +} + +func (d Date) String() string { + return d.Time.Format("2006-01-02") +} diff --git a/components/ledger/pkg/client/types/datetime.go b/components/ledger/pkg/client/types/datetime.go new file mode 100644 index 0000000000..c07ddcd514 --- /dev/null +++ b/components/ledger/pkg/client/types/datetime.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package types + +import "time" + +// MustTimeFromString returns a time.Time from a string formatted as "2006-01-02T15:04:05Z07:00" or panics. +// Avoid using this function in production code. +func MustTimeFromString(str string) time.Time { + t, err := time.Parse(time.RFC3339, str) + if err != nil { + panic(err) + } + + return t +} + +// MustNewTimeFromString returns an instance of time.Time from a string formatted as "2006-01-02T15:04:05Z07:00" or panics. +// Avoid using this function in production code. +func MustNewTimeFromString(str string) *time.Time { + t := MustTimeFromString(str) + return &t +} diff --git a/components/ledger/pkg/client/types/decimal.go b/components/ledger/pkg/client/types/decimal.go new file mode 100644 index 0000000000..f7def72891 --- /dev/null +++ b/components/ledger/pkg/client/types/decimal.go @@ -0,0 +1,20 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package types + +import ( + "fmt" + + "github.com/ericlagergren/decimal" +) + +// MustNewDecimalFromString returns an instance of Decimal from a string +// Avoid using this function in production code. +func MustNewDecimalFromString(s string) *decimal.Big { + d, ok := new(decimal.Big).SetString(s) + if !ok { + panic(fmt.Errorf("failed to parse string as decimal.Big")) + } + + return d +} diff --git a/components/ledger/pkg/client/types/pointers.go b/components/ledger/pkg/client/types/pointers.go new file mode 100644 index 0000000000..1ed80cfbbb --- /dev/null +++ b/components/ledger/pkg/client/types/pointers.go @@ -0,0 +1,10 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package types + +func String(s string) *string { return &s } +func Bool(b bool) *bool { return &b } +func Int(i int) *int { return &i } +func Int64(i int64) *int64 { return &i } +func Float32(f float32) *float32 { return &f } +func Float64(f float64) *float64 { return &f } diff --git a/components/ledger/pkg/client/v2.go b/components/ledger/pkg/client/v2.go new file mode 100644 index 0000000000..72a655ac6b --- /dev/null +++ b/components/ledger/pkg/client/v2.go @@ -0,0 +1,4735 @@ +// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. + +package client + +import ( + "bytes" + "context" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/formancehq/stack/ledger/client/internal/hooks" + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "github.com/formancehq/stack/ledger/client/models/operations" + "github.com/formancehq/stack/ledger/client/models/sdkerrors" + "io" + "math/big" + "net/http" + "net/url" + "time" +) + +type V2 struct { + sdkConfiguration sdkConfiguration +} + +func newV2(sdkConfig sdkConfiguration) *V2 { + return &V2{ + sdkConfiguration: sdkConfig, + } +} + +// GetInfo - Show server information +func (s *V2) GetInfo(ctx context.Context, opts ...operations.Option) (*operations.V2GetInfoResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2GetInfo", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/v2/_info") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2GetInfoResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2ConfigInfoResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2ConfigInfoResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2ErrorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListLedgers - List ledgers +func (s *V2) ListLedgers(ctx context.Context, pageSize *int64, cursor *string, opts ...operations.Option) (*operations.V2ListLedgersResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2ListLedgers", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2ListLedgersRequest{ + PageSize: pageSize, + Cursor: cursor, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/v2") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2ListLedgersResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2LedgerListResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2LedgerListResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetLedger - Get a ledger +func (s *V2) GetLedger(ctx context.Context, ledger string, opts ...operations.Option) (*operations.V2GetLedgerResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2GetLedger", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2GetLedgerRequest{ + Ledger: ledger, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2GetLedgerResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2GetLedgerResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2GetLedgerResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateLedger - Create a ledger +func (s *V2) CreateLedger(ctx context.Context, ledger string, v2CreateLedgerRequest *components.V2CreateLedgerRequest, opts ...operations.Option) (*operations.V2CreateLedgerResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2CreateLedger", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2CreateLedgerRequest{ + Ledger: ledger, + V2CreateLedgerRequest: v2CreateLedgerRequest, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "V2CreateLedgerRequest", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2CreateLedgerResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// UpdateLedgerMetadata - Update ledger metadata +func (s *V2) UpdateLedgerMetadata(ctx context.Context, ledger string, requestBody map[string]string, opts ...operations.Option) (*operations.V2UpdateLedgerMetadataResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2UpdateLedgerMetadata", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2UpdateLedgerMetadataRequest{ + Ledger: ledger, + RequestBody: requestBody, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/metadata", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2UpdateLedgerMetadataResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2ErrorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteLedgerMetadata - Delete ledger metadata by key +func (s *V2) DeleteLedgerMetadata(ctx context.Context, ledger string, key string, opts ...operations.Option) (*operations.V2DeleteLedgerMetadataResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2DeleteLedgerMetadata", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2DeleteLedgerMetadataRequest{ + Ledger: ledger, + Key: key, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/metadata/{key}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2DeleteLedgerMetadataResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetLedgerInfo - Get information about a ledger +func (s *V2) GetLedgerInfo(ctx context.Context, ledger string, opts ...operations.Option) (*operations.V2GetLedgerInfoResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2GetLedgerInfo", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2GetLedgerInfoRequest{ + Ledger: ledger, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/_info", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2GetLedgerInfoResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2LedgerInfoResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2LedgerInfoResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateBulk - Bulk request +func (s *V2) CreateBulk(ctx context.Context, ledger string, requestBody []components.V2BulkElement, opts ...operations.Option) (*operations.V2CreateBulkResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2CreateBulk", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2CreateBulkRequest{ + Ledger: ledger, + RequestBody: requestBody, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/_bulk", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2CreateBulkResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + fallthrough + case httpRes.StatusCode == 400: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2BulkResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2BulkResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CountAccounts - Count the accounts from a ledger +func (s *V2) CountAccounts(ctx context.Context, ledger string, pit *time.Time, requestBody map[string]any, opts ...operations.Option) (*operations.V2CountAccountsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2CountAccounts", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2CountAccountsRequest{ + Ledger: ledger, + Pit: pit, + RequestBody: requestBody, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/accounts", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "HEAD", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2CountAccountsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + res.Headers = httpRes.Header + + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListAccounts - List accounts from a ledger +// List accounts from a ledger, sorted by address in descending order. +func (s *V2) ListAccounts(ctx context.Context, request operations.V2ListAccountsRequest, opts ...operations.Option) (*operations.V2ListAccountsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2ListAccounts", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/accounts", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2ListAccountsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2AccountsCursorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2AccountsCursorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetAccount - Get account by its address +func (s *V2) GetAccount(ctx context.Context, ledger string, address string, expand *string, pit *time.Time, opts ...operations.Option) (*operations.V2GetAccountResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2GetAccount", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2GetAccountRequest{ + Ledger: ledger, + Address: address, + Expand: expand, + Pit: pit, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/accounts/{address}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2GetAccountResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2AccountResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2AccountResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// AddMetadataToAccount - Add metadata to an account +func (s *V2) AddMetadataToAccount(ctx context.Context, request operations.V2AddMetadataToAccountRequest, opts ...operations.Option) (*operations.V2AddMetadataToAccountResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2AddMetadataToAccount", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/accounts/{address}/metadata", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + utils.PopulateHeaders(ctx, req, request, nil) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2AddMetadataToAccountResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteAccountMetadata - Delete metadata by key +// Delete metadata by key +func (s *V2) DeleteAccountMetadata(ctx context.Context, ledger string, address string, key string, opts ...operations.Option) (*operations.V2DeleteAccountMetadataResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2DeleteAccountMetadata", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2DeleteAccountMetadataRequest{ + Ledger: ledger, + Address: address, + Key: key, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/accounts/{address}/metadata/{key}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2DeleteAccountMetadataResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode >= 200 && httpRes.StatusCode < 300: + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ReadStats - Get statistics from a ledger +// Get statistics from a ledger. (aggregate metrics on accounts and transactions) +func (s *V2) ReadStats(ctx context.Context, ledger string, opts ...operations.Option) (*operations.V2ReadStatsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2ReadStats", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2ReadStatsRequest{ + Ledger: ledger, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/stats", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2ReadStatsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2StatsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2StatsResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CountTransactions - Count the transactions from a ledger +func (s *V2) CountTransactions(ctx context.Context, ledger string, pit *time.Time, requestBody map[string]any, opts ...operations.Option) (*operations.V2CountTransactionsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2CountTransactions", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2CountTransactionsRequest{ + Ledger: ledger, + Pit: pit, + RequestBody: requestBody, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/transactions", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "HEAD", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2CountTransactionsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + res.Headers = httpRes.Header + + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListTransactions - List transactions from a ledger +// List transactions from a ledger, sorted by id in descending order. +func (s *V2) ListTransactions(ctx context.Context, request operations.V2ListTransactionsRequest, opts ...operations.Option) (*operations.V2ListTransactionsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2ListTransactions", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/transactions", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2ListTransactionsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2TransactionsCursorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2TransactionsCursorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateTransaction - Create a new transaction to a ledger +func (s *V2) CreateTransaction(ctx context.Context, ledger string, v2PostTransaction components.V2PostTransaction, dryRun *bool, idempotencyKey *string, opts ...operations.Option) (*operations.V2CreateTransactionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2CreateTransaction", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2CreateTransactionRequest{ + Ledger: ledger, + DryRun: dryRun, + IdempotencyKey: idempotencyKey, + V2PostTransaction: v2PostTransaction, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/transactions", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "V2PostTransaction", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + utils.PopulateHeaders(ctx, req, request, nil) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2CreateTransactionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2CreateTransactionResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2CreateTransactionResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetTransaction - Get transaction from a ledger by its ID +func (s *V2) GetTransaction(ctx context.Context, ledger string, id *big.Int, expand *string, pit *time.Time, opts ...operations.Option) (*operations.V2GetTransactionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2GetTransaction", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2GetTransactionRequest{ + Ledger: ledger, + ID: id, + Expand: expand, + Pit: pit, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/transactions/{id}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2GetTransactionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2GetTransactionResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2GetTransactionResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// AddMetadataOnTransaction - Set the metadata of a transaction by its ID +func (s *V2) AddMetadataOnTransaction(ctx context.Context, request operations.V2AddMetadataOnTransactionRequest, opts ...operations.Option) (*operations.V2AddMetadataOnTransactionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2AddMetadataOnTransaction", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/transactions/{id}/metadata", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + utils.PopulateHeaders(ctx, req, request, nil) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2AddMetadataOnTransactionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteTransactionMetadata - Delete metadata by key +// Delete metadata by key +func (s *V2) DeleteTransactionMetadata(ctx context.Context, ledger string, id *big.Int, key string, opts ...operations.Option) (*operations.V2DeleteTransactionMetadataResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2DeleteTransactionMetadata", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2DeleteTransactionMetadataRequest{ + Ledger: ledger, + ID: id, + Key: key, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/transactions/{id}/metadata/{key}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2DeleteTransactionMetadataResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode >= 200 && httpRes.StatusCode < 300: + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// RevertTransaction - Revert a ledger transaction by its ID +func (s *V2) RevertTransaction(ctx context.Context, ledger string, id *big.Int, force *bool, atEffectiveDate *bool, opts ...operations.Option) (*operations.V2RevertTransactionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2RevertTransaction", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2RevertTransactionRequest{ + Ledger: ledger, + ID: id, + Force: force, + AtEffectiveDate: atEffectiveDate, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/transactions/{id}/revert", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2RevertTransactionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2RevertTransactionResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2RevertTransactionResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetBalancesAggregated - Get the aggregated balances from selected accounts +func (s *V2) GetBalancesAggregated(ctx context.Context, ledger string, pit *time.Time, useInsertionDate *bool, requestBody map[string]any, opts ...operations.Option) (*operations.V2GetBalancesAggregatedResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2GetBalancesAggregated", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2GetBalancesAggregatedRequest{ + Ledger: ledger, + Pit: pit, + UseInsertionDate: useInsertionDate, + RequestBody: requestBody, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/aggregate/balances", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2GetBalancesAggregatedResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2AggregateBalancesResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2AggregateBalancesResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetVolumesWithBalances - Get list of volumes with balances for (account/asset) +func (s *V2) GetVolumesWithBalances(ctx context.Context, request operations.V2GetVolumesWithBalancesRequest, opts ...operations.Option) (*operations.V2GetVolumesWithBalancesResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2GetVolumesWithBalances", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/volumes", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2GetVolumesWithBalancesResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2VolumesWithBalanceCursorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2VolumesWithBalanceCursorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListLogs - List the logs from a ledger +// List the logs from a ledger, sorted by ID in descending order. +func (s *V2) ListLogs(ctx context.Context, request operations.V2ListLogsRequest, opts ...operations.Option) (*operations.V2ListLogsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2ListLogs", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/logs", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2ListLogsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.V2LogsCursorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2LogsCursorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +func (s *V2) ImportLogs(ctx context.Context, ledger string, requestBody *string, opts ...operations.Option) (*operations.V2ImportLogsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2ImportLogs", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2ImportLogsRequest{ + Ledger: ledger, + RequestBody: requestBody, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/logs/import", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "string", `request:"mediaType=application/octet-stream"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2ImportLogsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ExportLogs - Export logs +func (s *V2) ExportLogs(ctx context.Context, ledger string, opts ...operations.Option) (*operations.V2ExportLogsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "v2ExportLogs", + OAuth2Scopes: []string{}, + SecuritySource: nil, + } + + request := operations.V2ExportLogsRequest{ + Ledger: ledger, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/{ledger}/logs/export", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "*/*") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.V2ExportLogsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + default: + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/components/ledger/pkg/testserver/helpers.go b/components/ledger/pkg/testserver/helpers.go new file mode 100644 index 0000000000..7f6efb2969 --- /dev/null +++ b/components/ledger/pkg/testserver/helpers.go @@ -0,0 +1,15 @@ +package testserver + +import ( + . "github.com/formancehq/stack/libs/go-libs/testing/utils" + . "github.com/onsi/ginkgo/v2" +) + +func UseNewTestServer(configurationProvider func() Configuration) *Deferred[*Server] { + d := NewDeferred[*Server]() + BeforeEach(func() { + d.Reset() + d.SetValue(New(GinkgoT(), configurationProvider())) + }) + return d +} diff --git a/components/ledger/pkg/testserver/server.go b/components/ledger/pkg/testserver/server.go new file mode 100644 index 0000000000..950575b8a7 --- /dev/null +++ b/components/ledger/pkg/testserver/server.go @@ -0,0 +1,174 @@ +package testserver + +import ( + "context" + "fmt" + "io" + "net/http" + "os" + "strings" + "time" + + "github.com/formancehq/ledger/cmd" + ledgerclient "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/libs/go-libs/bun/bunconnect" + "github.com/formancehq/stack/libs/go-libs/httpclient" + "github.com/formancehq/stack/libs/go-libs/httpserver" + "github.com/formancehq/stack/libs/go-libs/logging" + "github.com/formancehq/stack/libs/go-libs/service" + "github.com/stretchr/testify/require" +) + +type T interface { + require.TestingT + TempDir() string + Cleanup(func()) + Helper() + Logf(format string, args ...any) +} + +type Configuration struct { + PostgresConfiguration bunconnect.ConnectionOptions + Output io.Writer + Debug bool +} + +type Server struct { + configuration Configuration + t T + httpClient *ledgerclient.Formance + cancel func() + ctx context.Context + errorChan chan error +} + +func (s *Server) Start() { + s.t.Helper() + + tmpDir := s.t.TempDir() + require.NoError(s.t, os.MkdirAll(tmpDir, 0700)) + s.t.Cleanup(func() { + _ = os.RemoveAll(tmpDir) + }) + + rootCmd := cmd.NewRootCommand() + args := []string{ + "serve", + "--" + cmd.BindFlag, ":0", + "--" + bunconnect.PostgresURIFlag, s.configuration.PostgresConfiguration.DatabaseSourceName, + "--" + bunconnect.PostgresMaxOpenConnsFlag, fmt.Sprint(s.configuration.PostgresConfiguration.MaxOpenConns), + "--" + bunconnect.PostgresConnMaxIdleTimeFlag, fmt.Sprint(s.configuration.PostgresConfiguration.ConnMaxIdleTime), + } + if s.configuration.PostgresConfiguration.MaxIdleConns != 0 { + args = append( + args, + "--"+bunconnect.PostgresMaxIdleConnsFlag, + fmt.Sprint(s.configuration.PostgresConfiguration.MaxIdleConns), + ) + } + if s.configuration.PostgresConfiguration.MaxOpenConns != 0 { + args = append( + args, + "--"+bunconnect.PostgresMaxOpenConnsFlag, + fmt.Sprint(s.configuration.PostgresConfiguration.MaxOpenConns), + ) + } + if s.configuration.PostgresConfiguration.ConnMaxIdleTime != 0 { + args = append( + args, + "--"+bunconnect.PostgresConnMaxIdleTimeFlag, + fmt.Sprint(s.configuration.PostgresConfiguration.ConnMaxIdleTime), + ) + } + if s.configuration.Debug { + args = append(args, "--"+service.DebugFlag) + } + + s.t.Logf("Starting application with flags: %s", strings.Join(args, " ")) + rootCmd.SetArgs(args) + rootCmd.SilenceErrors = true + output := s.configuration.Output + if output == nil { + output = io.Discard + } + rootCmd.SetOut(output) + rootCmd.SetErr(output) + + s.ctx = logging.TestingContext() + s.ctx, s.cancel = context.WithCancel(s.ctx) + s.ctx = service.ContextWithLifecycle(s.ctx) + s.ctx = httpserver.ContextWithServerInfo(s.ctx) + + s.errorChan = make(chan error, 1) + go func() { + s.errorChan <- rootCmd.ExecuteContext(s.ctx) + }() + + select { + case <-service.Ready(s.ctx): + case err := <-s.errorChan: + if err != nil { + require.NoError(s.t, err) + } else { + require.Fail(s.t, "unexpected service stop") + } + } + + s.httpClient = ledgerclient.New( + ledgerclient.WithServerURL(httpserver.URL(s.ctx)), + ledgerclient.WithClient(&http.Client{ + Transport: httpclient.NewDebugHTTPTransport(http.DefaultTransport), + }), + ) +} + +func (s *Server) Stop() { + s.t.Helper() + + if s.cancel == nil { + return + } + s.cancel() + s.cancel = nil + + // Wait app to be marked as stopped + select { + case <-service.Stopped(s.ctx): + case <-time.After(5 * time.Second): + require.Fail(s.t, "service should have been stopped") + } + + // Ensure the app has been properly shutdown + select { + case err := <-s.errorChan: + require.NoError(s.t, err) + case <-time.After(5 * time.Second): + require.Fail(s.t, "service should have been stopped without error") + } +} + +func (s *Server) Client() *ledgerclient.Formance { + return s.httpClient +} + +func (s *Server) Restart() { + s.t.Helper() + + s.Stop() + s.Start() +} + +func New(t T, configuration Configuration) *Server { + srv := &Server{ + t: t, + configuration: configuration, + } + t.Logf("Start testing server") + srv.Start() + t.Cleanup(func() { + t.Logf("Stop testing server") + srv.Stop() + }) + + return srv +} diff --git a/components/ledger/sdkconfig.yaml b/components/ledger/sdkconfig.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/ledger/test/environment_test.go b/components/ledger/test/environment_test.go new file mode 100644 index 0000000000..e23302c892 --- /dev/null +++ b/components/ledger/test/environment_test.go @@ -0,0 +1,58 @@ +//go:build it + +package test_suite + +import ( + "encoding/json" + "github.com/formancehq/stack/libs/go-libs/logging" + "github.com/formancehq/stack/libs/go-libs/testing/docker" + . "github.com/formancehq/stack/libs/go-libs/testing/platform/pgtesting" + . "github.com/formancehq/stack/libs/go-libs/testing/utils" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "os" +) + +var ( + dockerPool = NewDeferred[*docker.Pool]() + pgServer = NewDeferred[*PostgresServer]() + debug = os.Getenv("DEBUG") == "true" + logger = logging.NewDefaultLogger(GinkgoWriter, debug, false) +) + +type ParallelExecutionContext struct { + PostgresServer *PostgresServer +} + +var _ = SynchronizedBeforeSuite(func() []byte { + By("Initializing docker pool") + dockerPool.SetValue(docker.NewPool(GinkgoT(), logger)) + + pgServer.LoadAsync(func() *PostgresServer { + By("Initializing postgres server") + return CreatePostgresServer(GinkgoT(), dockerPool.GetValue()) + }) + + By("Waiting services alive") + Wait(pgServer) + By("All services ready.") + + data, err := json.Marshal(ParallelExecutionContext{ + PostgresServer: pgServer.GetValue(), + }) + Expect(err).To(BeNil()) + + return data +}, func(data []byte) { + select { + case <-pgServer.Done(): + // Process #1, setup is terminated + return + default: + } + pec := ParallelExecutionContext{} + err := json.Unmarshal(data, &pec) + Expect(err).To(BeNil()) + + pgServer.SetValue(pec.PostgresServer) +}) diff --git a/components/ledger/test/scenario_test.go b/components/ledger/test/scenario_test.go new file mode 100644 index 0000000000..28b11fd0a0 --- /dev/null +++ b/components/ledger/test/scenario_test.go @@ -0,0 +1,33 @@ +//go:build it + +package test_suite + +import ( + . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/stack/libs/go-libs/logging" + . "github.com/formancehq/stack/libs/go-libs/testing/platform/pgtesting" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Context("Ledger integration tests", func() { + var ( + db = UsePostgresDatabase(pgServer) + ctx = logging.TestingContext() + ) + + testServer := UseNewTestServer(func() Configuration { + return Configuration{ + PostgresConfiguration: db.GetValue().ConnectionOptions(), + Output: GinkgoWriter, + Debug: debug, + } + }) + When("Starting the ledger", func() { + It("Should be ok", func() { + info, err := testServer.GetValue().Client().Ledger.V2.GetInfo(ctx) + Expect(err).NotTo(HaveOccurred()) + Expect(info.V2ConfigInfoResponse.Version).To(Equal("develop")) + }) + }) +}) diff --git a/components/ledger/test/suite_test.go b/components/ledger/test/suite_test.go new file mode 100644 index 0000000000..8f527c415d --- /dev/null +++ b/components/ledger/test/suite_test.go @@ -0,0 +1,14 @@ +//go:build it + +package test_suite + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "testing" +) + +func Test(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Test Suite") +} diff --git a/components/operator/Earthfile b/components/operator/Earthfile index c5db51f54f..5afb7b8725 100644 --- a/components/operator/Earthfile +++ b/components/operator/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT .. AS components diff --git a/components/operator/tools/kubectl-stacks/Earthfile b/components/operator/tools/kubectl-stacks/Earthfile index e6393601c8..e26b31e852 100644 --- a/components/operator/tools/kubectl-stacks/Earthfile +++ b/components/operator/tools/kubectl-stacks/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../../../.. AS stack IMPORT ../../.. AS components diff --git a/components/operator/tools/utils/Earthfile b/components/operator/tools/utils/Earthfile index 32aaef8514..0d79eda626 100644 --- a/components/operator/tools/utils/Earthfile +++ b/components/operator/tools/utils/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../../../.. AS stack IMPORT ../../.. AS components diff --git a/components/payments/Earthfile b/components/payments/Earthfile index 4899885ab9..b1b588f196 100644 --- a/components/payments/Earthfile +++ b/components/payments/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT ../../releases AS releases IMPORT .. AS components diff --git a/ee/Earthfile b/ee/Earthfile index 5289a856fd..9cb8b0e7e7 100644 --- a/ee/Earthfile +++ b/ee/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT .. AS stack deploy: diff --git a/ee/agent/Earthfile b/ee/agent/Earthfile index 3bd7096c93..6a45b25b16 100644 --- a/ee/agent/Earthfile +++ b/ee/agent/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT ../../helm/libs AS helm-libs diff --git a/ee/auth/Earthfile b/ee/auth/Earthfile index e7a43cd874..687e7ea298 100644 --- a/ee/auth/Earthfile +++ b/ee/auth/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT .. AS ee diff --git a/ee/gateway/Earthfile b/ee/gateway/Earthfile index d702005f4b..8b252d4398 100644 --- a/ee/gateway/Earthfile +++ b/ee/gateway/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT .. AS ee diff --git a/ee/orchestration/Earthfile b/ee/orchestration/Earthfile index d9bce855f1..0c7b6284a0 100644 --- a/ee/orchestration/Earthfile +++ b/ee/orchestration/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT ../../releases AS releases IMPORT .. AS ee diff --git a/ee/reconciliation/Earthfile b/ee/reconciliation/Earthfile index 98a6017362..fd34ff0486 100644 --- a/ee/reconciliation/Earthfile +++ b/ee/reconciliation/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT ../../releases AS releases IMPORT .. AS ee diff --git a/ee/search/Earthfile b/ee/search/Earthfile index 31f12ee5c9..cafe8e87ea 100644 --- a/ee/search/Earthfile +++ b/ee/search/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT .. AS ee diff --git a/ee/stargate/Earthfile b/ee/stargate/Earthfile index b5887580da..c561d20e87 100644 --- a/ee/stargate/Earthfile +++ b/ee/stargate/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT .. AS ee diff --git a/ee/wallets/Earthfile b/ee/wallets/Earthfile index 12416f49cc..da5e99cb0b 100644 --- a/ee/wallets/Earthfile +++ b/ee/wallets/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT ../../releases AS releases IMPORT .. AS ee diff --git a/ee/webhooks/Earthfile b/ee/webhooks/Earthfile index e75882770a..cd8d117177 100644 --- a/ee/webhooks/Earthfile +++ b/ee/webhooks/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT .. AS ee diff --git a/helm/Earthfile b/helm/Earthfile index 85ac517f1f..3c310388ab 100644 --- a/helm/Earthfile +++ b/helm/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT .. AS stack IMPORT ../components/operator AS operator diff --git a/helm/demo/Earthfile b/helm/demo/Earthfile index 4cd4f89901..687b6da741 100644 --- a/helm/demo/Earthfile +++ b/helm/demo/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core sources: FROM core+base-image diff --git a/helm/libs/Earthfile b/helm/libs/Earthfile index 9ed0464dc8..8037dc82b1 100644 --- a/helm/libs/Earthfile +++ b/helm/libs/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core sources: FROM core+base-image diff --git a/helm/regions/Earthfile b/helm/regions/Earthfile index 889549bc58..627bab7996 100644 --- a/helm/regions/Earthfile +++ b/helm/regions/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT ../../components/operator AS operator IMPORT ../../ee/agent AS agent diff --git a/libs/Earthfile b/libs/Earthfile index a03a56ae0c..efd1c8330f 100644 --- a/libs/Earthfile +++ b/libs/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT .. AS stack run: diff --git a/libs/core/Earthfile b/libs/core/Earthfile index 9dd14ebe41..cf512fcca9 100644 --- a/libs/core/Earthfile +++ b/libs/core/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack FROM core+base-image diff --git a/libs/events/Earthfile b/libs/events/Earthfile index 1ff3c76c33..c8f054a329 100644 --- a/libs/events/Earthfile +++ b/libs/events/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack FROM core+base-image diff --git a/libs/go-libs/Earthfile b/libs/go-libs/Earthfile index 70f2fcf3e8..3586735b3f 100644 --- a/libs/go-libs/Earthfile +++ b/libs/go-libs/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack FROM core+base-image diff --git a/releases/Earthfile b/releases/Earthfile index 828804ef80..04734dec7b 100644 --- a/releases/Earthfile +++ b/releases/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ./../ AS stack sources: diff --git a/releases/sdks/go/.speakeasy/gen.lock b/releases/sdks/go/.speakeasy/gen.lock index 37922f6912..197a44e524 100755 --- a/releases/sdks/go/.speakeasy/gen.lock +++ b/releases/sdks/go/.speakeasy/gen.lock @@ -1,7 +1,7 @@ lockVersion: 2.0.0 id: 7eac0a45-60a2-40bb-9e85-26bd77ec2a6d management: - docChecksum: 31a0004fae4a5f62c9fb3d08fae59b32 + docChecksum: 0565b0e11806fc861715659cc13d103e docVersion: v0.0.0 speakeasyVersion: 1.346.0 generationVersion: 2.379.3 diff --git a/releases/sdks/go/docs/pkg/models/operations/v2getinforesponse.md b/releases/sdks/go/docs/pkg/models/operations/v2getinforesponse.md index a88e408f8b..a56606cbd5 100644 --- a/releases/sdks/go/docs/pkg/models/operations/v2getinforesponse.md +++ b/releases/sdks/go/docs/pkg/models/operations/v2getinforesponse.md @@ -8,4 +8,5 @@ | `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | | `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | | `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | -| `V2ConfigInfoResponse` | [*shared.V2ConfigInfoResponse](../../../pkg/models/shared/v2configinforesponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file +| `V2ConfigInfoResponse` | [*shared.V2ConfigInfoResponse](../../../pkg/models/shared/v2configinforesponse.md) | :heavy_minus_sign: | OK | +| `V2ErrorResponse` | **sdkerrors.V2ErrorResponse* | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/releases/sdks/go/docs/pkg/models/operations/v2updateledgermetadataresponse.md b/releases/sdks/go/docs/pkg/models/operations/v2updateledgermetadataresponse.md index b003081854..73728bb8e9 100644 --- a/releases/sdks/go/docs/pkg/models/operations/v2updateledgermetadataresponse.md +++ b/releases/sdks/go/docs/pkg/models/operations/v2updateledgermetadataresponse.md @@ -7,4 +7,5 @@ | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | | `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | | `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | -| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file +| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `V2ErrorResponse` | **sdkerrors.V2ErrorResponse* | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/releases/sdks/go/docs/sdks/v2/README.md b/releases/sdks/go/docs/sdks/v2/README.md index 57f7ab6443..78cc371a13 100644 --- a/releases/sdks/go/docs/sdks/v2/README.md +++ b/releases/sdks/go/docs/sdks/v2/README.md @@ -519,9 +519,10 @@ func main() { ### Response **[*operations.V2DeleteAccountMetadataResponse](../../pkg/models/operations/v2deleteaccountmetadataresponse.md), error** -| Error Object | Status Code | Content Type | -| ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ------------------------- | ------------------------- | ------------------------- | +| sdkerrors.V2ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | ## DeleteLedgerMetadata diff --git a/releases/sdks/go/pkg/models/operations/v2getinfo.go b/releases/sdks/go/pkg/models/operations/v2getinfo.go index 30c1d3214e..c1cbfd73b4 100644 --- a/releases/sdks/go/pkg/models/operations/v2getinfo.go +++ b/releases/sdks/go/pkg/models/operations/v2getinfo.go @@ -3,6 +3,7 @@ package operations import ( + "github.com/formancehq/formance-sdk-go/v2/pkg/models/sdkerrors" "github.com/formancehq/formance-sdk-go/v2/pkg/models/shared" "net/http" ) @@ -16,6 +17,8 @@ type V2GetInfoResponse struct { RawResponse *http.Response // OK V2ConfigInfoResponse *shared.V2ConfigInfoResponse + // Error + V2ErrorResponse *sdkerrors.V2ErrorResponse } func (o *V2GetInfoResponse) GetContentType() string { @@ -45,3 +48,10 @@ func (o *V2GetInfoResponse) GetV2ConfigInfoResponse() *shared.V2ConfigInfoRespon } return o.V2ConfigInfoResponse } + +func (o *V2GetInfoResponse) GetV2ErrorResponse() *sdkerrors.V2ErrorResponse { + if o == nil { + return nil + } + return o.V2ErrorResponse +} diff --git a/releases/sdks/go/pkg/models/operations/v2updateledgermetadata.go b/releases/sdks/go/pkg/models/operations/v2updateledgermetadata.go index 4190427e16..bfec54cb66 100644 --- a/releases/sdks/go/pkg/models/operations/v2updateledgermetadata.go +++ b/releases/sdks/go/pkg/models/operations/v2updateledgermetadata.go @@ -3,6 +3,7 @@ package operations import ( + "github.com/formancehq/formance-sdk-go/v2/pkg/models/sdkerrors" "net/http" ) @@ -33,6 +34,8 @@ type V2UpdateLedgerMetadataResponse struct { StatusCode int // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response + // Error + V2ErrorResponse *sdkerrors.V2ErrorResponse } func (o *V2UpdateLedgerMetadataResponse) GetContentType() string { @@ -55,3 +58,10 @@ func (o *V2UpdateLedgerMetadataResponse) GetRawResponse() *http.Response { } return o.RawResponse } + +func (o *V2UpdateLedgerMetadataResponse) GetV2ErrorResponse() *sdkerrors.V2ErrorResponse { + if o == nil { + return nil + } + return o.V2ErrorResponse +} diff --git a/releases/sdks/go/v2.go b/releases/sdks/go/v2.go index b0b1e51f59..24839bd818 100644 --- a/releases/sdks/go/v2.go +++ b/releases/sdks/go/v2.go @@ -1335,7 +1335,7 @@ func (s *V2) DeleteAccountMetadata(ctx context.Context, request operations.V2Del if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } - req.Header.Set("Accept", "*/*") + req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { @@ -1443,7 +1443,17 @@ func (s *V2) DeleteAccountMetadata(ctx context.Context, request operations.V2Del switch { case httpRes.StatusCode >= 200 && httpRes.StatusCode < 300: default: - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } } return res, nil @@ -2472,6 +2482,18 @@ func (s *V2) GetInfo(ctx context.Context, opts ...operations.Option) (*operation default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2ErrorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): @@ -4653,6 +4675,18 @@ func (s *V2) UpdateLedgerMetadata(ctx context.Context, request operations.V2Upda switch { case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.V2ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.V2ErrorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): diff --git a/tests/benchmarks/Earthfile b/tests/benchmarks/Earthfile index 75399c05f3..6c73250777 100644 --- a/tests/benchmarks/Earthfile +++ b/tests/benchmarks/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack diff --git a/tests/integration/Earthfile b/tests/integration/Earthfile index 4c903214ab..e599183bdb 100644 --- a/tests/integration/Earthfile +++ b/tests/integration/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.14.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core IMPORT ../.. AS stack IMPORT ../../releases AS releases diff --git a/tests/integration/go.mod b/tests/integration/go.mod index 7840ec005f..ce6b3f4325 100644 --- a/tests/integration/go.mod +++ b/tests/integration/go.mod @@ -24,15 +24,15 @@ require ( github.com/jackc/pgx/v5 v5.6.0 github.com/nats-io/nats.go v1.37.0 github.com/oauth2-proxy/mockoidc v0.0.0-20220308204021-b9169deeb282 - github.com/onsi/ginkgo/v2 v2.20.0 - github.com/onsi/gomega v1.34.1 + github.com/onsi/ginkgo/v2 v2.20.2 + github.com/onsi/gomega v1.34.2 github.com/ory/dockertest/v3 v3.11.0 github.com/pborman/uuid v1.2.1 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.1 - github.com/uptrace/bun v1.2.1 - github.com/uptrace/bun/dialect/pgdialect v1.2.1 + github.com/uptrace/bun v1.2.3 + github.com/uptrace/bun/dialect/pgdialect v1.2.3 github.com/uptrace/bun/driver/pgdriver v1.1.14 github.com/xo/dburl v0.23.2 github.com/zitadel/oidc/v2 v2.12.0 @@ -47,13 +47,13 @@ require ( github.com/IBM/sarama v1.43.3 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect - github.com/ThreeDotsLabs/watermill v1.3.5 // indirect + github.com/ThreeDotsLabs/watermill v1.3.7 // indirect github.com/ThreeDotsLabs/watermill-http/v2 v2.3.0 // indirect github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.1 // indirect github.com/ThreeDotsLabs/watermill-nats/v2 v2.0.2 // indirect github.com/adyen/adyen-go-api-library/v7 v7.3.1 // indirect github.com/ajg/form v1.5.1 // indirect - github.com/alitto/pond v1.8.3 // indirect + github.com/alitto/pond v1.9.2 // indirect github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/aquasecurity/esquery v0.2.0 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect @@ -130,7 +130,7 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect + github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/mux v1.8.0 // indirect @@ -196,6 +196,7 @@ require ( github.com/pierrec/lz4/v4 v4.1.21 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect + github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/riandyrn/otelchi v0.9.0 // indirect github.com/robfig/cron v1.2.0 // indirect @@ -235,7 +236,7 @@ require ( go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect go.opentelemetry.io/contrib/instrumentation/runtime v0.53.0 // indirect go.opentelemetry.io/contrib/propagators/b3 v1.28.0 // indirect - go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel v1.29.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect @@ -244,10 +245,10 @@ require ( go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.28.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.28.0 // indirect go.opentelemetry.io/otel/log v0.3.0 // indirect - go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/metric v1.29.0 // indirect go.opentelemetry.io/otel/sdk v1.28.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.29.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.temporal.io/api v1.18.1 // indirect go.temporal.io/sdk v1.21.1 // indirect @@ -259,11 +260,10 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.26.0 // indirect - golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/mod v0.20.0 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.23.0 // indirect + golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.17.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.24.0 // indirect diff --git a/tests/integration/go.sum b/tests/integration/go.sum index a156aa7489..d1dc40f23b 100644 --- a/tests/integration/go.sum +++ b/tests/integration/go.sum @@ -613,8 +613,8 @@ github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/ThreeDotsLabs/watermill v1.3.5 h1:50JEPEhMGZQMh08ct0tfO1PsgMOAOhV3zxK2WofkbXg= -github.com/ThreeDotsLabs/watermill v1.3.5/go.mod h1:O/u/Ptyrk5MPTxSeWM5vzTtZcZfxXfO9PK9eXTYiFZY= +github.com/ThreeDotsLabs/watermill v1.3.7 h1:NV0PSTmuACVEOV4dMxRnmGXrmbz8U83LENOvpHekN7o= +github.com/ThreeDotsLabs/watermill v1.3.7/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= github.com/ThreeDotsLabs/watermill-http/v2 v2.3.0 h1:EMLYXiuFhza/p5LgoM+R49JHYbkXuNLNC6tlXyG/x0E= github.com/ThreeDotsLabs/watermill-http/v2 v2.3.0/go.mod h1:Ily2cdTrvlj9dLB8BqAy5OIzWwS8B5WrFh+Ey7wOgQQ= github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.1 h1:xqSjxMpZUROIjFTLqmKDJfOn/1zbqagcOcKE4xSxUzc= @@ -629,8 +629,8 @@ github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM= -github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= -github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= +github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= +github.com/alitto/pond v1.9.2/go.mod h1:xQn3P/sHTYcU/1BR3i86IGIrilcrGC2LiS+E2+CJWsI= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= @@ -972,8 +972,8 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= -github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.0/go.mod h1:OJpEgntRZo8ugHpF9hkoLJbS5dSI20XZeXJ9JVywLlM= github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= @@ -1195,10 +1195,10 @@ github.com/oauth2-proxy/mockoidc v0.0.0-20220308204021-b9169deeb282 h1:TQMyrpijt github.com/oauth2-proxy/mockoidc v0.0.0-20220308204021-b9169deeb282/go.mod h1:rW25Kyd08Wdn3UVn0YBsDTSvReu0jqpmJKzxITPSjks= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/onsi/ginkgo/v2 v2.20.0 h1:PE84V2mHqoT1sglvHc8ZdQtPcwmvvt29WLEEO3xmdZw= -github.com/onsi/ginkgo/v2 v2.20.0/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= -github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= -github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= +github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= +github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= +github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= +github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= @@ -1238,6 +1238,8 @@ github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:Om github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/puzpuzpuz/xsync/v3 v3.4.0 h1:DuVBAdXuGFHv8adVXjWWZ63pJq+NRXOWVXlKDBZ+mJ4= +github.com/puzpuzpuz/xsync/v3 v3.4.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= @@ -1315,10 +1317,10 @@ github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6 github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= 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/uptrace/bun v1.2.1 h1:2ENAcfeCfaY5+2e7z5pXrzFKy3vS8VXvkCag6N2Yzfk= -github.com/uptrace/bun v1.2.1/go.mod h1:cNg+pWBUMmJ8rHnETgf65CEvn3aIKErrwOD6IA8e+Ec= -github.com/uptrace/bun/dialect/pgdialect v1.2.1 h1:ceP99r03u+s8ylaDE/RzgcajwGiC76Jz3nS2ZgyPQ4M= -github.com/uptrace/bun/dialect/pgdialect v1.2.1/go.mod h1:mv6B12cisvSc6bwKm9q9wcrr26awkZK8QXM+nso9n2U= +github.com/uptrace/bun v1.2.3 h1:6KDc6YiNlXde38j9ATKufb8o7MS8zllhAOeIyELKrk0= +github.com/uptrace/bun v1.2.3/go.mod h1:8frYFHrO/Zol3I4FEjoXam0HoNk+t5k7aJRl3FXp0mk= +github.com/uptrace/bun/dialect/pgdialect v1.2.3 h1:YyCxxqeL0lgFWRZzKCOt6mnxUsjqITcxSo0mLqgwMUA= +github.com/uptrace/bun/dialect/pgdialect v1.2.3/go.mod h1:Vx9TscyEq1iN4tnirn6yYGwEflz0KG3rBZTBCLpKAjc= github.com/uptrace/bun/driver/pgdriver v1.1.14 h1:V2Etm7mLGS3mhx8ddxZcUnwZLX02Jmq9JTlo0sNVDhA= github.com/uptrace/bun/driver/pgdriver v1.1.14/go.mod h1:D4FjWV9arDYct6sjMJhFoyU71SpllZRHXFRRP2Kd0Kw= github.com/uptrace/bun/extra/bundebug v1.2.1 h1:85MYpX3QESYI02YerKxUi1CD9mHuLrc2BXs1eOCtQus= @@ -1390,8 +1392,8 @@ go.opentelemetry.io/contrib/instrumentation/runtime v0.53.0/go.mod h1:u79lGGIlkg go.opentelemetry.io/contrib/propagators/b3 v1.28.0 h1:XR6CFQrQ/ttAYmTBX2loUEFGdk1h17pxYI8828dk/1Y= go.opentelemetry.io/contrib/propagators/b3 v1.28.0/go.mod h1:DWRkzJONLquRz7OJPh2rRbZ7MugQj62rk7g6HRnEqh0= go.opentelemetry.io/otel v1.2.0/go.mod h1:aT17Fk0Z1Nor9e0uisf98LrntPGMnk4frBO9+dkf69I= -go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= -go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= +go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0/go.mod h1:yeGZANgEcpdx/WK0IvvRFC+2oLiMS2u4L/0Rj2M2Qr0= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.28.0 h1:aLmmtjRke7LPDQ3lvpFz+kNEH43faFhzW7v8BFIEydg= @@ -1408,16 +1410,16 @@ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.28.0 h1:EVSnY9JbEEW92bE go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.28.0/go.mod h1:Ea1N1QQryNXpCD0I1fdLibBAIpQuBkznMmkdKrapk1Y= go.opentelemetry.io/otel/log v0.3.0 h1:kJRFkpUFYtny37NQzL386WbznUByZx186DpEMKhEGZs= go.opentelemetry.io/otel/log v0.3.0/go.mod h1:ziCwqZr9soYDwGNbIL+6kAvQC+ANvjgG367HVcyR/ys= -go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= -go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc= +go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8= go.opentelemetry.io/otel/sdk v1.2.0/go.mod h1:jNN8QtpvbsKhgaC6V5lHiejMoKD+V8uadoSafgHPx1U= go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= go.opentelemetry.io/otel/trace v1.2.0/go.mod h1:N5FLswTubnxKxOJHM7XZC074qpeEdLy3CgAVsdMucK0= -go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= -go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4= +go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= @@ -1484,8 +1486,6 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1734,8 +1734,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.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.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=