dataset

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: MIT Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 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 (*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) GetDatasets

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

GetDatasets returns the list of datasets

func (*Client) GetDimensions

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

GetDimensions will return a versions dimensions

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

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

GetInstance returns an instance from the dataset api

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) (m Options, err error)

GetOptions will return the options for a dimension

func (*Client) GetVersion

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

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

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

func (c *Client) GetVersions(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceAuthToken, collectionID, datasetID, edition string) (m []Version, err error)

GetVersions gets all versions for an edition from the dataset api

func (*Client) PutVersion

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

PutVersion update the version

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,omitempty"`
	NextRelease       string            `json:"next_release,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"`
	UnitOfMeasure     string            `json:"unit_of_measure,omitempty"`
	URI               string            `json:"uri,omitempty"`
	UsageNotes        *[]UsageNote      `json:"usage_notes,omitempty"`
}

DatasetDetails represents a response dataset model from the dataset api

type Dimension

type Dimension struct {
	Name        string `json:"name"`
	Links       Links  `json:"links"`
	Description string `json:"description"`
	Label       string `json:"label"`
	URL         string `json:"href,omitempty"`
}

Dimension represents a response model for a dimension endpoint

type Dimensions

type Dimensions struct {
	Items Items `json:"items"`
}

Dimensions represent a list of dimensions from the dataset api

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 `bson:"csv,omitempty" json:"csv,omitempty"`
	CSVW *Download `bson:"csvw,omitempty" json:"csvw,omitempty"`
	XLS  *Download `bson:"xls,omitempty" json:"xls,omitempty"`
}

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

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 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 Instance

type Instance struct {
	Version
}

Instance represents an instance within a dataset

type Items

type Items []Dimension

Items represents a list of dimensions

func (Items) Len

func (d Items) Len() int

func (Items) Less

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

func (Items) Swap

func (d Items) Swap(i, j int)
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"`
}

Links represent the Links within a dataset model

type List

type List struct {
	Items []Dataset `json:"items"`
}

List represents an object containing a list of datasets

type Metadata

type Metadata struct {
	Version
	DatasetDetails
}

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

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 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 Options

type Options struct {
	Items []Option `json:"items"`
}

Options represents a list of options from the dataset api

func (Options) String

func (m Options) String() string

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 RelatedDataset

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

RelatedDataset represents a related dataset document returned by the dataset api

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 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    []Dimension         `json:"dimensions"`
	ID            string              `json:"id"`
	InstanceID    string              `json:"instance_id"`
	LatestChanges []Change            `json:"latest_changes"`
	Links         Links               `json:"links"`
	ReleaseDate   string              `json:"release_date"`
	State         string              `json:"state"`
	Temporal      []Temporal          `json:"temporal"`
	Version       int                 `json:"version"`
}

Version represents a version within a dataset

Jump to

Keyboard shortcuts

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