turso

package
v0.88.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPaymentRequired = errors.New("payment required")

Functions

func CheckName

func CheckName(name string) error

func LocationsTable

func LocationsTable(columns []interface{}) table.Table

func ProbeLocation

func ProbeLocation(location string) *time.Duration

Types

type ApiToken

type ApiToken struct {
	ID     string `json:"dbId"`
	Name   string
	Owner  uint
	PubKey []byte
}

type ApiTokensClient

type ApiTokensClient client

func (*ApiTokensClient) Create

func (a *ApiTokensClient) Create(name string) (CreateApiToken, error)

func (*ApiTokensClient) List

func (a *ApiTokensClient) List() ([]ApiToken, error)

func (*ApiTokensClient) Revoke

func (a *ApiTokensClient) Revoke(name string) error

type BillingClient

type BillingClient client

func (*BillingClient) CreateStripeCustomer

func (c *BillingClient) CreateStripeCustomer(name string) (string, error)

func (*BillingClient) HasPaymentMethod

func (c *BillingClient) HasPaymentMethod() (bool, error)

func (*BillingClient) HasPaymentMethodWithStripeId

func (c *BillingClient) HasPaymentMethodWithStripeId(stripeId string) (bool, error)

func (*BillingClient) Portal

func (c *BillingClient) Portal() (Portal, error)

func (*BillingClient) PortalForStripeId

func (c *BillingClient) PortalForStripeId(stripeId string) (Portal, error)

type Body

type Body struct {
	Org string `json:"org"`
}

type Client

type Client struct {
	Org string

	Instances     *InstancesClient
	Databases     *DatabasesClient
	Feedback      *FeedbackClient
	Organizations *OrganizationsClient
	ApiTokens     *ApiTokensClient
	Locations     *LocationsClient
	Tokens        *TokensClient
	Users         *UsersClient
	Plans         *PlansClient
	Subscriptions *SubscriptionClient
	Billing       *BillingClient
	Groups        *GroupsClient
	// contains filtered or unexported fields
}

Collection of all turso clients

func New

func New(base *url.URL, token string, cliVersion string, org string) *Client

func (*Client) Delete

func (t *Client) Delete(path string, body io.Reader) (*http.Response, error)

func (*Client) Get

func (t *Client) Get(path string, body io.Reader) (*http.Response, error)

func (*Client) Patch

func (t *Client) Patch(path string, body io.Reader) (*http.Response, error)

func (*Client) Post

func (t *Client) Post(path string, body io.Reader) (*http.Response, error)

func (*Client) Upload

func (t *Client) Upload(path string, fileData *os.File) (*http.Response, error)

type ClosestLocationResponse

type ClosestLocationResponse struct {
	Server string
}

type CreateApiToken

type CreateApiToken struct {
	Name  string `json:"name"`
	ID    string `json:"id"`
	Value string `json:"value"`
}

type CreateDatabaseBody

type CreateDatabaseBody struct {
	Name       string  `json:"name"`
	Location   string  `json:"location"`
	Image      string  `json:"image,omitempty"`
	Extensions string  `json:"extensions,omitempty"`
	Group      string  `json:"group,omitempty"`
	Seed       *DBSeed `json:"seed,omitempty"`
}

type CreateDatabaseResponse

type CreateDatabaseResponse struct {
	Database Database
	Username string
}

type CreateInstanceLocationError

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

func (*CreateInstanceLocationError) Error

type DBSeed

type DBSeed struct {
	Type      string     `json:"type"`
	Name      string     `json:"value,omitempty"`
	URL       string     `json:"url,omitempty"`
	Timestamp *time.Time `json:"timestamp,omitempty"`
}

type Database

type Database struct {
	ID            string `json:"dbId" mapstructure:"dbId"`
	Name          string
	Regions       []string
	PrimaryRegion string
	Hostname      string
	Version       string
	Group         string
}

type DatabasesClient

type DatabasesClient client

func (*DatabasesClient) Create

func (d *DatabasesClient) Create(name, location, image, extensions, group string, seed *DBSeed) (*CreateDatabaseResponse, error)

func (*DatabasesClient) Delete

func (d *DatabasesClient) Delete(database string) error

func (*DatabasesClient) List

func (d *DatabasesClient) List() ([]Database, error)

func (*DatabasesClient) Rotate

func (d *DatabasesClient) Rotate(database string) error

