deployserverclient

package module
v0.0.0-...-c1d85d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 13 Imported by: 0

README

github.com/formancehq/fctl/internal/deployserverclient

Developer-friendly & type-safe Go SDK specifically catered to leverage github.com/formancehq/fctl/internal/deployserverclient API.



[!IMPORTANT] This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.

Summary

Table of Contents

SDK Installation

To add the SDK as a dependency to your project:

go get github.com/formancehq/fctl/internal/deployserverclient

SDK Example Usage

Example
package main

import (
	"context"
	"github.com/formancehq/fctl/internal/deployserverclient"
	"log"
)

func main() {
	ctx := context.Background()

	s := deployserverclient.New()

	res, err := s.ListApps(ctx, "<id>", nil, nil)
	if err != nil {
		log.Fatal(err)
	}
	if res.ListAppsResponse != nil {
		// handle response
	}
}

Available Resources and Operations

Available methods
DeployServer SDK

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:

package main

import (
	"context"
	"github.com/formancehq/fctl/internal/deployserverclient"
	"github.com/formancehq/fctl/internal/deployserverclient/retry"
	"log"
	"models/operations"
)

func main() {
	ctx := context.Background()

	s := deployserverclient.New()

	res, err := s.ListApps(ctx, "<id>", nil, nil, 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.ListAppsResponse != 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:

package main

import (
	"context"
	"github.com/formancehq/fctl/internal/deployserverclient"
	"github.com/formancehq/fctl/internal/deployserverclient/retry"
	"log"
)

func main() {
	ctx := context.Background()

	s := deployserverclient.New(
		deployserverclient.WithRetryConfig(
			retry.Config{
				Strategy: "backoff",
				Backoff: &retry.BackoffStrategy{
					InitialInterval: 1,
					MaxInterval:     50,
					Exponent:        1.1,
					MaxElapsedTime:  100,
				},
				RetryConnectionErrors: false,
			}),
	)

	res, err := s.ListApps(ctx, "<id>", nil, nil)
	if err != nil {
		log.Fatal(err)
	}
	if res.ListAppsResponse != 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.

By Default, an API error will return apierrors.APIError. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective Errors tables in SDK docs for more details on possible error types for each operation.

For example, the ListApps function may return the following errors:

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*
Example
package main

import (
	"context"
	"errors"
	"github.com/formancehq/fctl/internal/deployserverclient"
	"github.com/formancehq/fctl/internal/deployserverclient/models/apierrors"
	"log"
)

func main() {
	ctx := context.Background()

	s := deployserverclient.New()

	res, err := s.ListApps(ctx, "<id>", nil, nil)
	if err != nil {

		var e *apierrors.APIError
		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(serverIndex int) 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 Description
0 https://deploy-server.staging.formance.cloud Staging server
1 https://deploy-server.formance.cloud Production server
2 http://localhost:8080 Local server
Example
package main

import (
	"context"
	"github.com/formancehq/fctl/internal/deployserverclient"
	"log"
)

func main() {
	ctx := context.Background()

	s := deployserverclient.New(
		deployserverclient.WithServerIndex(0),
	)

	res, err := s.ListApps(ctx, "<id>", nil, nil)
	if err != nil {
		log.Fatal(err)
	}
	if res.ListAppsResponse != nil {
		// handle response
	}
}

Override Server URL Per-Client

The default server can also be overridden globally using the WithServerURL(serverURL string) option when initializing the SDK client instance. For example:

package main

import (
	"context"
	"github.com/formancehq/fctl/internal/deployserverclient"
	"log"
)

func main() {
	ctx := context.Background()

	s := deployserverclient.New(
		deployserverclient.WithServerURL("http://localhost:8080"),
	)

	res, err := s.ListApps(ctx, "<id>", nil, nil)
	if err != nil {
		log.Fatal(err)
	}
	if res.ListAppsResponse != 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:

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.

import (
	"net/http"
	"time"

	"github.com/formancehq/fctl/internal/deployserverclient"
)

var (
	httpClient = &http.Client{Timeout: 30 * time.Second}
	sdkClient  = deployserverclient.New(deployserverclient.WithClient(httpClient))
)

This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerList = []string{

	"https://deploy-server.staging.formance.cloud",

	"https://deploy-server.formance.cloud",

	"http://localhost:8080",
}

ServerList contains the list of servers available to the SDK

Functions

func Bool

func Bool(b bool) *bool

Bool provides a helper function to return a pointer to a bool

func Float32

func Float32(f float32) *float32

Float32 provides a helper function to return a pointer to a float32

func Float64

func Float64(f float64) *float64

Float64 provides a helper function to return a pointer to a float64

func Int

func Int(i int) *int

Int provides a helper function to return a pointer to an int

func Int64

func Int64(i int64) *int64

Int64 provides a helper function to return a pointer to an int64

func Pointer

func Pointer[T any](v T) *T

Pointer provides a helper function to return a pointer to a type

func String

func String(s string) *string

String provides a helper function to return a pointer to a string

Types

type DeployServer

type DeployServer struct {
	SDKVersion string
	// contains filtered or unexported fields
}

func New

func New(opts ...SDKOption) *DeployServer

New creates a new instance of the SDK with the provided options

func (*DeployServer) CreateApp

CreateApp - Create a new app

func (*DeployServer) CreateAppVariable

func (s *DeployServer) CreateAppVariable(ctx context.Context, id string, createVariableRequest components.CreateVariableRequest, opts ...operations.Option) (*operations.CreateAppVariableResponse, error)

CreateAppVariable - Create variable for an app

func (*DeployServer) DeleteApp

DeleteApp - Delete an app

func (*DeployServer) DeleteAppVariable

func (s *DeployServer) DeleteAppVariable(ctx context.Context, id string, variableID string, opts ...operations.Option) (*operations.DeleteAppVariableResponse, error)

DeleteAppVariable - Delete a variable from an app

func (*DeployServer) DeployAppConfiguration

func (s *DeployServer) DeployAppConfiguration(ctx context.Context, id string, application components.Application, opts ...operations.Option) (*operations.DeployAppConfigurationResponse, error)

DeployAppConfiguration - Deploy a new configuration for an app

func (*DeployServer) DeployAppConfigurationRaw

func (s *DeployServer) DeployAppConfigurationRaw(ctx context.Context, id string, application any, opts ...operations.Option) (*operations.DeployAppConfigurationRawResponse, error)

DeployAppConfigurationRaw - Deploy a new configuration for an app

func (*DeployServer) ListApps

func (s *DeployServer) ListApps(ctx context.Context, organizationID string, pageNumber *int64, pageSize *int64, opts ...operations.Option) (*operations.ListAppsResponse, error)

ListApps - List organization apps

func (*DeployServer) ReadApp

ReadApp - read app details

func (*DeployServer) ReadAppCurrentStateVersion

func (s *DeployServer) ReadAppCurrentStateVersion(ctx context.Context, id string, opts ...operations.Option) (*operations.ReadAppCurrentStateVersionResponse, error)

ReadAppCurrentStateVersion - Get the current state version of an app

func (*DeployServer) ReadAppRuns

func (s *DeployServer) ReadAppRuns(ctx context.Context, id string, pageNumber *int64, pageSize *int64, opts ...operations.Option) (*operations.ReadAppRunsResponse, error)

ReadAppRuns - Get runs of an app

func (*DeployServer) ReadAppVariables

func (s *DeployServer) ReadAppVariables(ctx context.Context, id string, pageNumber *int64, pageSize *int64, opts ...operations.Option) (*operations.ReadAppVariablesResponse, error)

ReadAppVariables - Get all variables of an app

func (*DeployServer) ReadAppVersions

func (s *DeployServer) ReadAppVersions(ctx context.Context, id string, pageNumber *int64, pageSize *int64, opts ...operations.Option) (*operations.ReadAppVersionsResponse, error)

ReadAppVersions - Get versions of an app

func (*DeployServer) ReadCurrentAppVersion

func (s *DeployServer) ReadCurrentAppVersion(ctx context.Context, id string, from *operations.From, opts ...operations.Option) (*operations.ReadCurrentAppVersionResponse, error)

ReadCurrentAppVersion - Get the current version of an app

func (*DeployServer) ReadCurrentRun

func (s *DeployServer) ReadCurrentRun(ctx context.Context, id string, opts ...operations.Option) (*operations.ReadCurrentRunResponse, error)

ReadCurrentRun - Get the current run of an app

func (*DeployServer) ReadCurrentRunLogs

func (s *DeployServer) ReadCurrentRunLogs(ctx context.Context, id string, opts ...operations.Option) (*operations.ReadCurrentRunLogsResponse, error)

ReadCurrentRunLogs - Get logs of the current run of an app

func (*DeployServer) ReadRun

ReadRun - Get the run of a version

func (*DeployServer) ReadRunLogs

ReadRunLogs - Get logs of a run by its ID

func (*DeployServer) ReadVersion

ReadVersion - Get a specific version

func (*DeployServer) UpdateApp

func (s *DeployServer) UpdateApp(ctx context.Context, id string, updateAppRequest components.UpdateAppRequest, opts ...operations.Option) (*operations.UpdateAppResponse, error)

UpdateApp - Update an app

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient provides an interface for supplying the SDK with a custom HTTP client

type SDKOption

type SDKOption func(*DeployServer)

func WithClient

func WithClient(client HTTPClient) SDKOption

WithClient allows the overriding of the default HTTP client used by the SDK

func WithRetryConfig

func WithRetryConfig(retryConfig retry.Config) SDKOption

func WithServerIndex

func WithServerIndex(serverIndex int) SDKOption

WithServerIndex allows the overriding of the default server by index

func WithServerURL

func WithServerURL(serverURL string) SDKOption

WithServerURL allows the overriding of the default server URL

func WithTemplatedServerURL

func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption

WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters

func WithTimeout

func WithTimeout(timeout time.Duration) SDKOption

WithTimeout Optional request timeout applied to each operation

Directories

Path Synopsis
internal
models

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL