dataset

package
v2.260.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 18 Imported by: 75

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBatchETagMismatch = errors.New("ETag value changed from one batch to another")
View Source
var MaxIDs = func() int {
	return maxIDs
}

MaxIDs returns the maximum number of IDs acceptable in a list

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Date        string `json:"date"`
	Description string `json:"description"`
	Type        string `json:"type"`
}

Alert represents an alert returned by the dataset api

type BuildHierarchyTask

type BuildHierarchyTask struct {
	State         string `json:"state,omitempty"`
	DimensionName string `json:"dimension_name,omitempty"`
	CodeListID    string `json:"code_list_id,omitempty"`
}

BuildHierarchyTask represents a task of importing a single hierarchy.

type BuildSearchIndexTask

type BuildSearchIndexTask struct {
	State         string `json:"state,omitempty"`
	DimensionName string `json:"dimension_name,omitempty"`
}

BuildSearchIndexTask represents a task of importing a single search index into search.

type Change

type Change struct {
	Description string `json:"description"`
	Name        string `json:"name"`
	Type        string `json:"type"`
}

Change represents a change returned for a version by the dataset api

type Client

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

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

func NewAPIClient

func NewAPIClient(datasetAPIURL string) *Client

NewAPIClient creates a new instance of Client with a given dataset api url and the relevant tokens

func NewAPIClientWithMaxRetries

func NewAPIClientWithMaxRetries(datasetAPIURL string, maxRetries int) *Client

NewAPIClientWithMaxRetries creates a new instance of Client with a given dataset api url and the relevant tokens, setting a number of max retires for the HTTP client

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) Checker

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

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

func (*Client) Get

func (c *Client) Get(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, datasetID string) (m DatasetDetails, err error)

Get returns dataset level information for a given dataset id

func (*Client) GetByPath

func (c *Client) GetByPath(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, path string) (m DatasetDetails, err error)

GetByPath returns dataset level information for a given dataset path

func (*Client) GetDatasetCurrentAndNext

func (c *Client) GetDatasetCurrentAndNext(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, datasetID string) (m Dataset, err error)

GetDatasetCurrentAndNext returns dataset level information but contains both next and current documents

func (*Client) GetDatasets

func (c *Client) GetDatasets(ctx context.Context, userAuthToken, serviceAuthToken, collectionID string, q *QueryParams) (m List, err error)

GetDatasets returns the list of datasets

func (*Client) GetDatasetsBatchProcess

func (c *Client) GetDatasetsBatchProcess(ctx context.Context, userAuthToken, serviceAuthToken, collectionID string, processBatch DatasetsBatchProcessor, batchSize, maxWorkers int) error

GetDatasetsBatchProcess gets the datasets from the dataset API in batches, calling the provided function for each batch.

func (*Client) GetDatasetsInBatches

func (c *Client) GetDatasetsInBatches(ctx context.Context, userAuthToken, serviceAuthToken, collectionID string, batchSize, maxWorkers int) (datasets List, err error)

GetDatasetsInBatches retrieves a list of datasets in concurrent batches and accumulates the results

func (*Client) GetEdition

func (c *Client) GetEdition(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, datasetID, edition string) (m Edition, err error)

GetEdition retrieves a single edition document from a given datasetID and edition label

func (*Client) GetEditions

func (c *Client) GetEditions(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, datasetID string) (m []Edition, err error)

GetEditions returns all editions for a dataset

func (*Client) GetFullEditionsDetails added in v2.101.0

func (c *Client) GetFullEditionsDetails(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, datasetID string) (m []EditionsDetails, err error)

GetEditions returns all editions for a dataset

func (*Client) GetInstance

func (c *Client) GetInstance(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, instanceID, ifMatch string) (m Instance, eTag string, err error)

GetInstance returns an instance from the dataset api

func (*Client) GetInstanceBytes

func (c *Client) GetInstanceBytes(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, instanceID, ifMatch string) (b []byte, eTag string, err error)

