filter

package
v1.30.3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseResponseBody

func CloseResponseBody(ctx context.Context, resp *http.Response)

CloseResponseBody closes the response body and logs an error if unsuccessful

Types

type Client

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

Client is a filter api client which can be used to make requests to the server

func New

func New(filterAPIURL string) *Client

New creates a new instance of Client with a given filter api url

func NewWithHealthClient added in v1.24.0

func NewWithHealthClient(hcCli *healthcheck.Client) *Client

NewWithHealthClient creates a new instance of Client, reusing the URL and Clienter from the provided health check client.

func (*Client) AddDimension

func (c *Client) AddDimension(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, id, name string) error

AddDimension adds a new dimension to a filter job

func (*Client) AddDimensionValue

func (c *Client) AddDimensionValue(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name, value string) error

AddDimensionValue adds a particular value to a filter job for a given filterID and name

func (*Client) AddDimensionValues

func (c *Client) AddDimensionValues(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string, options []string) error

AddDimensionValues adds many options to a filter job dimension

func (*Client) Checker

func (c *Client) Checker(ctx context.Context, check *health.CheckState) error

Checker calls filter api health endpoint and returns a check object to the caller.

func (*Client) CreateBlueprint

func (c *Client) CreateBlueprint(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID, datasetID, edition, version string, names []string) (string, error)

CreateBlueprint creates a filter blueprint and returns the associated filterID

func (*Client) GetDimension

func (c *Client) GetDimension(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string) (dim Dimension, err error)

GetDimension returns information on a requested dimension name for a given filterID unmarshalled as a Dimension struct

func (*Client) GetDimensionBytes added in v1.5.0

func (c *Client) GetDimensionBytes(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string) ([]byte, error)

GetDimensionBytes returns information on a requested dimension name for a given filterID as a byte array

func (*Client) GetDimensionOptions

func (c *Client) GetDimensionOptions(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string) (opts []DimensionOption, err error)

GetDimensionOptions retrieves a list of the dimension options unmarshalled as an array of DimensionOption structs

func (*Client) GetDimensionOptionsBytes added in v1.5.0

func (c *Client) GetDimensionOptionsBytes(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string) ([]byte, error)

GetDimensionOptionsBytes retrieves a list of the dimension options as a byte array

func (*Client) GetDimensions

func (c *Client) GetDimensions(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID string) (dims []Dimension, err error)

GetDimensions will return the dimensions associated with the provided filter id as an array of Dimension structs

func (*Client) GetDimensionsBytes added in v1.5.0

func (c *Client) GetDimensionsBytes(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID string) ([]byte, error)

GetDimensionsBytes will return the dimensions associated with the provided filter id as a byte array

func (*Client) GetJobState

func (c *Client) GetJobState(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID, filterID string) (m Model, err error)

GetJobState will return the current state of the filter job unmarshalled as a Model struct

func (*Client) GetJobStateBytes added in v1.5.0

func (c *Client) GetJobStateBytes(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID, filterID string) ([]byte, error)

GetJobStateBytes will return the current state of the filter job as a byte array

func (*Client) GetOutput

func (c *Client) GetOutput(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID, filterOutputID string) (m Model, err error)

GetOutput returns a filter output job for a given filter output id, unmarshalled as a Model struct

func (*Client) GetOutputBytes added in v1.5.0

func (c *Client) GetOutputBytes(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID, filterOutputID string) ([]byte, error)

GetOutputBytes returns a filter output job for a given filter output id as a byte array

func (*Client) GetPreview

func (c *Client) GetPreview(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID, filterOutputID string) (p Preview, err error)

GetPreview attempts to retrieve a preview for a given filterOutputID unmarshalled as a Preview struct

func (*Client) GetPreviewBytes added in v1.5.0

func (c *Client) GetPreviewBytes(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID, filterOutputID string) ([]byte, error)

GetPreviewBytes attempts to retrieve a preview for a given filterOutputID as a byte array

func (*Client) RemoveDimension

func (c *Client) RemoveDimension(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string) error

RemoveDimension removes a given dimension from a filter job

func (*Client) RemoveDimensionValue

