batch

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package batch is used for interacting with the Batch platform's API. This backend is a non-traditional backend and does not implement the Backend interface; it should be used independently.

Index

Constants

View Source
const (
	EnterKey = byte(10)
	PageSize = 25
)
View Source
const (
	DefaultAPIURL = "https://api.batch.sh"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthResponse

type AuthResponse struct {
	AccountID             string `json:"id"`
	Name                  string `json:"name"`
	Email                 string `json:"email"`
	OnboardingState       string `json:"onboarding_state"`
	OnboardingStateStatus string `json:"onboarding_state_status"`
	Team                  struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	}
}

AuthResponse is used to unmarshal the JSON results of a login API call

type Batch

type Batch struct {
	PersistentConfig *config.Config
	Log              *logrus.Entry
	Opts             *opts.CLIOptions
	Client           *http.Client
	Printer          PrinterFunc
	ApiUrl           string
}

func New

func New(cliOpts *opts.CLIOptions, cfg *config.Config) *Batch

New creates a new instance of a Batch struct with defaults

func (*Batch) ArchiveReplay added in v0.25.1

func (b *Batch) ArchiveReplay() error

ArchiveReplay archives a replay

func (*Batch) Authenticate

func (b *Batch) Authenticate(username, password string) (*AuthResponse, error)

Authenticate makes an API call to the Batch.sh API with the given account's credentials

func (*Batch) CreateCollection

func (b *Batch) CreateCollection() error

func (*Batch) CreateDestination

func (b *Batch) CreateDestination(dstType string) error

func (*Batch) CreateReplay

func (b *Batch) CreateReplay() error

func (*Batch) Delete added in v0.25.1

func (b *Batch) Delete(path string) ([]byte, int, error)

func (*Batch) Get

func (b *Batch) Get(path string, queryParams map[string]string) ([]byte, int, error)

Get makes a GET request to the Batch.sh API

func (*Batch) ListCollections

func (b *Batch) ListCollections() error

ListCollections lists all of an account's collections

func (*Batch) ListDestinations

func (b *Batch) ListDestinations() error

ListDestinations lists all of an account's replay destinations

func (*Batch) ListReplays

func (b *Batch) ListReplays() error

ListReplays lists all of an account's replays

func (*Batch) ListSchemas

func (b *Batch) ListSchemas() error

ListSchemas lists all of an account's schemas

func (*Batch) Login

func (b *Batch) Login() error

Login attempts to login to the Batch.sh API using credentials supplied via stdin

func (*Batch) Logout

func (b *Batch) Logout() error

Logout logs a user out of the Batch.sh API and clears saved credentials

func (*Batch) Post

func (b *Batch) Post(path string, params map[string]interface{}) ([]byte, int, error)

Post makes a POST request to the Batch.sh API

func (*Batch) SearchCollection

func (b *Batch) SearchCollection() error

SearchCollection queries a collection

type BlunderError

type BlunderError struct {
	Code     int    `json:"code"`
	Domain   string `json:"domain"`
	Field    string `json:"field"`
	Status   string `json:"status"`
	RawError string `json:"raw_error"`
	Message  string `json:"message"`
}

type BlunderErrorResponse

type BlunderErrorResponse struct {
	Errors []*BlunderError `json:"errors"`
}

type Collection

type Collection struct {
	ID                string `json:"id" header:"ID"`
	Name              string `json:"name" header:"Name"`
	Token             string `json:"token"`
	Paused            bool   `json:"paused" header:"Is Paused?"`
	Archived          bool   `json:"archived" header:"Archived"`
	*CollectionSchema `json:"schema"`
}

Collection is used to unmarshal the JSON results of a list collections API call

type CollectionOutput

type CollectionOutput struct {
	Name       string `header:"Name" json:"name"`
	ID         string `header:"ID" json:"id"`
	Token      string `header:"Token" json:"token"`
	Paused     bool   `header:"Is Paused" json:"paused"`
	Archived   bool   `header:"Archived" json:"archived"`
	SchemaName string `header:"Schema Name" json:"schema_name"`
	SchemaType string `header:"Schema Type" json:"schema_type"`
}

CollectionOutput is used for displaying collections as a table

type CollectionSchema

type CollectionSchema struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name" header:"Schema"`
	Type string `json:"type"`
}

CollectionSchema is used to unmarshal the JSON results of a list collections API call

type DataLake

type DataLake struct {
	ID string `json:"id"`
}

type DestinationOutput

type DestinationOutput struct {
	Name     string `json:"name" header:"Name"`
	ID       string `json:"id" header:"Destination ID"`
	Type     string `json:"type" header:"Type"`
	Archived bool   `json:"archived" header:"Is Archived"`
}

DestinationOutput is used for displaying destinations as a table

type IBatch

type IBatch interface {
	LoadConfig()
	Login() error
	Logout() error
	ListReplays() error
	ListCollections() error
	ListSchemas() error
	ListDestinations() error
	Get(path string, queryParams map[string]string) (content []byte, statusCode int, err error)
	Post(path string, params map[string]interface{}) (content []byte, statusCode int, err error)
	Delete(path string) (content []byte, statusCode int, err error)
}

type PrinterFunc

type PrinterFunc func(v interface{})

PrinterFunc is a function that will be used to display output to the user's console

type Replay

type Replay struct {
	ID                 string `header:"Replay ID" json:"id"`
	Name               string `header:"Name" json:"name"`
	Type               string `header:"Type" json:"type"`
	Query              string `header:"Query" json:"query"`
	Paused             bool   `header:"Is Paused" json:"paused"`
	Archived           bool   `header:"Archived" json:"archived"`
	Status             string `header:"Status" json:"status"`
	*ReplayDestination `json:"destination"`
	*ReplayCollection  `json:"collection"`
	*ReplayStage       `json:"stage"`
}

Replay is used to unmarshal the JSON results of a list replays API call

type ReplayCollection

type ReplayCollection struct {
	Name string `json:"name"`
}

ReplayCollection is used to unmarshal the JSON results of a list replays API call

type ReplayDestination

type ReplayDestination struct {
	Name string `json:"name"`
}

ReplayDestination is used to unmarshal the JSON results of a list replays API call

type ReplayOutput

type ReplayOutput struct {
	Name        string `header:"Name" json:"name"`
	ID          string `header:"Replay ID" json:"id"`
	Type        string `header:"Type" json:"type"`
	Query       string `header:"Query" json:"query"`
	Source      string `header:"Source"`
	Destination string `header:"Destination Name"`
	Paused      bool   `header:"Is Paused" json:"paused"`
	Status      string `header:"Status" json:"status"`
}

ReplayOutput is used for displaying replays as a table

type ReplayStage added in v1.14.2

type ReplayStage struct {
	Name string `json:"name"`
}

ReplayStage is used to unmarshal the JSON results of a list replays API call

type SchemaOutput

type SchemaOutput struct {
	Name     string `header:"Name" json:"name"`
	ID       string `header:"Schema ID" json:"id"`
	Type     string `header:"Type" json:"type"`
	Archived bool   `header:"Is Archived" json:"archived"`
}

SchemaOutput is used for displaying schemas as a table

type SearchResult

type SearchResult struct {
	Total int               `json:"total"`
	Data  []json.RawMessage `json:"data"`
}

SearchResult is used to unmarshal the JSON results of a search API call

Jump to

Keyboard shortcuts

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