GetInstanceBytes returns an instance as bytes from the dataset api

func (*Client) GetInstanceDimensions

func (c *Client) GetInstanceDimensions(ctx context.Context, serviceAuthToken, instanceID string, q *QueryParams, ifMatch string) (m Dimensions, eTag string, err error)

GetInstanceDimensions performs a 'GET /instances/<id>/dimensions' and returns the marshalled Dimensions struct

func (*Client) GetInstanceDimensionsBatchProcess

func (c *Client) GetInstanceDimensionsBatchProcess(ctx context.Context, serviceAuthToken, instanceID string, processBatch InstanceDimensionsBatchProcessor, batchSize, maxWorkers int, checkETag bool) (eTag string, err error)

GetInstanceDimensionsBatchProcess gets the instance dimensions from the dataset API in batches, calling the provided function for each batch.

func (*Client) GetInstanceDimensionsBytes

func (c *Client) GetInstanceDimensionsBytes(ctx context.Context, serviceAuthToken, instanceID string, q *QueryParams, ifMatch string) (b []byte, eTag string, err error)

GetInstanceDimensionsBytes returns a list of dimensions for an instance as bytes from the dataset api

func (*Client) GetInstanceDimensionsInBatches

func (c *Client) GetInstanceDimensionsInBatches(ctx context.Context, serviceAuthToken, instanceID string, batchSize, maxWorkers int) (dimensions Dimensions, eTag string, err error)

func (*Client) GetInstances

func (c *Client) GetInstances(ctx context.Context, userAuthToken, serviceAuthToken, collectionID string, vars url.Values) (m Instances, err error)

GetInstances returns a list of all instances filtered by vars

func (*Client) GetInstancesBatchProcess

func (c *Client) GetInstancesBatchProcess(ctx context.Context, userAuthToken, serviceAuthToken, collectionID string, vars url.Values, processBatch InstancesBatchProcessor, batchSize, maxWorkers int) error

GetInstancesBatchProcess gets the instances from the dataset API in batches, calling the provided function for each batch.

func (*Client) GetInstancesInBatches

func (c *Client) GetInstancesInBatches(ctx context.Context, userAuthToken, serviceAuthToken, collectionID string, vars url.Values, batchSize, maxWorkers int) (instances Instances, err error)

func (*Client) GetMetadataURL

func (c *Client) GetMetadataURL(id, edition, version string) string

GetMetadataURL returns the URL for the metadata of a given dataset id, edition and version

func (*Client) GetOptions

func (c *Client) GetOptions(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, id, edition, version, dimension string, q *QueryParams) (m Options, err error)

GetOptions will return the options for a dimension

func (*Client) GetOptionsBatchProcess

func (c *Client) GetOptionsBatchProcess(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, id, edition, version, dimension string, optionIDs *[]string, processBatch OptionsBatchProcessor, batchSize, maxWorkers int) error

GetOptionsBatchProcess gets the dataset options for a dimension from dataset API in batches, and calls the provided function for each batch. If optionIDs is provided, only the options with the provided IDs will be requested

func (*Client) GetOptionsInBatches

func (c *Client) GetOptionsInBatches(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, id, edition, version, dimension string, batchSize, maxWorkers int) (opts Options, err error)

GetOptionsInBatches retrieves a list of the dimension options in concurrent batches and accumulates the results

func (*Client) GetVersion

func (c *Client) GetVersion(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceAuthToken, collectionID, datasetID, edition, version string) (v Version, err error)

GetVersion gets a specific version for an edition from the dataset api

func (*Client) GetVersionDimensions

func (c *Client) GetVersionDimensions(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, id, edition, version string) (m VersionDimensions, err error)

GetVersionDimensions will return a list of dimensions for a given version of a dataset

func (*Client) GetVersionMetadata

func (c *Client) GetVersionMetadata(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, id, edition, version string) (m Metadata, err error)

GetVersionMetadata returns the metadata for a given dataset id, edition and version

