Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) AddDimension(ctx context.Context, ...) (eTag string, err error)
- func (c *Client) AddDimensionValue(ctx context.Context, ...) (eTag string, err error)
- func (c *Client) AddDimensionValues(ctx context.Context, ...) (latestETag string, err error)
- func (c *Client) AddEvent(ctx context.Context, ...) error
- func (c *Client) Checker(ctx context.Context, check *health.CheckState) error
- func (c *Client) CreateBlueprint(ctx context.Context, ...) (filterID, eTag string, err error)
- func (c *Client) CreateFlexibleBlueprint(ctx context.Context, ...) (filterID, eTag string, err error)
- func (c *Client) GetDimension(ctx context.Context, ...) (dim Dimension, eTag string, err error)
- func (c *Client) GetDimensionBytes(ctx context.Context, ...) (body []byte, eTag string, err error)
- func (c *Client) GetDimensionOptions(ctx context.Context, ...) (opts DimensionOptions, eTag string, err error)
- func (c *Client) GetDimensionOptionsBatchProcess(ctx context.Context, ...) (eTag string, err error)
- func (c *Client) GetDimensionOptionsBytes(ctx context.Context, ...) (body []byte, eTag string, err error)
- func (c *Client) GetDimensionOptionsInBatches(ctx context.Context, ...) (opts DimensionOptions, eTag string, err error)
- func (c *Client) GetDimensions(ctx context.Context, ...) (dims Dimensions, eTag string, err error)
- func (c *Client) GetDimensionsBytes(ctx context.Context, ...) (body []byte, eTag string, err error)
- func (c *Client) GetJobState(ctx context.Context, ...) (m Model, eTag string, err error)
- func (c *Client) GetJobStateBytes(ctx context.Context, ...) ([]byte, string, error)
- func (c *Client) GetOutput(ctx context.Context, ...) (m Model, err error)
- func (c *Client) GetOutputBytes(ctx context.Context, ...) ([]byte, error)
- func (c *Client) GetPreview(ctx context.Context, ...) (p Preview, err error)
- func (c *Client) GetPreviewBytes(ctx context.Context, ...) ([]byte, error)
- func (c *Client) PatchDimensionValues(ctx context.Context, ...) (latestETag string, err error)
- func (c *Client) RemoveDimension(ctx context.Context, ...) (eTag string, err error)
- func (c *Client) RemoveDimensionValue(ctx context.Context, ...) (eTag string, err error)
- func (c *Client) RemoveDimensionValues(ctx context.Context, ...) (latestETag string, err error)
- func (c *Client) SetDimensionValues(ctx context.Context, ...) (eTag string, err error)
- func (c *Client) UpdateBlueprint(ctx context.Context, ...) (Model, string, error)
- func (c *Client) UpdateFilterOutput(ctx context.Context, ...) error
- func (c *Client) UpdateFilterOutputBytes(ctx context.Context, ...) error
- type Config
- type Dataset
- type Dimension
- type DimensionOption
- type DimensionOptions
- type DimensionOptionsBatchProcessor
- type Dimensions
- type Download
- type ErrInvalidFilterAPIResponse
- type Event
- type Link
- type Links
- type Model
- type ModelDimension
- type Preview
- type QueryParams
Constants ¶
const ( EventFilterOutputQueryStart = "FilterOutputQueryStart" EventFilterOutputQueryEnd = "FilterOutputQueryEnd" EventFilterOutputCSVGenStart = "FilterOutputCSVGenStart" EventFilterOutputCSVGenEnd = "FilterOutputCSVGenEnd" )
Variables ¶
var ( ErrBatchETagMismatch = errors.New("ETag value changed from one batch to another") ErrBatchUnexpectedType = errors.New("batch processor was called with an unexpected type of items") ErrInvalidPaginationQuery = errors.New("negative offsets or limits are not allowed") )
error definitions that are not related to invalid responses
Functions ¶
This section is empty.
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 NewWithHealthClient ¶
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, ifMatch string) (eTag string, err 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, ifMatch string) (eTag string, err error)
AddDimensionValue adds a particular value to a filter job for a given filterID and dimension name
func (*Client) AddDimensionValues ¶
func (c *Client) AddDimensionValues(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string, values []string, batchSize int, ifMatch string) (latestETag string, err error)
AddDimensionValues adds the provided values to a dimension option list. This is performed in batches of size up to batchSize
func (*Client) AddEvent ¶
func (c *Client) AddEvent(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, filterJobID string, event *Event) error
AddEvent performs a POST operation to update the filter with the provided event
func (*Client) Checker ¶
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) (filterID, eTag string, err error)
CreateBlueprint creates a filter blueprint and returns the associated filterID and eTag
func (*Client) CreateFlexibleBlueprint ¶ added in v2.98.0
func (c *Client) CreateFlexibleBlueprint(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID, datasetID, edition, version string, names []string, population_type string) (filterID, eTag string, err error)
CreateFlexibleBlueprint creates a flexible filter blueprint and returns the associated filterID and eTag
func (*Client) GetDimension ¶
func (c *Client) GetDimension(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string) (dim Dimension, eTag string, err error)
GetDimension returns information on a requested dimension name for a given filterID unmarshalled as a Dimension struct
func (*Client) GetDimensionBytes ¶
func (c *Client) GetDimensionBytes(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string) (body []byte, eTag string, err 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, q *QueryParams) (opts DimensionOptions, eTag string, err error)
GetDimensionOptions retrieves a list of the dimension options unmarshalled as an array of DimensionOption structs
func (*Client) GetDimensionOptionsBatchProcess ¶
func (c *Client) GetDimensionOptionsBatchProcess(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string, processBatch DimensionOptionsBatchProcessor, batchSize, maxWorkers int, checkETag bool) (eTag string, err error)
GetDimensionOptionsBatchProcess gets the filter options for a dimension from filter API in batches, and calls the provided function for each batch. If checkETag is true, then the ETag will be validated for each batch call. If it changes from one batch to another, an ErrBatchETagMismatch error will be returned. Unless your processBatch function performs some call to modify the same filter, it is recommended to set checkETag to true, and you may retry this call if it fails with ErrBatchETagMismatch
func (*Client) GetDimensionOptionsBytes ¶
func (c *Client) GetDimensionOptionsBytes(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string, q *QueryParams) (body []byte, eTag string, err error)
GetDimensionOptionsBytes retrieves a list of the dimension options as a byte array
func (*Client) GetDimensionOptionsInBatches ¶
func (c *Client) GetDimensionOptionsInBatches(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string, batchSize, maxWorkers int) (opts DimensionOptions, eTag string, err error)
GetDimensionOptionsInBatches retrieves a list of the dimension options in concurrent batches and accumulates the results. If the ETag changes from one batch to another, the process will be aborted and an ErrBatchETagMismatch error will be returned. You may retry the call in this case.
func (*Client) GetDimensions ¶
func (c *Client) GetDimensions(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID string, q *QueryParams) (dims Dimensions, eTag string, err error)
GetDimensions will return the dimensions associated with the provided filter id as an array of Dimension structs
func (*Client) GetDimensionsBytes ¶
func (c *Client) GetDimensionsBytes(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID string, q *QueryParams) (body []byte, eTag string, err 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, eTag string, err error)
GetJobState will return the current state of the filter job unmarshalled as a Model struct
func (*Client) GetJobStateBytes ¶
func (c *Client) GetJobStateBytes(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID, filterID string) ([]byte, string, 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 ¶
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 ¶
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) PatchDimensionValues ¶
func (c *Client) PatchDimensionValues(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string, addValues, removeValues []string, batchSize int, ifMatch string) (latestETag string, err error)
PatchDimensionValues adds and removes values from a dimension option list. If the same item is provided in the add and remove list, it will be removed. Duplicates in the same list will have no effect.
func (*Client) RemoveDimension ¶
func (c *Client) RemoveDimension(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name, ifMatch string) (eTag string, err 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, ifMatch string) (eTag string, err error)
RemoveDimensionValue removes a particular value to a filter job for a given filterID and name
func (*Client) RemoveDimensionValues ¶
func (c *Client) RemoveDimensionValues(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string, values []string, batchSize int, ifMatch string) (latestETag string, err error)
RemoveDimensionValues removes the provided values from a dimension option list. This is performed with PATCH operations in batches of size up to batchSize.
func (*Client) SetDimensionValues ¶
func (c *Client) SetDimensionValues(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, filterID, name string, options []string, ifMatch string) (eTag string, err error)
SetDimensionValues creates or overwrites the options for a filter job dimension
func (*Client) UpdateBlueprint ¶
func (c *Client) UpdateBlueprint(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceToken, collectionID string, m Model, doSubmit bool, ifMatch string) (Model, string, error)
UpdateBlueprint will update a blueprint with a given filter model, providing the required IfMatch value to be sure the update is done in the expected object
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"` IsAreaType *bool `json:"is_area_type,omitempty"` Options []string `json:"options,omitempty"` }
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 DimensionOptions ¶
type DimensionOptions struct { Items []DimensionOption `json:"items"` Count int `json:"count"` Offset int `json:"offset"` Limit int `json:"limit"` TotalCount int `json:"total_count"` }
DimensionOptions represents a list of dimension options from the filter api
type DimensionOptionsBatchProcessor ¶
type DimensionOptionsBatchProcessor func(opts DimensionOptions, eTag string) (abort bool, err error)
DimensionOptionsBatchProcessor is the type corresponding to a batch processing function for filter DimensionOptions
type Dimensions ¶
type Dimensions struct { Items []Dimension `json:"items"` Count int `json:"count"` Offset int `json:"offset"` Limit int `json:"limit"` TotalCount int `json:"total_count"` }
Dimensions represents a dimensions response 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 ¶
ErrInvalidFilterAPIResponse is returned when the filter api does not respond with a valid status
func (ErrInvalidFilterAPIResponse) Code ¶
func (e ErrInvalidFilterAPIResponse) Code() int
Code returns the status code received from filter api if an error is returned
func (ErrInvalidFilterAPIResponse) Error ¶
func (e ErrInvalidFilterAPIResponse) Error() string
Error should be called by the user to print out the stringified version of the error
type Links ¶
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"` Dataset Dataset `json:"dataset,omitempty"` 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"` URI string `json:"dimension_url,omitempty"` IsAreaType *bool `json:"is_area_type,omitempty"` 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
type QueryParams ¶
QueryParams represents the possible query parameters that a caller can provide
func (QueryParams) Validate ¶
func (q QueryParams) Validate() error
Validate validates that no negative values are provided for limit or offset