batch

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnterKey = byte(10)
	PageSize = 25
)

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 {
	Token   string
	TeamID  string
	UserID  string
	Log     *logrus.Entry
	Opts    *cli.Options
	Client  *http.Client
	Printer PrinterFunc
	ApiUrl  string
}

func New

func New(opts *cli.Options) *Batch

New creates a new instance of a Batch struct with defaults

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) 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) LoadConfig

func (b *Batch) LoadConfig()

Attempt to load stored credentials

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?"`
	*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"`
	ID         string `header:"ID"`
	Token      string `header:"Token"`
	Paused     bool   `header:"Is Paused"`
	SchemaName string `header:"Schema Name"`
	SchemaType string `header:"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 Config

type Config struct {
	Token  string `json:"token"`
	TeamID string `json:"team_id"`
	UserID string `json:"user_id"`
}

Config stores Account IDs and the auth_token cookie

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)
}

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"`
	*ReplayDestination `json:"destination"`
	*ReplayCollection  `json:"collection"`
}

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

type ReplayCollection

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

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

type ReplayDestination

type ReplayDestination struct {
	Name string `db:"destination_name" 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"`
	Collection  string `header:"Collection Name"`
	Destination string `header:"Destination Name"`
	Paused      bool   `header:"Is Paused" json:"paused"`
}

ReplayOutput is used for displaying replays as a table

type SchemaOutput

type SchemaOutput struct {
	Name     string `header:"Name" json:"name"`
	ID       string `header:"Schema ID" json:"id"`
	Type     string `header:"Type" json:"type"`
	RootType string `header:"Protobuf Root Type" json:"root_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