pkg

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package pkg is the top level package for shared libraries

Package pkg is the top level package for shared libraries

Package pkg is the top level package for shared libraries

Package pkg is the top level package for shared libraries

Package pkg is the top level package for shared libraries

Index

Constants

View Source
const (
	// JSONFormat is for the command line flag -o
	JSONFormat = "json"
	// TextFormat is for the command line flag -o
	TextFormat = "text"
)

Variables

View Source
var Env = "prod"

Functions

func FormatErrors added in v0.5.0

func FormatErrors(es []Error) string

FormatErrors puts the API errors into a well formatted text output

func PathWithEnv added in v0.6.0

func PathWithEnv(f string) string

func ReadToken added in v0.2.0

func ReadToken(tokenFile string) (string, error)

ReadToken retrieves the login from the specified json file

func WriteRows added in v0.3.2

func WriteRows(w io.Writer, rows [][]string) error

WriteRows outputs a flexiable right aligned tabwriter

Types

type AuthenticatedClient added in v0.5.0

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

AuthenticatedClient has a token and the methods to query the Astra DevOps API

func Authenticate added in v0.5.0

func Authenticate(clientInfo ClientInfo, verbose bool) (*AuthenticatedClient, error)

func AuthenticateToken added in v0.5.0

func AuthenticateToken(token string, verbose bool) (*AuthenticatedClient, error)

func (*AuthenticatedClient) AddKeyspaceToDb added in v0.5.0

func (a *AuthenticatedClient) AddKeyspaceToDb(databaseID string, keyspaceName string) error

AddKeyspaceToDb Adds keyspace into database * @param databaseID string representation of the database ID * @param keyspaceName Name of database keyspace @return error

func (*AuthenticatedClient) CreateDb added in v0.5.0

CreateDb creates a database in Astra, username and password fields are required only on legacy tiers and waits until it is in a created state * @param createDb Definition of new database @return (Database, error)

func (*AuthenticatedClient) FindDb added in v0.5.0

func (a *AuthenticatedClient) FindDb(databaseID string) (astra.Database, error)

FindDb Returns specified database * @param databaseID string representation of the database ID @return (Database, error)

func (*AuthenticatedClient) GetSecureBundle added in v0.5.0

func (a *AuthenticatedClient) GetSecureBundle(databaseID string) (astra.CredsURL, error)

GetSecureBundle Returns a temporary URL to download a zip file with certificates for connecting to the database. The URL expires after five minutes.<p>There are two types of the secure bundle URL: <ul&gt * @param databaseID string representation of the database ID @return (SecureBundle, error)

func (*AuthenticatedClient) GetTierInfo added in v0.5.0

GetTierInfo Returns all supported tier, cloud, region, count, and capacitity combinations @return ([]TierInfo, error)

func (*AuthenticatedClient) ListDb added in v0.5.0

func (a *AuthenticatedClient) ListDb(include string, provider string, startingAfter string, limit int) ([]astra.Database, error)

ListDb find all databases that match the parameters * @param "include" (optional.string) - Allows filtering so that databases in listed states are returned * @param "provider" (optional.string) - Allows filtering so that databases from a given provider are returned * @param "startingAfter" (optional.string) - Optional parameter for pagination purposes. Used as this value for starting retrieving a specific page of results * @param "limit" (optional.int) - Optional parameter for pagination purposes. Specify the number of items for one page of data @return ([]Database, error)

func (*AuthenticatedClient) Park added in v0.5.0

func (a *AuthenticatedClient) Park(databaseID string) error

Park parks the database at the specified id and will block until the database is parked * @param databaseID string representation of the database ID @return error

func (*AuthenticatedClient) ParkAsync added in v0.5.0

func (a *AuthenticatedClient) ParkAsync(databaseID string) error

ParkAsync parks the database at the specified id. Note you cannot park a serverless database * @param databaseID string representation of the database ID @return error

func (*AuthenticatedClient) ResetPassword added in v0.5.0

func (a *AuthenticatedClient) ResetPassword(databaseID, username, password string) error

ResetPassword changes the password for the database at the specified id * @param databaseID string representation of the database ID * @param username string containing username * @param password string containing password. The specified password will be updated for the specified database user @return error

func (*AuthenticatedClient) Resize added in v0.5.0

func (a *AuthenticatedClient) Resize(databaseID string, capacityUnits int) error

Resize a database. Total number of capacity units desired should be specified. Reducing a size of a database is not supported at this time. Note you cannot resize a serverless database * @param databaseID string representation of the database ID * @param capacityUnits int32 containing capacityUnits key with a value greater than the current number of capacity units (max increment of 3 additional capacity units) @return error

func (*AuthenticatedClient) Terminate added in v0.5.0

