fly

package module
v0.0.0-...-104f99f Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 9 Imported by: 0

README

fly-sdk

The unofficial Golang SDK for Fly.io.

Warning This library is very early in development as is not suitable for use in production.

Supports Golang version 1.20+.

Usage/Examples

go get -u github.com/omnilium/fly-sdk@latest
package main

import (
	"context"
	"os"
	"github.com/omnilium/fly-sdk"
)

func main() {
    client, _ := fly.New(os.Getenv("FLY_API_TOKEN"), fly.WithDefaultOrgSlug("personal"))

    apps, _ := client.Apps.List(context.TODO(), nil)
}

Documentation

Documentation

Features

  • Automatic authentication using Access Tokens
  • Apps
  • Machines
  • Volumes
  • DNS Discovery

Feedback

If you have any feedback, please open a new Discussions thread.

Contributing

Contributions are always welcome! To get started, fork the repo, make the changes you desire, and open a PR!

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Name         string       `json:"name"`
	Organization Organization `json:"organization"`
	Status       string       `json:"status"`
}

type AppsClient

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

func (*AppsClient) Create

func (c *AppsClient) Create(ctx context.Context, orgSlug *string, appName string, network *string) error

func (*AppsClient) Delete

func (c *AppsClient) Delete(ctx context.Context, orgSlug *string, appName string) error

func (*AppsClient) Get

func (c *AppsClient) Get(ctx context.Context, orgSlug *string, appName string) (*App, error)

func (*AppsClient) List

func (c *AppsClient) List(ctx context.Context, orgSlug *string) (*ListAppsResponse, error)

type Client

type Client struct {
	Apps *AppsClient
	// contains filtered or unexported fields
}

func New

func New(token string, opt ...ConfigOption) (*Client, error)

func (*Client) Dispatch

func (c *Client) Dispatch(req *http.Request, response any) error

func (*Client) Request

func (c *Client) Request(ctx context.Context, method string, path string, body any) (*http.Request, error)

type Config

type Config struct {
	Host           string
	BasePath       string
	Client         *http.Client
	Token          string
	DefaultOrgSlug string
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) OrgSlug

func (c *Config) OrgSlug(slug *string) string

func (*Config) Validate

func (c *Config) Validate() error

func (*Config) WithOptions

func (c *Config) WithOptions(opts ...ConfigOption) *Config

type ConfigOption

type ConfigOption func(*Config)

func WithBasePath

func WithBasePath(basePath string) ConfigOption

func WithClient

func WithClient(client *http.Client) ConfigOption

func WithDefaultOrgSlug

func WithDefaultOrgSlug(org string) ConfigOption

func WithHost

func WithHost(host string) ConfigOption

func WithToken

func WithToken(token string) ConfigOption

type CreateAppRequest

type CreateAppRequest struct {
	AppName string `json:"app_name"`
	Network string `json:"network"`
	OrgSlug string `json:"org_slug"`
}

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type ListApp

type ListApp struct {
	MachineCount int    `json:"machine_count"`
	Name         string `json:"name"`
}

type ListAppsResponse

type ListAppsResponse struct {
	TotalApps int       `json:"total_apps"`
	Apps      []ListApp `json:"apps"`
}

type MissingBasePathError

type MissingBasePathError struct{}

func (MissingBasePathError) Error

func (e MissingBasePathError) Error() string

type MissingClientError

type MissingClientError struct{}

func (MissingClientError) Error

func (e MissingClientError) Error() string

type MissingHostError

type MissingHostError struct{}

func (MissingHostError) Error

func (e MissingHostError) Error() string

type MissingOrgSlugError

type MissingOrgSlugError struct{}

func (MissingOrgSlugError) Error

func (e MissingOrgSlugError) Error() string

type MissingTokenError

type MissingTokenError struct{}

func (MissingTokenError) Error

func (e MissingTokenError) Error() string

type Organization

type Organization struct {
	Name string `json:"name"`
	Slug string `json:"slug"`
}

type RequestFailedError

type RequestFailedError struct {
	Reason string
}

func (RequestFailedError) Error

func (e RequestFailedError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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