func (*Client) GetVersionMetadataSelection added in v2.133.0

func (c *Client) GetVersionMetadataSelection(ctx context.Context, req GetVersionMetadataSelectionInput) (*Metadata, error)

func (*Client) GetVersionWithHeaders added in v2.247.0

func (c *Client) GetVersionWithHeaders(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceAuthToken, collectionID, datasetID, edition, version string) (v Version, h ResponseHeaders, err error)

GetVersionWithHeaders gets a specific version for an edition from the dataset api and additional response headers

func (*Client) GetVersions

func (c *Client) GetVersions(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceAuthToken, collectionID, datasetID, edition string, q *QueryParams) (m VersionsList, err error)

GetVersions gets all versions for an edition from the dataset api

func (*Client) GetVersionsBatchProcess

func (c *Client) GetVersionsBatchProcess(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceAuthToken, collectionID, datasetID, edition string, processBatch VersionsBatchProcessor, batchSize, maxWorkers int) error

GetVersionsBatchProcess gets the datasets from the dataset API in batches, calling the provided function for each batch.

func (*Client) GetVersionsInBatches

func (c *Client) GetVersionsInBatches(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceAuthToken, collectionID, datasetID, edition string, batchSize, maxWorkers int) (versions VersionsList, err error)

GetVersionsInBatches retrieves a list of datasets in concurrent batches and accumulates the results

func (*Client) PatchInstanceDimensionOption

func (c *Client) PatchInstanceDimensionOption(ctx context.Context, serviceAuthToken, instanceID, dimensionID, optionID, nodeID string, order *int, ifMatch string) (eTag string, err error)

PatchInstanceDimensionOption performs a 'PATCH /instances/<id>/dimensions/<id>/options/<id>' to update the node_id and/or order of the specified dimension

func (*Client) PatchInstanceDimensions added in v2.1.12

func (c *Client) PatchInstanceDimensions(ctx context.Context, serviceAuthToken, instanceID string, upserts []*OptionPost, updates []*OptionUpdate, ifMatch string) (eTag string, err error)

PatchInstanceDimensions performs a 'PATCH /instances/<id>/dimensions' with the provided List of Options to patch (upsert)

func (*Client) PostInstance

func (c *Client) PostInstance(ctx context.Context, serviceAuthToken string, newInstance *NewInstance) (i *Instance, eTag string, err error)

PostInstance performs a POST /instances/ request with the provided instance marshalled as body

func (*Client) PostInstanceDimensions

func (c *Client) PostInstanceDimensions(ctx context.Context, serviceAuthToken, instanceID string, data OptionPost, ifMatch string) (eTag string, err error)

PostInstanceDimensions performs a 'POST /instances/<id>/dimensions' with the provided OptionPost

func (*Client) PutDataset

func (c *Client) PutDataset(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, datasetID string, d DatasetDetails) error

PutDataset update the dataset

func (*Client) PutInstance

func (c *Client) PutInstance(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, instanceID string, i UpdateInstance, ifMatch string) (eTag string, err error)

PutInstance updates an instance

func (*Client) PutInstanceData

func (c *Client) PutInstanceData(ctx context.Context, serviceAuthToken, instanceID string, data JobInstance, ifMatch string) (eTag string, err error)

PutInstanceData executes a put request to update instance data via the dataset API.

func (*Client) PutInstanceImportTasks

func (c *Client) PutInstanceImportTasks(ctx context.Context, serviceAuthToken, instanceID string, data InstanceImportTasks, ifMatch string) (eTag string, err error)

PutInstanceImportTasks marks the import observation task state for an instance

func (*Client) PutInstanceState

func (c *Client) PutInstanceState(ctx context.Context, serviceAuthToken, instanceID string, state State, ifMatch string) (eTag string, err error)

PutInstanceState performs a PUT '/instances/<id>' with the string representation of the provided state

func (*Client) PutMetadata added in v2.250.0

func (c *Client) PutMetadata(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, datasetID, edition, version string, metadata EditableMetadata, versionEtag string) error

PutMetadata updates the dataset and the version metadata

func (*Client) PutVersion

func (c *Client) PutVersion(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, datasetID, edition, version string, v Version) error

PutVersion update the version

func (*Client) UpdateInstanceWithNewInserts

func (c *Client) UpdateInstanceWithNewInserts(ctx context.Context, serviceAuthToken, instanceID string, observationsInserted int32, ifMatch string) (eTag string, err error)

UpdateInstanceWithNewInserts increments the observation inserted count for an instance

type CodeList

type CodeList struct {
	ID          string `json:"id"`
	HRef        string `json:"href"`
	Name        string `json:"name"`
	IsHierarchy bool   `json:"is_hierarchy"`
}

CodeList holds one of the codelists corresponding to a new Instance

type Contact

type Contact struct {
	Name      string `json:"name"`
	Telephone string `json:"telephone"`
	Email     string `json:"email"`
}

Contact represents a response model within a dataset

type Dataset

type Dataset struct {
	ID      string          `json:"id"`
	Next    *DatasetDetails `json:"next,omitempty"`
	Current *DatasetDetails `json:"current,omitempty"`
	DatasetDetails
}

Dataset represents a dataset resource

type DatasetDetails

type DatasetDetails struct {
	ID                string            `json:"id,omitempty"`
	CollectionID      string            `json:"collection_id,omitempty"`
	Contacts          *[]Contact        `json:"contacts,omitempty"`
	Description       string            `json:"description,omitempty"`
	Keywords          *[]string         `json:"keywords,omitempty"`
	License           string            `json:"license,omitempty"`
	Links             Links             `json:"links,omitempty"`
	Methodologies     *[]Methodology    `json:"methodologies,omitempty"`
	NationalStatistic bool              `json:"national_statistic"`
	NextRelease       string            `json:"next_release,omitempty"`
	NomisReferenceURL string            `json:"nomis_reference_url,omitempty"`
	Publications      *[]Publication    `json:"publications,omitempty"`
	Publisher         *Publisher        `json:"publisher,omitempty"`
	QMI               Publication       `json:"qmi,omitempty"`
	RelatedDatasets   *[]RelatedDataset `json:"related_datasets,omitempty"`
	ReleaseFrequency  string            `json:"release_frequency,omitempty"`
	State             string            `json:"state,omitempty"`
	Theme             string            `json:"theme,omitempty"`
	Title             string            `json:"title,omitempty"`
	Type              string            `json:"type,omitempty"`
	UnitOfMeasure     string            `json:"unit_of_measure,omitempty"`
	UsageNotes        *[]UsageNote      `json:"usage_notes,omitempty"`
	URI               string            `json:"uri,omitempty"`
	IsBasedOn         *IsBasedOn        `json:"is_based_on,omitempty"`
	VersionsList      VersionsList      `json:"versions_list,omitempty"`
	CanonicalTopic    string            `json:"canonical_topic,omitempty"`
	Subtopics         []string          `json:"subtopics,omitempty"`
	Survey            string            `json:"survey,omitempty"`
	RelatedContent    *[]GeneralDetails `json:"related_content,omitempty"`
	LowestGeography   string            `json:"lowest_geography,omitempty"`
}

DatasetDetails represents a response dataset model from the dataset api

type DatasetsBatchProcessor

type DatasetsBatchProcessor func(List) (abort bool, err error)

DatasetsBatchProcessor is the type corresponding to a batch processing function for a dataset List.

type Dimension

type Dimension struct {
	DimensionID string `json:"dimension"`
	InstanceID  string `json:"instance_id"`
	NodeID      string `json:"node_id,omitempty"`
	Label       string `json:"label"`
	Option      string `json:"option"`
	Links       Links  `json:"links"`
}

Dimension represents a response model for a dimension endpoint

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 list of dimensions