func (c *Client) RemoveDimensionValue(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name, value string) error

RemoveDimensionValue removes a particular value to a filter job for a given filterID and name

func (*Client) UpdateBlueprint

func (c *Client) UpdateBlueprint(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID string, m Model, doSubmit bool) (Model, error)

UpdateBlueprint will update a blueprint with a given filter model

func (*Client) UpdateFilterOutput added in v1.5.0

func (c *Client) UpdateFilterOutput(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, filterJobID string, model *Model) error

UpdateFilterOutput performs a PUT operation to update the filter with the provided filterOutput model

func (*Client) UpdateFilterOutputBytes added in v1.5.0

func (c *Client) UpdateFilterOutputBytes(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, filterJobID string, b []byte) error

UpdateFilterOutputBytes performs a PUT operation to update the filter with the provided byte array

type Config

type Config struct {
	InternalToken string
	FlorenceToken string
}

Config contains any configuration required to send requests to the filter api

type CreateBlueprint

type CreateBlueprint struct {
	Dataset    Dataset          `json:"dataset"`
	Dimensions []ModelDimension `json:"dimensions"`
	FilterID   string           `json:"filter_id"`
}

CreateBlueprint represents the fields required to create a filter blueprint

type Dataset

type Dataset struct {
	DatasetID string `json:"id"`
	Edition   string `json:"edition"`
	Version   int    `json:"version"`
}

Dataset represents the dataset fields required to create a filter blueprint

type Dimension

type Dimension struct {
	Name string `json:"name"`
	URI  string `json:"dimension_url"`
}

Dimension represents a dimension response from the filter api

type DimensionOption

type DimensionOption struct {
	DimensionOptionsURL string `json:"dimension_option_url"`
	Option              string `json:"option"`
}

DimensionOption represents a dimension option from the filter api

type Download

type Download struct {
	URL     string `json:"href"`
	Size    string `json:"size"`
	Public  string `json:"public,omitempty"`
	Private string `json:"private,omitempty"`
	Skipped bool   `json:"skipped,omitempty"`
}

Download represents a download within a filter from api response

type ErrInvalidFilterAPIResponse

type ErrInvalidFilterAPIResponse struct {
	ExpectedCode int
	ActualCode   int
	URI          string
}

ErrInvalidFilterAPIResponse is returned when the filter api does not respond with a valid status

func (ErrInvalidFilterAPIResponse) Code

Code returns the status code received from filter api if an error is returned

func (ErrInvalidFilterAPIResponse) Error

Error should be called by the user to print out the stringified version of the error

type Event

type Event struct {
	Time string `json:"time"`
	Type string `json:"type"`
}

Event represents an event from a filter api response

type Link struct {
	ID   string `json:"id"`
	HRef string `json:"href"`
}

Link represents a single link within a links object

type Links struct {
	Version         Link `json:"version,omitempty"`
	FilterOutputs   Link `json:"filter_output,omitempty"`
	FilterBlueprint Link `json:"filter_blueprint,omitempty"`
}

Links represents a links object on the filter api response

type Model

type Model struct {
	FilterID    string              `json:"filter_id"`
	InstanceID  string              `json:"instance_id"`
	Links       Links               `json:"links"`
	DatasetID   string              `json:"dataset_id"`
	Edition     string              `json:"edition"`
	Version     string              `json:"version"`
	State       string              `json:"state"`
	Dimensions  []ModelDimension    `json:"dimensions,omitempty"`
	Downloads   map[string]Download `json:"downloads,omitempty"`
	Events      []Event             `json:"events,omitempty"`
	IsPublished bool                `json:"published"`
}

Model represents a model returned from the filter api

type ModelDimension

type ModelDimension struct {
	Name    string   `json:"name"`
	Options []string `json:"options"`
	Values  []string `json:"values"`
}

ModelDimension represents a dimension to be filtered upon

type Preview

type Preview struct {
	Headers         []string   `json:"headers"`
	NumberOfRows    int        `json:"number_of_rows"`
	NumberOfColumns int        `json:"number_of_columns"`
	Rows            [][]string `json:"rows"`
}

Preview represents a preview document returned from the filter api

Jump to

Keyboard shortcuts

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