func (a *AuthenticatedClient) Terminate(id string, preparedStateOnly bool) error

Terminate deletes the database at the specified id and will block until it shows up as deleted or is removed from the system * @param databaseID string representation of the database ID * @param "PreparedStateOnly" - For internal use only. Used to safely terminate prepared databases @return error

func (*AuthenticatedClient) Unpark added in v0.5.0

func (a *AuthenticatedClient) Unpark(databaseID string) error

Unpark unparks the database at the specified id and will block until the database is unparked * @param databaseID String representation of the database ID @return error

func (*AuthenticatedClient) UnparkAsync added in v0.5.0

func (a *AuthenticatedClient) UnparkAsync(databaseID string) error

UnparkAsync unparks the database at the specified id. NOTE you cannot unpark a serverless database * @param databaseID String representation of the database ID @return error

func (*AuthenticatedClient) WaitUntil added in v0.5.0

func (a *AuthenticatedClient) WaitUntil(id string, tries int, intervalSeconds int, status ...astra.StatusEnum) (astra.Database, error)

WaitUntil will keep checking the database for the requested status until it is available. Eventually it will timeout if the operation is not yet complete. * @param id string - the database id to find * @param tries int - number of attempts * @param intervalSeconds int - seconds to wait between tries * @param status StatusEnum - status to wait for @returns (Database, error)

type Client added in v0.3.2

type Client interface {
	CreateDb(astraops.DatabaseInfoCreate) (astraops.Database, error)
	Terminate(string, bool) error
	FindDb(string) (astraops.Database, error)
	ListDb(string, string, string, int) ([]astraops.Database, error)
	Park(string) error
	Unpark(string) error
	Resize(string, int) error
	GetSecureBundle(string) (astraops.CredsURL, error)
	GetTierInfo() ([]astraops.AvailableRegionCombination, error)
}

Client is the abstraction for client interactions. Allows alternative db management clients

type ClientInfo added in v0.5.0

type ClientInfo struct {
	ClientSecret string
	ClientName   string
	ClientID     string
}

ClientInfo provides access to

func ReadLogin

func ReadLogin(saJSONFile string) (ClientInfo, error)

ReadLogin retrieves the login from the specified json file

type ConfFiles added in v0.2.0

type ConfFiles struct {
	TokenPath string
	SaPath    string
}

ConfFiles supports both formats of credentials and will say if the token one is present

func GetHome

func GetHome(getHome func() (string, error)) (confDir string, confFiles ConfFiles, err error)

GetHome returns the configuration directory and file error will return if there is no user home folder

func (ConfFiles) HasServiceAccount added in v0.2.0

func (c ConfFiles) HasServiceAccount() (bool, error)

HasServiceAccount returns true if there is a service account file present and accessible

func (ConfFiles) HasToken added in v0.2.0

func (c ConfFiles) HasToken() (bool, error)

HasToken returns true if there is a token file present and accessible

type Creds added in v0.3.2

type Creds struct {
	GetHomeFunc func() (string, error) // optional. If not specified os.UserHomeDir is used for log base directory to find creds
}

Creds knows how handle and store credentials

func (*Creds) Login added in v0.3.2

func (c *Creds) Login() (Client, error)

Login logs into the Astra DevOps API using the local configuration provided by the 'astra-cli login' command

type Error added in v0.5.0

type Error struct {
	// API specific error code
	ID int
	// User-friendly description of error
	Message string
}

Error when the api has an error this is the structure

type ErrorResponse added in v0.5.0

type ErrorResponse struct {
	Errors []Error
}

ErrorResponse when the API has an error

type FileNotFoundError added in v0.1.3

type FileNotFoundError struct {
	Path string
	Err  error
}

FileNotFoundError when unable to read file

func (*FileNotFoundError) Error added in v0.1.3

func (j *FileNotFoundError) Error() string

Error returns the error string

type JSONParseError added in v0.1.3

type JSONParseError struct {
	Original string
	Err      error
}

JSONParseError when unable to read JSON

func (*JSONParseError) Error added in v0.1.3

func (j *JSONParseError) Error() string

Error returns the error string

type LoginService added in v0.3.2

type LoginService interface {
	Login() (Client, error)
}

LoginService provides interface to implement logins and produce an Client

type ParseError

type ParseError struct {
	Args []string
	Err  error
}

ParseError is used to indicate there is an error in the command line args

func (*ParseError) Error

func (p *ParseError) Error() string

Error outpus the error with the args provided, if there are no args that becomes the error

Directories

Path Synopsis
Package env is the package where global environment configuration goes
Package env is the package where global environment configuration goes
Package httputils provides common http functions and utilities
Package httputils provides common http functions and utilities
Package test is for test utilies and mocks
Package test is for test utilies and mocks

Jump to

Keyboard shortcuts

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