client

package
v0.3.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)
View Source
var (
	// ErrUnauthorized is returned on 401
	ErrUnauthorized = errors.New("authorization error")
)

Functions

This section is empty.

Types

type Client

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

Client implements a grossly simplified API client for Observe

func NewClient

func NewClient(customerID string, options ...Option) (*Client, error)

func (*Client) CreateDataset

func (c *Client) CreateDataset(workspaceId string, config *DatasetConfig) (*Dataset, error)

CreateDataset creates dataset

func (*Client) CreateForeignKey added in v0.13.14

func (c *Client) CreateForeignKey(workspaceID string, config *ForeignKeyConfig) (*ForeignKey, error)

CreateForeignKey

func (*Client) DeleteDataset

func (c *Client) DeleteDataset(id string) error

DeleteDataset by ID

func (*Client) DeleteForeignKey added in v0.13.14

func (c *Client) DeleteForeignKey(id string) error

DeleteForeignKey

func (*Client) GetDataset

func (c *Client) GetDataset(id string) (*Dataset, error)

GetDataset returns dataset by ID

func (*Client) GetForeignKey added in v0.13.14

func (c *Client) GetForeignKey(id string) (*ForeignKey, error)

GetForeignKey returns deferred foreign key

func (*Client) GetWorkspace

func (c *Client) GetWorkspace(id string) (*Workspace, error)

GetWorkspace by ID

func (*Client) LookupDataset

func (c *Client) LookupDataset(workspaceID string, name string) (*Dataset, error)

LookupDataset by name.

func (*Client) LookupWorkspace added in v0.13.14

func (c *Client) LookupWorkspace(name string) (*Workspace, error)

LookupWorkspace by name.

func (*Client) Run

func (c *Client) Run(reqBody string, vars map[string]interface{}) (map[string]interface{}, error)

Run raw GraphQL query against API

func (*Client) UpdateDataset

func (c *Client) UpdateDataset(workspaceId string, id string, config *DatasetConfig) (*Dataset, error)

UpdateDataset updates existing dataset

func (*Client) UpdateForeignKey added in v0.13.14

func (c *Client) UpdateForeignKey(id string, config *ForeignKeyConfig) (*ForeignKey, error)

UpdateForeignKey by ID

func (*Client) Verify

func (c *Client) Verify() error

Verify checks if we can connect to API.

type Dataset

type Dataset struct {
	ID          string         `json:"id"`
	WorkspaceID string         `json:"workspace_id"`
	Version     string         `json:"version"`
	Config      *DatasetConfig `json:"config"`
}

Dataset is the output of a sequence of stages operating on a collection of inputs

func (*Dataset) OID

func (d *Dataset) OID() *OID

type DatasetConfig

type DatasetConfig struct {
	Name      string            `json:"name"`
	IconURL   *string           `json:"icon_url"`
	Freshness *time.Duration    `json:"freshness"`
	Inputs    map[string]*Input `json:"inputs"`
	Stages    []*Stage          `json:"stages"`

	// in practice PathCost is mandatory, since it cannot be set to null
	PathCost int64 `json:"path_cost"`
}

DatasetConfig contains configurable elements associated to Dataset

func (*DatasetConfig) Validate

func (c *DatasetConfig) Validate() error

Validate verifies dataset config

type ForeignKey

type ForeignKey struct {
	ID        string            `json:"id"`
	Workspace string            `json:"workspace"`
	Config    *ForeignKeyConfig `json:"config"`
}

type ForeignKeyConfig

type ForeignKeyConfig struct {
	Source    *string  `json:"source"`
	Target    *string  `json:"target"`
	SrcFields []string `json:"srcFields"`
	DstFields []string `json:"srcFields"`
	Label     *string  `json:"label"`
}

type Input

type Input struct {
	Dataset *string ` json:"dataset,omitempty"`
}

Input references an existing data source

type OID

type OID struct {
	Type    Type
	ID      string
	Version *string
}

func NewOID

func NewOID(s string) (*OID, error)

func (*OID) String

func (o *OID) String() string

type Option added in v0.2.0

type Option func(*Client) error

func WithDomain added in v0.2.0

func WithDomain(domain string) Option

WithDomain overrides domain name used

func WithHTTPClient added in v0.2.0

func WithHTTPClient(client *http.Client) Option

WithHTTPClient overrides default HTTP client

func WithInsecure added in v0.2.0

func WithInsecure() Option

WithInsecure sets HTTP client to not verify TLS requests Must be set after WithHTTPClient, if both options are present

func WithToken added in v0.2.0

func WithToken(token string) Option

WithToken sets bearer token

func WithUserAgent

func WithUserAgent(userAgent string) Option

func WithUserCredentials added in v0.2.0

func WithUserCredentials(user, password string) Option

type Stage

type Stage struct {
	Alias    *string `json:"alias,omitempty"`
	Input    *string `json:"input,omitempty"`
	Pipeline string  `json:"pipeline"`
}

Stage applies a pipeline to an input If no input is provided, stage will follow on from previous stage An alias must be provided for callers to be able to reference this stage in OPAL Internally, the alias does not map to the stageID - it is the input name we use when refering to this stage

type Type

type Type string
const (
	TypeDataset   Type = "dataset"
	TypeWorkspace      = "workspace"
)

func (Type) IsValid

func (t Type) IsValid() bool

type Workspace

type Workspace struct {
	ID       string            `json:"id"`
	Config   *WorkspaceConfig  `json:"config"`
	Datasets map[string]string `json:"datasets"`
}

Workspace acts as top-level grouping

func (*Workspace) OID

func (w *Workspace) OID() *OID

type WorkspaceConfig

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

WorkspaceConfig contains configurable elements associated to Workspace

Directories

Path Synopsis
internal
api

Jump to

Keyboard shortcuts

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