api

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLimit  = 20
	DefaultOffset = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Router chi.Router
	// contains filtered or unexported fields
}

API provides a struct to wrap the api around

func New

func New(_ context.Context, cfg *config.Config, r chi.Router, idc *identity.Client, rsp responder, g generator, d datastore, ds datasetAPIClient, pt populationTypesAPIClient, c cantabularClient, m metadataAPIClient, p kafka.IProducer) *API

New creates and initialises a new API

func (*API) HydrateMultivariateDimensionsPOST added in v1.16.0

func (api *API) HydrateMultivariateDimensionsPOST(dimensions []model.Dimension, pType string) ([]model.Dimension, error)

Used for POST Dimension when the filter type is multivariate. Extra logic required to hydrate dimension using the default categorisation of the dimension.

func (*API) ParseRequest

func (api *API) ParseRequest(body io.Reader, req interface{}) error

NOTE: for multivariate tables, it is going to use the name field for the id when making the call to cantabular.

func (*API) RetrieveDefaultCategorisation added in v1.18.0

func (api *API) RetrieveDefaultCategorisation(dimension *model.Dimension, datasetName string) (string, string, string, error)

RetrieveDefaultCategorisation takes dimension, returns categorisations, and checks if any are default. if so, it returns the relevant information. If there are no default categorisations, it returns empty string for default categorisation, and the original dimension name and label to persist instead. returns (finalDimension, finalLabel, finalCategorisation, error)

type DatasetJSONDimension added in v1.2.0

type DatasetJSONDimension struct {
	DimensionName string       `json:"dimension_name"`
	Options       []model.Link `json:"options"`
}
type DatasetJSONLinks struct {
	DatasetMetadata model.Link `json:"dataset_metadata"`
	Self            model.Link `json:"self"`
	Version         model.Link `json:"version"`
}

type Error

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

Error is the packages error type

func (Error) BadRequest added in v1.2.0

func (e Error) BadRequest() bool

BadRequest satisfies the errBadRequest interface

func (Error) Error

func (e Error) Error() string

Error satisfies the standard library Go error interface

func (Error) LogData

func (e Error) LogData() map[string]interface{}

LogData satisfies the dataLogger interface which is used to recover log data from an error

func (Error) Message

func (e Error) Message() string

Message satisfies the messager interface which is used to specify a response to be sent to the caller in place of the error text for a given error. This is useful when you don't want sensitive information or implementation details being exposed to the caller which could be used to find exploits in our API

func (Error) NotFound added in v1.2.0

func (e Error) NotFound() bool

NotFound satisfies the errNotFound interface

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap implements the standard library Go unwrapper interface

type GetDatasetJSONResponse added in v1.10.0

type GetDatasetJSONResponse struct {
	Dimensions        []DatasetJSONDimension `json:"dimensions"`
	Links             DatasetJSONLinks       `json:"links"`
	Observations      []float32              `json:"observations"`
	TotalObservations int                    `json:"total_observations"`
	BlockedAreas      int                    `json:"blocked_areas"`
	TotalAreas        int                    `json:"total_areas"`
	AreasReturned     int                    `json:"areas_returned"`
}

getDatasetJSONResponse is the response body for GET /datasets/{dataset_id}/editions/{edition}/versions/{version}/json

type GetFilterDimensionOptionsItem added in v1.2.0

type GetFilterDimensionOptionsItem struct {
	Option    string     `json:"option"`
	Self      model.Link `json:"self"`
	Filter    model.Link `json:"filter"`
	Dimension model.Link `json:"Dimension"`
}

type GetFilterDimensionOptionsResponse added in v1.2.0

type GetFilterDimensionOptionsResponse struct {
	Items []GetFilterDimensionOptionsItem `json:"items"`
	// contains filtered or unexported fields
}

getDimensionOptionsResponse is the response body for GET /filters/{id}/dimensions/{name}/options

type GetObservationResponse added in v1.20.0

type GetObservationResponse struct {
	Dimensions  []ObservationDimension `bson:"dimensions"    json:"dimensions"`
	Observation float32                `bson:"observation"   json:"observation"`
}

type GetObservationsResponse added in v1.20.0

type GetObservationsResponse struct {
	Observations      []GetObservationResponse `bson:"observations"         json:"observations"`
	Links             DatasetJSONLinks         `json:"links"`
	TotalObservations int                      `json:"total_observations"`
	BlockedAreas      int                      `json:"blocked_areas"`
	TotalAreas        int                      `json:"total_areas"`
	AreasReturned     int                      `json:"areas_returned"`
}

type ObservationDimension added in v1.20.0

type ObservationDimension struct {
	Dimension   string `bson:"dimension"       json:"dimension"`
	DimensionID string `bson:"dimension_id"    json:"dimension_id"`
	Option      string `bson:"option"          json:"option"`
	OptionID    string `bson:"option_id"       json:"option_id"`
}

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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