type Download

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

Download represents a version download from the dataset api

type DownloadList

type DownloadList struct {
	CSV  *Download `json:"csv,omitempty"`
	CSVW *Download `json:"csvw,omitempty"`
	XLS  *Download `json:"xls,omitempty"`
}

DownloadList represents a list of objects of containing information on the downloadable files

type EditableMetadata added in v2.250.0

type EditableMetadata struct {
	Alerts            *[]Alert           `json:"alerts,omitempty"`
	CanonicalTopic    string             `json:"canonical_topic,omitempty"`
	Contacts          []Contact          `json:"contacts,omitempty"`
	Description       string             `json:"description,omitempty"`
	Dimensions        []VersionDimension `json:"dimensions,omitempty"`
	Keywords          []string           `json:"keywords,omitempty"`
	LatestChanges     *[]Change          `json:"latest_changes,omitempty"`
	License           string             `json:"license,omitempty"`
	Methodologies     []Methodology      `json:"methodologies,omitempty"`
	NationalStatistic *bool              `json:"national_statistic,omitempty"`
	NextRelease       string             `json:"next_release,omitempty"`
	Publications      []Publication      `json:"publications,omitempty"`
	QMI               *Publication       `json:"qmi,omitempty"`
	RelatedDatasets   []RelatedDataset   `json:"related_datasets,omitempty"`
	ReleaseDate       string             `json:"release_date,omitempty"`
	ReleaseFrequency  string             `json:"release_frequency,omitempty"`
	Title             string             `json:"title,omitempty"`
	Survey            string             `json:"survey,omitempty"`
	Subtopics         []string           `json:"subtopics,omitempty"`
	UnitOfMeasure     string             `json:"unit_of_measure,omitempty"`
	UsageNotes        *[]UsageNote       `json:"usage_notes,omitempty"`
	RelatedContent    []GeneralDetails   `json:"related_content,omitempty"`
}

EditableMetadata represents the metadata fields that can be edited

type Edition

type Edition struct {
	Edition string `json:"edition"`
	ID      string `json:"id"`
	Links   Links  `json:"links"`
	State   string `json:"state"`
}

Edition represents an edition within a dataset

type EditionItems added in v2.101.0

type EditionItems struct {
	Items []EditionsDetails `json:"items"`
}

type EditionsDetails added in v2.101.0

type EditionsDetails struct {
	ID      string  `json:"id"`
	Next    Edition `json:"next"`
	Current Edition `json:"current"`
	Edition
}

type ErrInvalidDatasetAPIResponse

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

ErrInvalidDatasetAPIResponse is returned when the dataset api does not respond with a valid status

func NewDatasetAPIResponse

func NewDatasetAPIResponse(resp *http.Response, uri string) (e *ErrInvalidDatasetAPIResponse)

NewDatasetAPIResponse creates an error response, optionally adding body to e when status is 404

func (ErrInvalidDatasetAPIResponse) Code

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

func (ErrInvalidDatasetAPIResponse) Error

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

type Event

type Event struct {
	Type          string `json:"type"`
	Time          string `json:"time"`
	Message       string `json:"message"`
	MessageOffset string `json:"messageOffset"`
}

Event holds one of the event which has happened to a new Instance

type GeneralDetails added in v2.191.0

type GeneralDetails struct {
	Description string `json:"description,omitempty"`
	HRef        string `json:"href,omitempty"`
	Title       string `json:"title,omitempty"`
}

type GetVersionMetadataSelectionInput added in v2.133.0

type GetVersionMetadataSelectionInput struct {
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	DatasetID        string
	Edition          string
	Version          string
	Dimensions       []string
}

type ImportObservationsTask

type ImportObservationsTask struct {
	State                string `json:"state,omitempty"`
	InsertedObservations int64  `json:"total_inserted_observations,omitempty"`
}

ImportObservationsTask represents the task of importing instance observation data into the database.

type Instance

type Instance struct {
	Version
}

Instance represents an instance within a dataset

type InstanceDimensionsBatchProcessor

type InstanceDimensionsBatchProcessor func(dimensions Dimensions, eTag string) (abort bool, err error)

InstanceDimensionsBatchProcessor is the type corresponding to a batch processing function for Instance dimensions

type InstanceImportTasks

type InstanceImportTasks struct {
	ImportObservations    *ImportObservationsTask `json:"import_observations"`
	BuildHierarchyTasks   []*BuildHierarchyTask   `json:"build_hierarchies"`
	BuildSearchIndexTasks []*BuildSearchIndexTask `json:"build_search_indexes"`
}

InstanceImportTasks represents all of the tasks required to complete an import job.

type Instances

type Instances struct {
	Items      []Instance `json:"items"`
	Count      int        `json:"count"`
	Offset     int        `json:"offset"`
	Limit      int        `json:"limit"`
	TotalCount int        `json:"total_count"`
}

Instances represent a list of Instance objects

type InstancesBatchProcessor

type InstancesBatchProcessor func(Instances) (abort bool, err error)

InstancesBatchProcessor is the type corresponding to a batch processing function for Instances

type IsBasedOn

type IsBasedOn struct {
	Type string `json:"@type"`
	ID   string `json:"@id"`
}

IsBasedOn is a special set of json-ld metadata for Cantabular datasets For more information on json-ld markup see: https://moz.com/blog/json-ld-for-beginners

type JobInstance

type JobInstance struct {
	HeaderNames          []string `json:"headers"`
	NumberOfObservations int      `json:"total_observations"`
}

JobInstance represents the details necessary to update (PUT) a job instance

type Link struct {
	URL string `json:"href"`
	ID  string `json:"id,omitempty"`
}

Link represents a single link within a dataset model

type Links struct {
	AccessRights  Link `json:"access_rights,omitempty"`
	Dataset       Link `json:"dataset,omitempty"`
	Dimensions    Link `json:"dimensions,omitempty"`
	Edition       Link `json:"edition,omitempty"`
	Editions      Link `json:"editions,omitempty"`
	LatestVersion Link `json:"latest_version,omitempty"`
	Versions      Link `json:"versions,omitempty"`
	Self          Link `json:"self,omitempty"`
	CodeList      Link `json:"code_list,omitempty"`
	Options       Link `json:"options,omitempty"`
	Version       Link `json:"version,omitempty"`
	Code          Link `json:"code,omitempty"`
	Taxonomy      Link `json:"taxonomy,omitempty"`
	Job           Link `json:"job,omitempty"`
}

Links represent the Links within a dataset model

type List

type List struct {
	Items      []Dataset `json:"items"`
	Count      int       `json:"count"`
	Offset     int       `json:"offset"`
	Limit      int       `json:"limit"`
	TotalCount int       `json:"total_count"`
}

List represents an object containing a list of datasets

type Metadata

type Metadata struct {
	Version
	DatasetDetails
	DatasetLinks Links `json:"dataset_links,omitempty"`
}

Metadata is a combination of version and dataset model fields

func (Metadata) ToString

func (m Metadata) ToString() string

ToString builds a string of metadata information

func (*Metadata) UnmarshalJSON added in v2.167.0

func (m *Metadata) UnmarshalJSON(js []byte) error

UnmarshalJSON is used to disambiguate the 'links' attribute of the incoming Metadata struct. As currently structured both the embedded Version and DatasetDetails objects have a 'links' attribute, and the default json marshaller will not populate either field as it doesn't know which to populate. In order not to introduce a breaking change to the api, the bespoke Unmarshaller below will do the disambiguation

type Methodology

type Methodology struct {
	Description string `json:"description"`
	URL         string `json:"href"`
	Title       string `json:"title"`
}

Methodology represents a methodology document returned by the dataset api

type NewInstance