func (*DatabasesClient) Seed

func (d *DatabasesClient) Seed(name string, dbFile *os.File) error

func (*DatabasesClient) Stats added in v0.88.3

func (d *DatabasesClient) Stats(database string) (Stats, error)

func (*DatabasesClient) Token

func (d *DatabasesClient) Token(database string, expiration string, readOnly bool) (string, error)

func (*DatabasesClient) Transfer

func (d *DatabasesClient) Transfer(database, org string) error

func (*DatabasesClient) URL

func (d *DatabasesClient) URL(suffix string) string

func (*DatabasesClient) Update

func (d *DatabasesClient) Update(database string, group bool) error

func (*DatabasesClient) UploadDump

func (d *DatabasesClient) UploadDump(dbFile *os.File) (string, error)

func (*DatabasesClient) Usage

func (d *DatabasesClient) Usage(database string) (DbUsage, error)

type DbUsage

type DbUsage struct {
	UUID      string          `json:"uuid,omitempty"`
	Instances []InstanceUsage `json:"instances"`
	Usage     Usage           `json:"usage"`
}

type DbUsageResponse

type DbUsageResponse struct {
	DbUsage DbUsage `json:"database"`
}

type FeedbackClient

type FeedbackClient client

func (*FeedbackClient) Submit

func (d *FeedbackClient) Submit(summary, feedback string) error

type Group

type Group struct {
	Name      string   `json:"name"`
	Locations []string `json:"locations"`
	Primary   string   `json:"primary"`
	Archived  bool     `json:"archived"`
}

type GroupsClient

type GroupsClient client

func (*GroupsClient) AddLocation

func (d *GroupsClient) AddLocation(name, location string) error

func (*GroupsClient) Create

func (d *GroupsClient) Create(name, location, version string) error

func (*GroupsClient) Delete

func (d *GroupsClient) Delete(group string) error

func (*GroupsClient) Get

func (d *GroupsClient) Get(name string) (Group, error)

func (*GroupsClient) List

func (d *GroupsClient) List() ([]Group, error)

func (*GroupsClient) RemoveLocation

func (d *GroupsClient) RemoveLocation(name, location string) error

func (*GroupsClient) Rotate

func (d *GroupsClient) Rotate(group string) error

func (*GroupsClient) Token

func (d *GroupsClient) Token(group string, expiration string, readOnly bool) (string, error)

func (*GroupsClient) Transfer added in v0.88.0

func (d *GroupsClient) Transfer(group string, to string) error

func (*GroupsClient) URL

func (d *GroupsClient) URL(suffix string) string

func (*GroupsClient) Unarchive added in v0.87.5

func (d *GroupsClient) Unarchive(name string) error

func (*GroupsClient) Update added in v0.87.8

func (d *GroupsClient) Update(group string, version, extensions string) error

func (*GroupsClient) WaitLocation added in v0.86.2

func (d *GroupsClient) WaitLocation(name, location string) error

type Instance

type Instance struct {
	Uuid     string
	Name     string
	Type     string
	Region   string
	Hostname string
}

type InstanceUsage

type InstanceUsage struct {
	UUID  string `json:"uuid,omitempty"`
	Usage Usage  `json:"usage"`
}

type InstancesClient

type InstancesClient client

func (*InstancesClient) Create

func (d *InstancesClient) Create(dbName, location string) (*Instance, error)

func (*InstancesClient) Delete

func (i *InstancesClient) Delete(db, instance string) error

func (*InstancesClient) List

func (i *InstancesClient) List(db string) ([]Instance, error)

func (*InstancesClient) URL

func (d *InstancesClient) URL(database, suffix string) string

func (*InstancesClient) Wait

func (i *InstancesClient) Wait(db, instance string) error

type Invite

type Invite struct {
	Email string `json:"email,omitempty"`
	Role  string `json:"role,omitempty"`
}

type Location

type Location struct {
	Code        string `json:"code"`
	Description string `json:"description"`
}

type LocationResponse

type LocationResponse struct {
	Code        string `json:"code"`
	Description string `json:"description"`
	Closest     []Location
}

type LocationsClient

type LocationsClient client

func (*LocationsClient) Closest

func (c *LocationsClient) Closest() (string, error)

func (*LocationsClient) Get

func (c *LocationsClient) Get(location string) (LocationResponse, error)

