filter

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: MIT Imports: 14 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 (*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) (Dimension, error)

GetDimension returns information on a requested dimension name for a given filterID

func (*Client) GetDimensionOptions

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

GetDimensionOptions retrieves a list of the dimension options

func (*Client) GetDimensions

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

GetDimensions will return the dimensions associated with the provided filter id

func (*Client) GetJobState

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

GetJobState will return the current state of the filter job

func (*Client) GetOutput

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

GetOutput returns a filter output job for a given filter output id

func (*Client) GetPreview

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

GetPreview attempts to retrieve a preview for a given filterOutputID

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

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 {
	// contains filtered or unexported fields
}

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