Skip to content

feat: devenvs #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
VERSION 0.8

IMPORT github.com/formancehq/earthly:tags/v0.19.1 AS core
ARG core=github.com/formancehq/earthly:main
IMPORT $core AS core

FROM core+base-image

Expand Down
6 changes: 3 additions & 3 deletions pkg/client/.speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
lockVersion: 2.0.0
id: e26e5b37-4391-4462-9a20-c517a83a166a
management:
docChecksum: db765895ce588102fc2f91fcc1f328ba
docChecksum: dfc3ed9eb806fc9e8c6629a3d2a0a637
docVersion: 0.1.0
speakeasyVersion: 1.351.0
generationVersion: 2.384.1
releaseVersion: 0.1.3
configChecksum: 95fa254f71d5a7c155d6b2f3308f1843
releaseVersion: 0.1.4
configChecksum: c78571211c83f4afeeaed43ac964a7c8
features:
go:
additionalDependencies: 0.1.0
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/.speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: true
go:
version: 0.1.3
version: 0.1.4
additionalDependencies: {}
allowUnknownFieldsInWeakUnions: false
clientServerStatusCodesAsErrors: true
Expand Down
1 change: 1 addition & 0 deletions pkg/client/docs/models/components/trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- |
| `Event` | *string* | :heavy_check_mark: | N/A |
| `WorkflowID` | *string* | :heavy_check_mark: | N/A |
| `Version` | **string* | :heavy_minus_sign: | N/A |
| `Filter` | **string* | :heavy_minus_sign: | N/A |
| `Vars` | map[string]*any* | :heavy_minus_sign: | N/A |
| `Name` | **string* | :heavy_minus_sign: | N/A |
Expand Down
1 change: 1 addition & 0 deletions pkg/client/docs/models/components/triggerdata.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| ------------------ | ------------------ | ------------------ | ------------------ |
| `Event` | *string* | :heavy_check_mark: | N/A |
| `WorkflowID` | *string* | :heavy_check_mark: | N/A |
| `Version` | **string* | :heavy_minus_sign: | N/A |
| `Filter` | **string* | :heavy_minus_sign: | N/A |
| `Vars` | map[string]*any* | :heavy_minus_sign: | N/A |
| `Name` | **string* | :heavy_minus_sign: | N/A |
1 change: 1 addition & 0 deletions pkg/client/docs/models/components/v2trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- |
| `Event` | *string* | :heavy_check_mark: | N/A |
| `WorkflowID` | *string* | :heavy_check_mark: | N/A |
| `Version` | **string* | :heavy_minus_sign: | N/A |
| `Filter` | **string* | :heavy_minus_sign: | N/A |
| `Vars` | map[string]*any* | :heavy_minus_sign: | N/A |
| `Name` | **string* | :heavy_minus_sign: | N/A |
Expand Down
1 change: 1 addition & 0 deletions pkg/client/docs/models/components/v2triggerdata.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| ------------------ | ------------------ | ------------------ | ------------------ |
| `Event` | *string* | :heavy_check_mark: | N/A |
| `WorkflowID` | *string* | :heavy_check_mark: | N/A |
| `Version` | **string* | :heavy_minus_sign: | N/A |
| `Filter` | **string* | :heavy_minus_sign: | N/A |
| `Vars` | map[string]*any* | :heavy_minus_sign: | N/A |
| `Name` | **string* | :heavy_minus_sign: | N/A |
178 changes: 178 additions & 0 deletions pkg/client/formance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package client

import (
"context"
"fmt"
"github.com/formancehq/flows/pkg/client/internal/hooks"
"github.com/formancehq/flows/pkg/client/internal/utils"
"github.com/formancehq/flows/pkg/client/models/components"
"github.com/formancehq/flows/pkg/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
Security func(context.Context) (interface{}, error)
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 {
Orchestration *Orchestration

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
}
}

// WithSecurity configures the SDK to use the provided security details
func WithSecurity(security components.Security) SDKOption {
return func(sdk *Formance) {
sdk.sdkConfiguration.Security = utils.AsSecuritySource(security)
}
}

// WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication
func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption {
return func(sdk *Formance) {
sdk.sdkConfiguration.Security = func(ctx context.Context) (interface{}, error) {
return security(ctx)
}
}
}

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: "0.1.0",
SDKVersion: "0.8.0",
GenVersion: "2.409.8",
UserAgent: "speakeasy-sdk/go 0.8.0 2.409.8 0.1.0 github.com/formancehq/flows/pkg/client",
Hooks: hooks.New(),
},
}
for _, opt := range opts {
opt(sdk)
}

if sdk.sdkConfiguration.Security == nil {
var envVarSecurity components.Security
if utils.PopulateSecurityFromEnv(&envVarSecurity) {
sdk.sdkConfiguration.Security = utils.AsSecuritySource(envVarSecurity)
}
}

// 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.Orchestration = newOrchestration(sdk.sdkConfiguration)

return sdk
}
8 changes: 8 additions & 0 deletions pkg/client/models/components/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
type Trigger struct {
Event string `json:"event"`
WorkflowID string `json:"workflowID"`
Version *string `json:"version,omitempty"`
Filter *string `json:"filter,omitempty"`
Vars map[string]any `json:"vars,omitempty"`
Name *string `json:"name,omitempty"`
Expand Down Expand Up @@ -42,6 +43,13 @@ func (o *Trigger) GetWorkflowID() string {
return o.WorkflowID
}

func (o *Trigger) GetVersion() *string {
if o == nil {
return nil
}
return o.Version
}

func (o *Trigger) GetFilter() *string {
if o == nil {
return nil
Expand Down
8 changes: 8 additions & 0 deletions pkg/client/models/components/triggerdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package components
type TriggerData struct {
Event string `json:"event"`
WorkflowID string `json:"workflowID"`
Version *string `json:"version,omitempty"`
Filter *string `json:"filter,omitempty"`
Vars map[string]any `json:"vars,omitempty"`
Name *string `json:"name,omitempty"`
Expand All @@ -24,6 +25,13 @@ func (o *TriggerData) GetWorkflowID() string {
return o.WorkflowID
}

func (o *TriggerData) GetVersion() *string {
if o == nil {
return nil
}
return o.Version
}

func (o *TriggerData) GetFilter() *string {
if o == nil {
return nil
Expand Down
8 changes: 8 additions & 0 deletions pkg/client/models/components/v2trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
type V2Trigger struct {
Event string `json:"event"`
WorkflowID string `json:"workflowID"`
Version *string `json:"version,omitempty"`
Filter *string `json:"filter,omitempty"`
Vars map[string]any `json:"vars,omitempty"`
Name *string `json:"name,omitempty"`
Expand Down Expand Up @@ -42,6 +43,13 @@ func (o *V2Trigger) GetWorkflowID() string {
return o.WorkflowID
}

func (o *V2Trigger) GetVersion() *string {
if o == nil {
return nil
}
return o.Version
}

func (o *V2Trigger) GetFilter() *string {
if o == nil {
return nil
Expand Down
8 changes: 8 additions & 0 deletions pkg/client/models/components/v2triggerdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package components
type V2TriggerData struct {
Event string `json:"event"`
WorkflowID string `json:"workflowID"`
Version *string `json:"version,omitempty"`
Filter *string `json:"filter,omitempty"`
Vars map[string]any `json:"vars,omitempty"`
Name *string `json:"name,omitempty"`
Expand All @@ -24,6 +25,13 @@ func (o *V2TriggerData) GetWorkflowID() string {
return o.WorkflowID
}

func (o *V2TriggerData) GetVersion() *string {
if o == nil {
return nil
}
return o.Version
}

func (o *V2TriggerData) GetFilter() *string {
if o == nil {
return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ func New(opts ...SDKOption) *SDK {
sdkConfiguration: sdkConfiguration{
Language: "go",
OpenAPIDocVersion: "0.1.0",
SDKVersion: "0.1.3",
SDKVersion: "0.1.4",
GenVersion: "2.384.1",
UserAgent: "speakeasy-sdk/go 0.1.3 2.384.1 0.1.0 openapi",
UserAgent: "speakeasy-sdk/go 0.1.4 2.384.1 0.1.0 openapi",
Hooks: hooks.New(),
},
}
Expand Down