northflankgo

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 11 Imported by: 0

README

Go SDK

The comprehensive developer platform to build and scale microservices, jobs and managed databases with a powerful UI, API & CLI.

SDK Installation

go get github.com/speakeasy-sdks/northflank-go

SDK Example Usage

Example

package main

import (
	"context"
	northflankgo "github.com/speakeasy-sdks/northflank-go/v2"
	"github.com/speakeasy-sdks/northflank-go/v2/pkg/models/shared"
	"log"
)

func main() {
	s := northflankgo.New(
		northflankgo.WithSecurity(shared.Security{
			BasicAuth: &shared.SchemeBasicAuth{
				Password: "<YOUR_PASSWORD_HERE>",
				Username: "<YOUR_USERNAME_HERE>",
			},
		}),
	)

	ctx := context.Background()
	res, err := s.Miscellaneous.GetDNSID(ctx)
	if err != nil {
		log.Fatal(err)
	}

	if res.DNSIDResult != nil {
		// handle response
	}
}

Available Resources and Operations

Miscellaneous

Addons

Billing

CloudProviders

Domains

Integrations

Special Types

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.APIErrorResult 409 application/json
sdkerrors.SDKError 400-600 /

Example

package main

import (
	"context"
	"errors"
	northflankgo "github.com/speakeasy-sdks/northflank-go/v2"
	"github.com/speakeasy-sdks/northflank-go/v2/pkg/models/sdkerrors"
	"github.com/speakeasy-sdks/northflank-go/v2/pkg/models/shared"
	"log"
)