type NewInstance struct {
	InstanceID        string               `json:"id,omitempty"`
	Links             *Links               `json:"links,omitempty"`
	State             string               `json:"state,omitempty"`
	Events            []Event              `json:"events,omitempty"`
	TotalObservations int                  `json:"total_observations,omitempty"`
	Headers           []string             `json:"headers,omitempty"`
	Dimensions        []CodeList           `json:"dimensions,omitempty"`
	LastUpdated       string               `json:"last_updated,omitempty"`
	ImportTasks       *InstanceImportTasks `json:"import_tasks"`
	Type              string               `json:"type,omitempty"`
	LowestGeography   string               `json:"lowest_geography,omitempty"`
}

NewInstance which presents a single dataset being imported

type Option

type Option struct {
	DimensionID string `json:"dimension"`
	Label       string `json:"label"`
	Links       Links  `json:"links"`
	Option      string `json:"option"`
}

Option represents a response model for an option

type OptionPost

type OptionPost struct {
	Code     string `json:"code"`
	CodeList string `json:"code_list,omitempty"`
	Label    string `json:"label"`
	Name     string `json:"dimension"`
	Option   string `json:"option"`
	Order    *int   `json:"order,omitempty"`
}

OptionPost represents an option model to store in the dataset api

type OptionUpdate added in v2.3.0

type OptionUpdate struct {
	Option string
	Name   string
	Order  *int
	NodeID string
}

OptionUpdate represents an update for an existing option. The information provided in the struct will be used to generate a patch operation

type Options

type Options struct {
	Items      []Option `json:"items"`
	Count      int      `json:"count"`
	Offset     int      `json:"offset"`
	Limit      int      `json:"limit"`
	TotalCount int      `json:"total_count"`
}

Options represents a list of options from the dataset api

func (Options) String

func (m Options) String() string

type OptionsBatchProcessor

type OptionsBatchProcessor func(Options) (abort bool, err error)

OptionsBatchProcessor is the type corresponding to a batch processing function for dataset Options

type Publication

type Publication struct {
	Description string `json:"description"`
	URL         string `json:"href"`
	Title       string `json:"title"`
}

Publication represents a publication document returned by the dataset api

type Publisher

type Publisher struct {
	URL  string `json:"href"`
	Name string `json:"name"`
	Type string `json:"type"`
}

Publisher represents the publisher within the dataset

type QueryParams

type QueryParams struct {
	Offset    int
	Limit     int
	IsBasedOn string
	IDs       []string
}

QueryParams represents the possible query parameters that a caller can provide

func (*QueryParams) Validate

func (q *QueryParams) Validate() error

Validate validates tht no negative values are provided for limit or offset, and that the length of IDs is lower than the maximum Also escapes all IDs, so that they can be safely used as query parameters in requests

type RelatedDataset

type RelatedDataset struct {
	URL   string `json:"href"`
	Title string `json:"title"`
}

RelatedDataset represents a related dataset document returned by the dataset api

type ResponseHeaders added in v2.247.0

type ResponseHeaders struct {
	ETag string
}

ResponseHedaers represents headers that are available in the HTTP response

type State

type State int

State - iota enum of possible states

const (
	StateCreated State = iota
	StateSubmitted
	StateCompleted        // Instances only
	StateFailed           // Instances only
	StateEditionConfirmed // instances and versions only
	StateAssociated       // not editions
	StatePublished
	StateDetached
)

Possible values for a State of the resource. It can only be one of the following: TODO these states should be enforced in all the 'POST' and 'PUT' operations that can modify states of resources

func (State) String

func (s State) String() string

String returns the string representation of a state

type Temporal

type Temporal struct {
	StartDate string `json:"start_date"`
	EndDate   string `json:"end_date"`
	Frequency string `json:"frequency"`
}

Temporal represents a temporal returned by the dataset api

type UpdateInstance