func (*LocationsClient) List

func (c *LocationsClient) List() (map[string]string, error)

type LocationsResponse

type LocationsResponse struct {
	Locations map[string]string
}

type Member

type Member struct {
	Name string `json:"username,omitempty"`
	Role string `json:"role,omitempty"`
}

type OrgTotal

type OrgTotal struct {
	RowsRead         uint64 `json:"rows_read,omitempty"`
	RowsWritten      uint64 `json:"rows_written,omitempty"`
	StorageBytesUsed uint64 `json:"storage_bytes,omitempty"`
	Databases        uint64 `json:"databases,omitempty"`
	Locations        uint64 `json:"locations,omitempty"`
}

type OrgUsage

type OrgUsage struct {
	UUID      string    `json:"uuid,omitempty"`
	Usage     OrgTotal  `json:"usage"`
	Databases []DbUsage `json:"databases"`
}

type OrgUsageResponse

type OrgUsageResponse struct {
	OrgUsage OrgUsage `json:"organization"`
}

type Organization

type Organization struct {
	Name     string `json:"name,omitempty"`
	Slug     string `json:"slug,omitempty"`
	Type     string `json:"type,omitempty"`
	StripeID string `json:"stripe_id,omitempty"`
	Overages bool   `json:"overages,omitempty"`
}

type OrganizationsClient

type OrganizationsClient client

func (*OrganizationsClient) AddMember

func (c *OrganizationsClient) AddMember(username, role string) error

func (*OrganizationsClient) Create

func (c *OrganizationsClient) Create(name string, stripeId string, dryRun bool) (Organization, error)

func (*OrganizationsClient) Delete

func (c *OrganizationsClient) Delete(slug string) error

func (*OrganizationsClient) InviteMember

func (c *OrganizationsClient) InviteMember(email, role string) error

func (*OrganizationsClient) List

func (c *OrganizationsClient) List() ([]Organization, error)

func (*OrganizationsClient) ListMembers

func (c *OrganizationsClient) ListMembers() ([]Member, error)

func (*OrganizationsClient) MembersURL

func (c *OrganizationsClient) MembersURL(suffix string) (string, error)

func (*OrganizationsClient) RemoveMember

func (c *OrganizationsClient) RemoveMember(username string) error

func (*OrganizationsClient) SetOverages

func (c *OrganizationsClient) SetOverages(slug string, toggle bool) error

func (*OrganizationsClient) Usage

func (c *OrganizationsClient) Usage() (OrgUsage, error)

type Plan

type Plan struct {
	Name   string `json:"name"`
	Price  string `json:"price"`
	Quotas struct {
		RowsRead    uint64 `json:"rowsRead"`
		RowsWritten uint64 `json:"rowsWritten"`
		Databases   uint64 `json:"databases"`
		Locations   uint64 `json:"locations"`
		Storage     uint64 `json:"storage"`
	}
}

type PlansClient

type PlansClient client

func (*PlansClient) List

func (c *PlansClient) List() ([]Plan, error)

type Portal

type Portal struct {
	URL string `json:"url"`
}

type Stats added in v0.88.3

type Stats struct {
	TopQueries []struct {
		Query       string `json:"query"`
		RowsRead    int    `json:"rows_read"`
		RowsWritten int    `json:"rows_written"`
	} `json:"top_queries,omitempty"`
}

type SubscriptionClient

type SubscriptionClient client

func (*SubscriptionClient) Get

func (c *SubscriptionClient) Get() (string, error)

func (*SubscriptionClient) Set

func (c *SubscriptionClient) Set(plan string) error

type TokensClient

type TokensClient client

func (*TokensClient) Validate

func (c *TokensClient) Validate(token string) (int64, error)

type Usage

type Usage struct {
	RowsRead         uint64 `json:"rows_read,omitempty"`
	RowsWritten      uint64 `json:"rows_written,omitempty"`
	StorageBytesUsed uint64 `json:"storage_bytes,omitempty"`
}

type UserInfo

type UserInfo struct {
	Username string `json:"username"`
	Plan     string `json:"plan"`
}

type UserInfoResponse

type UserInfoResponse struct {
	User UserInfo `json:"user"`
}

type UsersClient

type UsersClient client

func (*UsersClient) GetUser

func (u *UsersClient) GetUser() (UserInfo, error)

Jump to

Keyboard shortcuts

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