func main() {
	s := northflankgo.New(
		northflankgo.WithSecurity(shared.Security{
			BasicAuth: &shared.SchemeBasicAuth{
				Password: "<YOUR_PASSWORD_HERE>",
				Username: "<YOUR_USERNAME_HERE>",
			},
		}),
	)

	var clusterID string = "gcp-cluster-1"

	ctx := context.Background()
	res, err := s.CloudProviders.DeleteCluster(ctx, clusterID)
	if err != nil {

		var e *sdkerrors.APIErrorResult
		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 https://api.northflank.com None
Example
package main

import (
	"context"
	northflankgo "github.com/speakeasy-sdks/northflank-go/v2"
	"github.com/speakeasy-sdks/northflank-go/v2/pkg/models/shared"
	"log"
)

func main() {
	s := northflankgo.New(
		northflankgo.WithServerIndex(0),
		northflankgo.WithSecurity(shared.Security{
			BasicAuth: &shared.SchemeBasicAuth{
				Password: "<YOUR_PASSWORD_HERE>",
				Username: "<YOUR_USERNAME_HERE>",
			},
		}),
	)

	ctx := context.Background()
	res, err := s.Miscellaneous.GetDNSID(ctx)
	if err != nil {
		log.Fatal(err)
	}

	if res.DNSIDResult != 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:

package main

import (
	"context"
	northflankgo "github.com/speakeasy-sdks/northflank-go/v2"
	"github.com/speakeasy-sdks/northflank-go/v2/pkg/models/shared"
	"log"
)

func main() {
	s := northflankgo.New(
		northflankgo.WithServerURL("https://api.northflank.com"),
		northflankgo.WithSecurity(shared.Security{
			BasicAuth: &shared.SchemeBasicAuth{
				Password: "<YOUR_PASSWORD_HERE>",
				Username: "<YOUR_USERNAME_HERE>",
			},
		}),
	)

	ctx := context.Background()
	res, err := s.Miscellaneous.GetDNSID(ctx)
	if err != nil {
		log.Fatal(err)
	}

	if res.DNSIDResult != 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/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.

Authentication

Per-Client Security Schemes

This SDK supports the following security schemes globally:

Name Type Scheme
BasicAuth http HTTP Basic
BearerAuth http HTTP Bearer

You can set the security parameters through the WithSecurity option when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:

package main

import (
	"context"
	northflankgo "github.com/speakeasy-sdks/northflank-go/v2"
	"github.com/speakeasy-sdks/northflank-go/v2/pkg/models/shared"
	"log"
)

func main() {
	s := northflankgo.New(
		northflankgo.WithSecurity(shared.Security{
			BasicAuth: &shared.SchemeBasicAuth{
				Password: "<YOUR_PASSWORD_HERE>",
				Username: "<YOUR_USERNAME_HERE>",
			},
		}),
	)

	ctx := context.Background()
	res, err := s.Miscellaneous.GetDNSID(ctx)
	if err != nil {
		log.Fatal(err)
	}

	if res.DNSIDResult != nil {
		// handle response
	}
}

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. Feel free to open a PR or a Github issue as 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://api.northflank.com",
}

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 String

func String(s string) *string

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

Types

type Addons

type Addons struct {
	// contains filtered or unexported fields
}

func (*Addons) ListAddonTypes

func (s *Addons) ListAddonTypes(ctx context.Context) (*operations.ListAddonTypesResponse, error)

ListAddonTypes - List addon types Gets information about the available addon types

type Billing

type Billing struct {
	// contains filtered or unexported fields
}

func (*Billing) Get

func (s *Billing) Get(ctx context.Context, cursor *string, page *int64, perPage *int64) (*operations.GetPastInvoicesResponse, error)

Get - List invoices Get a list of past invoices

func (*Billing) GetDetails

GetDetails - Get invoice details Get details about an invoice. If `timestamp` is passed in as a query parameter, this endpoint returns details about the invoice containing that timestamp. Otherwise, returns a preview invoice displaying billing data from after the most recent invoice.

type CloudProviders

type CloudProviders struct {
	// contains filtered or unexported fields
}

func (*CloudProviders) Create

Create integration Creates a new integration.

func (*CloudProviders) CreateCluster

CreateCluster - Create cluster Creates a new cluster.

func (*CloudProviders) DeleteCluster

func (s *CloudProviders) DeleteCluster(ctx context.Context, clusterID string) (*operations.DeleteClusterResponse, error)

DeleteCluster - Delete cluster Delete the given cluster. Fails if the cluster has associated projects.

func (*CloudProviders) DeleteIntegration

func (s *CloudProviders) DeleteIntegration(ctx context.Context, integrationID string) (*operations.DeleteIntegrationResponse, error)

DeleteIntegration - Delete integration Delete the given integration. Fails if the integration is associated with existing clusters.

func (*CloudProviders) Get

Get - List providers Lists supported cloud providers

func (*CloudProviders) GetCluster

func (s *CloudProviders) GetCluster(ctx context.Context, clusterID string) (*operations.GetClusterResponse, error)

GetCluster - Get cluster Get information about the given cluster

func (*CloudProviders) GetIntegration

func (s *CloudProviders) GetIntegration(ctx context.Context, integrationID string) (*operations.GetIntegrationResponse, error)

GetIntegration - Get integration Get information about the given integration

func (*CloudProviders) ListClusters

func (s *CloudProviders) ListClusters(ctx context.Context, cursor *string, page *int64, perPage *int64) (*operations.GetClustersResponse, error)

ListClusters - List clusters Lists clusters for the authenticated user or team.

func (*CloudProviders) ListIntegrations

func (s *CloudProviders) ListIntegrations(ctx context.Context, cursor *string, page *int64, perPage *int64) (*operations.GetIntegrationsResponse, error)

ListIntegrations - List integrations Lists integrations for the authenticated user or team.

func (*CloudProviders) UpdateCluster

func (s *CloudProviders) UpdateCluster(ctx context.Context, updateClusterRequest shared.UpdateClusterRequest, clusterID string) (*operations.UpdateClusterResponse, error)

UpdateCluster - Update cluster Update an existing cluster.

func (*CloudProviders) UpdateIntegration

func (s *CloudProviders) UpdateIntegration(ctx context.Context, updateIntegrationRequest shared.UpdateIntegrationRequest, integrationID string) (*operations.UpdateIntegrationResponse, error)

UpdateIntegration - Update integration Update information about the given integration

type Domains

type Domains struct {
	// contains filtered or unexported fields
}

func (*Domains) Add

func (s *Domains) Add(ctx context.Context, addSubDomainRequest shared.AddSubDomainRequest, domain string) (*operations.AddSubDomainResponse, error)

Add subdomain Adds a new subdomain to the domain.

func (*Domains) Assign

func (s *Domains) Assign(ctx context.Context, assignSubDomainRequest shared.AssignSubDomainRequest, domain string, subdomain string) (*operations.AssignSubDomainResponse, error)

Assign service to subdomain Assigns a service port to the given subdomain

func (*Domains) Create

Create new domain Registers a new domain

func (*Domains) Delete

func (s *Domains) Delete(ctx context.Context, domain string) (*operations.DeleteDomainResponse, error)

Delete domain Deletes a domain and each of its registered subdomains.

func (*Domains) DeleteCdn

func (s *Domains) DeleteCdn(ctx context.Context, cdnRequest shared.CDNRequest, domain string, subdomain string) (*operations.DeleteCDNResponse, error)

DeleteCdn - Remove CDN from a subdomain Removes the CDN integration from the given subdomain

func (*Domains) DeleteSubdomain

func (s *Domains) DeleteSubdomain(ctx context.Context, domain string, subdomain string) (*operations.DeleteSubDomainResponse, error)

DeleteSubdomain - Delete subdomain Removes a subdomain from a domain.

func (*Domains) Enable

func (s *Domains) Enable(ctx context.Context, cdnRequest shared.CDNRequest, domain string, subdomain string) (*operations.EnableCDNResponse, error)

Enable CDN on a subdomain Enables a CDN integration on the given subdomain

func (*Domains) Get

Get domain Get the details about a domain

func (*Domains) GetSubdomain

func (s *Domains) GetSubdomain(ctx context.Context, domain string, subdomain string) (*operations.GetSubDomainResponse, error)

GetSubdomain - Get subdomain Gets details about the given subdomain

func (*Domains) ListDomains

func (s *Domains) ListDomains(ctx context.Context, cursor *string, page *int64, perPage *int64) (*operations.ListDomainsResponse, error)

ListDomains - List domains Lists available domains

func (*Domains) Unassign

func (s *Domains) Unassign(ctx context.Context, domain string, subdomain string) (*operations.UnassignSubDomainResponse, error)

Unassign subdomain Removes a subdomain from its assigned service

func (*Domains) Verify

func (s *Domains) Verify(ctx context.Context, domain string, subdomain string) (*operations.VerifySubDomainResponse, error)

Verify subdomain Gets details about the given subdomain

func (*Domains) VerifyDomain

func (s *Domains) VerifyDomain(ctx context.Context, domain string) (*operations.VerifyDomainResponse, error)

VerifyDomain - Verify domain Attempts to verify the domain

type HTTPClient

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

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

type Integrations

type Integrations struct {
	// contains filtered or unexported fields
}

func (*Integrations) Add

Add registry Adds a new set of container registry credentials to this account.

func (*Integrations) Create

Create log sink Creates a new log sink.

func (*Integrations) Delete

Delete log sink Deletes a log sink.

func (*Integrations) DeleteRegistry

func (s *Integrations) DeleteRegistry(ctx context.Context, credentialID string) (*operations.DeleteRegistryResponse, error)

DeleteRegistry - Delete registry Deletes a set of registry credential data.

func (*Integrations) GenerateVCSToken

func (s *Integrations) GenerateVCSToken(ctx context.Context, customVCSID string, vcsLinkID string) (*operations.GenerateVCSTokenResponse, error)

GenerateVCSToken - Generate VCS token Generate a token for a specific VCS link.

func (*Integrations) Get

Get log sink details Gets details about a given log sink.

func (*Integrations) GetBranches

GetBranches - List branches Gets a list of branches for the repo

func (*Integrations) GetRegistry

func (s *Integrations) GetRegistry(ctx context.Context, credentialID string) (*operations.GetRegistryResponse, error)

GetRegistry - Get registry Views a set of registry credential data.

func (*Integrations) GetRepos

GetRepos - List repositories Gets a list of repositories accessible to this account

func (*Integrations) ListLogSinks

func (s *Integrations) ListLogSinks(ctx context.Context, cursor *string, perPage *int64) (*operations.GetLogSinksResponse, error)

ListLogSinks - List log sinks Gets a list of log sinks added to this account.

func (*Integrations) ListRegistries

func (s *Integrations) ListRegistries(ctx context.Context, cursor *string, perPage *int64) (*operations.GetRegistriesResponse, error)

ListRegistries - List registries Lists the container registry credentials saved to this account. Does not display secrets.

func (*Integrations) ListVcsProviders

func (s *Integrations) ListVcsProviders(ctx context.Context) (*operations.GetVCSProvidersResponse, error)

ListVcsProviders - List VCS providers Lists linked version control providers

func (*Integrations) Pause

Pause log sink Pauses a given log sink.

func (*Integrations) Resume

Resume log sink Resumes a paused log sink.

func (*Integrations) Update

func (s *Integrations) Update(ctx context.Context, logSinkRequest shared.LogSinkRequest, logSinkID string) (*operations.UpdateLogSinkResponse, error)

Update log sink Updates the settings for a log sink.

func (*Integrations) UpdateRegistry

func (s *Integrations) UpdateRegistry(ctx context.Context, requestBody operations.UpdateRegistryRequestBody, credentialID string) (*operations.UpdateRegistryResponse, error)

UpdateRegistry - Update registry Updates a set of registry credential data.

type Miscellaneous

type Miscellaneous struct {
	// contains filtered or unexported fields
}

func (*Miscellaneous) GetDNSID

GetDNSID - Get DNS ID Returns the partially random string used when generating host names for the authenticated account.

func (*Miscellaneous) HealthCheck

HealthCheck - Health check Returns api service status

type Northflank

type Northflank struct {
	Miscellaneous  *Miscellaneous
	Addons         *Addons
	Billing        *Billing
	CloudProviders *CloudProviders
	Domains        *Domains
	Integrations   *Integrations
	// contains filtered or unexported fields
}

Northflank API: This is the API for northflank.com

func New

func New(opts ...SDKOption) *Northflank

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

type SDKOption

type SDKOption func(*Northflank)

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 utils.RetryConfig) SDKOption

func WithSecurity

func WithSecurity(security shared.Security) SDKOption

WithSecurity configures the SDK to use the provided security details

func WithSecuritySource

func WithSecuritySource(security func(context.Context) (shared.Security, error)) SDKOption

WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication

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

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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