type UpdateInstance struct {
	Alerts               *[]Alert             `json:"alerts"`
	CollectionID         string               `json:"collection_id"`
	Downloads            DownloadList         `json:"downloads"`
	Edition              string               `json:"edition"`
	Dimensions           []VersionDimension   `json:"dimensions"`
	ID                   string               `json:"id"`
	InstanceID           string               `json:"instance_id"`
	LatestChanges        []Change             `json:"latest_changes"`
	ReleaseDate          string               `json:"release_date"`
	State                string               `json:"state"`
	Temporal             []Temporal           `json:"temporal"`
	Version              int                  `json:"version"`
	NumberOfObservations int64                `json:"total_observations,omitempty"`
	ImportTasks          *InstanceImportTasks `json:"import_tasks,omitempty"`
	CSVHeader            []string             `json:"headers,omitempty"`
	Type                 string               `json:"type,omitempty"`
	IsBasedOn            *IsBasedOn           `json:"is_based_on,omitempty"`
}

type UsageNote

type UsageNote struct {
	Note  string `json:"note,omitempty"`
	Title string `json:"title,omitempty"`
}

UsageNote represents a note containing extra information associated to the resource

type Version

type Version struct {
	Alerts               *[]Alert             `json:"alerts"`
	CollectionID         string               `json:"collection_id"`
	Downloads            map[string]Download  `json:"downloads"`
	Edition              string               `json:"edition"`
	Dimensions           []VersionDimension   `json:"dimensions"`
	ID                   string               `json:"id"`
	InstanceID           string               `json:"instance_id"`
	LatestChanges        []Change             `json:"latest_changes"`
	Links                Links                `json:"links,omitempty"`
	ReleaseDate          string               `json:"release_date"`
	State                string               `json:"state"`
	Temporal             []Temporal           `json:"temporal"`
	Version              int                  `json:"version"`
	NumberOfObservations int64                `json:"total_observations,omitempty"`
	ImportTasks          *InstanceImportTasks `json:"import_tasks,omitempty"`
	CSVHeader            []string             `json:"headers,omitempty"`
	UsageNotes           *[]UsageNote         `json:"usage_notes,omitempty"`
	IsBasedOn            *IsBasedOn           `json:"is_based_on,omitempty"`
	LowestGeography      string               `json:"lowest_geography,omitempty"`
}

Version represents a version within a dataset

type VersionDimension

type VersionDimension struct {
	ID                   string `json:"id"`
	Name                 string `json:"name"`
	Links                Links  `json:"links"`
	Description          string `json:"description"`
	Label                string `json:"label"`
	URL                  string `json:"href,omitempty"`
	Variable             string `json:"variable,omitempty"`
	NumberOfOptions      int    `json:"number_of_options,omitempty"`
	IsAreaType           *bool  `json:"is_area_type,omitempty"`
	QualityStatementText string `json:"quality_statement_text,omitempty"`
	QualityStatementURL  string `json:"quality_statement_url,omitempty"`
}

VersionDimension represents a dimension model nested in the Version model

type VersionDimensionItems

type VersionDimensionItems []VersionDimension

VersionDimensionItems represents a list of Version Dimensions

func (VersionDimensionItems) Len

func (d VersionDimensionItems) Len() int

func (VersionDimensionItems) Less

func (d VersionDimensionItems) Less(i, j int) bool

func (VersionDimensionItems) Swap

func (d VersionDimensionItems) Swap(i, j int)

type VersionDimensions

type VersionDimensions struct {
	Items VersionDimensionItems `json:"items"`
}

VersionDimensions represent a list of versionDimension

type VersionsBatchProcessor

type VersionsBatchProcessor func(VersionsList) (abort bool, err error)

VersionsBatchProcessor is the type corresponding to a batch processing function for a dataset List.

type VersionsList

type VersionsList struct {
	Items      []Version `json:"items"`
	Count      int       `json:"count"`
	Offset     int       `json:"offset"`
	Limit      int       `json:"limit"`
	TotalCount int       `json:"total_count"`
}

VersionsList represents an object containing a list of datasets

Jump to

Keyboard shortcuts

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