Documentation ¶
Index ¶
- Constants
- Variables
- func CheckState(docType, state string) error
- func ValidateImportTask(task GenericTaskDetails) error
- func ValidateInstanceState(state string) error
- func ValidateStateFilter(filterList []string) error
- func ValidateVersion(version *Version) error
- type Alert
- type BuildHierarchyTask
- type BuildSearchIndexTask
- type CachedDimensionOption
- type Contact
- type ContactDetails
- type Dataset
- type DatasetDimensionResults
- type DatasetLinks
- type DatasetResults
- type DatasetUpdate
- type DatasetUpdateResults
- type Dimension
- type DimensionLink
- type DimensionNodeResults
- type DimensionObject
- type DimensionOption
- type DimensionOptionLinks
- type DimensionOptionResults
- type DimensionValues
- type DownloadList
- type DownloadObject
- type Edition
- type EditionResults
- type EditionUpdate
- type EditionUpdateLinks
- type EditionUpdateResults
- type Event
- type GeneralDetails
- type GenericTaskDetails
- type ImportObservationsTask
- type Instance
- type InstanceImportTasks
- type InstanceLinks
- type InstanceResults
- type LatestChange
- type LinkObject
- type Metadata
- type MetadataLinks
- type Observation
- type ObservationLinks
- type ObservationsDoc
- type Option
- type PublicDimensionOption
- type Publisher
- type TemporalFrequency
- type UsageNote
- type Version
- type VersionLinks
- type VersionResults
Constants ¶
const ( CreatedState = "created" SubmittedState = "submitted" CompletedState = "completed" EditionConfirmedState = "edition-confirmed" AssociatedState = "associated" PublishedState = "published" DetachedState = "detached" )
A list of reusable states across application
Variables ¶
var ( ErrAssociatedVersionCollectionIDInvalid = errors.New("missing collection_id for association between version and a collection") ErrPublishedVersionCollectionIDInvalid = errors.New("unexpected collection_id in published version") ErrVersionStateInvalid = errors.New("incorrect state, can be one of the following: edition-confirmed, associated or published") ErrEditionLinksInvalid = errors.New("editions links do not exist") )
List of error variables
Functions ¶
func CheckState ¶
CheckState checks state against a whitelist of valid states
func ValidateImportTask ¶
func ValidateImportTask(task GenericTaskDetails) error
ValidateImportTask checks the task contains mandatory fields
func ValidateInstanceState ¶
ValidateInstanceState checks the list of instance states from a whitelist
func ValidateStateFilter ¶
ValidateStateFilter checks the list of filter states from a whitelist
func ValidateVersion ¶
ValidateVersion checks the content of the version structure
Types ¶
type Alert ¶
type Alert struct { Date string `bson:"date,omitempty" json:"date,omitempty"` Description string `bson:"description,omitempty" json:"description,omitempty"` Type string `bson:"type,omitempty" json:"type,omitempty"` }
Alert represents an object containing information on an alert
type BuildHierarchyTask ¶
type BuildHierarchyTask struct { DimensionID string `bson:"code_list_id,omitempty" json:"code_list_id,omitempty"` GenericTaskDetails `bson:",inline"` }
BuildHierarchyTask represents a task of importing a single hierarchy.
type BuildSearchIndexTask ¶
type BuildSearchIndexTask struct {
GenericTaskDetails `bson:",inline"`
}
BuildSearchIndexTask represents a task of importing a single search index into search.
type CachedDimensionOption ¶
type CachedDimensionOption struct { Code string `bson:"code,omitempty" json:"code"` CodeList string `bson:"code_list,omitempty" json:"code_list,omitempty"` InstanceID string `bson:"instance_id,omitempty" json:"instance_id,omitempty"` Label string `bson:"label,omitempty" json:"label"` Name string `bson:"name,omitempty" json:"dimension"` NodeID string `bson:"node_id,omitempty" json:"node_id"` Option string `bson:"option,omitempty" json:"option"` }
CachedDimensionOption contains information used to create a dimension option
type Contact ¶
type Contact struct { Email string `bson:"email,omitempty" json:"email,omitempty"` ID string `bson:"_id,omitempty" json:"id,omitempty"` LastUpdated time.Time `bson:"last_updated,omitempty" json:"-"` Name string `bson:"name,omitempty" json:"name,omitempty"` Telephone string `bson:"telephone,omitempty" json:"telephone,omitempty"` }
Contact represents information of individual contact details
type ContactDetails ¶
type ContactDetails struct { Email string `bson:"email,omitempty" json:"email,omitempty"` Name string `bson:"name,omitempty" json:"name,omitempty"` Telephone string `bson:"telephone,omitempty" json:"telephone,omitempty"` }
ContactDetails represents an object containing information of the contact
type Dataset ¶
type Dataset struct { CollectionID string `bson:"collection_id,omitempty" json:"collection_id,omitempty"` Contacts []ContactDetails `bson:"contacts,omitempty" json:"contacts,omitempty"` Description string `bson:"description,omitempty" json:"description,omitempty"` Keywords []string `bson:"keywords,omitempty" json:"keywords,omitempty"` ID string `bson:"_id,omitempty" json:"id,omitempty"` LastUpdated time.Time `bson:"last_updated,omitempty" json:"-"` License string `bson:"license,omitempty" json:"license,omitempty"` Links *DatasetLinks `bson:"links,omitempty" json:"links,omitempty"` Methodologies []GeneralDetails `bson:"methodologies,omitempty" json:"methodologies,omitempty"` NationalStatistic *bool `bson:"national_statistic,omitempty" json:"national_statistic,omitempty"` NextRelease string `bson:"next_release,omitempty" json:"next_release,omitempty"` Publications []GeneralDetails `bson:"publications,omitempty" json:"publications,omitempty"` Publisher *Publisher `bson:"publisher,omitempty" json:"publisher,omitempty"` QMI *GeneralDetails `bson:"qmi,omitempty" json:"qmi,omitempty"` RelatedDatasets []GeneralDetails `bson:"related_datasets,omitempty" json:"related_datasets,omitempty"` ReleaseFrequency string `bson:"release_frequency,omitempty" json:"release_frequency,omitempty"` State string `bson:"state,omitempty" json:"state,omitempty"` Theme string `bson:"theme,omitempty" json:"theme,omitempty"` Title string `bson:"title,omitempty" json:"title,omitempty"` UnitOfMeasure string `bson:"unit_of_measure,omitempty" json:"unit_of_measure,omitempty"` URI string `bson:"uri,omitempty" json:"uri,omitempty"` }
Dataset represents information related to a single dataset
type DatasetDimensionResults ¶
type DatasetDimensionResults struct {
Items []Dimension `json:"items"`
}
DatasetDimensionResults represents a structure for a list of dimensions
type DatasetLinks ¶
type DatasetLinks struct { AccessRights *LinkObject `bson:"access_rights,omitempty" json:"access_rights,omitempty"` Editions *LinkObject `bson:"editions,omitempty" json:"editions,omitempty"` LatestVersion *LinkObject `bson:"latest_version,omitempty" json:"latest_version,omitempty"` Self *LinkObject `bson:"self,omitempty" json:"self,omitempty"` Taxonomy *LinkObject `bson:"taxonomy,omitempty" json:"taxonomy,omitempty"` }
DatasetLinks represents a list of specific links related to the dataset resource
type DatasetResults ¶
type DatasetResults struct {
Items []*Dataset `json:"items"`
}
DatasetResults represents a structure for a list of datasets
type DatasetUpdate ¶
type DatasetUpdate struct { ID string `bson:"_id,omitempty" json:"id,omitempty"` Current *Dataset `bson:"current,omitempty" json:"current,omitempty"` Next *Dataset `bson:"next,omitempty" json:"next,omitempty"` }
DatasetUpdate represents an evolving dataset with the current dataset and the updated dataset
type DatasetUpdateResults ¶
type DatasetUpdateResults struct {
Items []DatasetUpdate `json:"items"`
}
DatasetUpdateResults represents a structure for a list of evolving dataset with the current dataset and the updated dataset
type Dimension ¶
type Dimension struct { Description string `bson:"description,omitempty" json:"description,omitempty"` Label string `bson:"label,omitempty" json:"label,omitempty"` LastUpdated time.Time `bson:"last_updated,omitempty" json:"-"` Links DimensionLink `bson:"links,omitempty" json:"links,omitempty"` HRef string `json:"href,omitempty"` ID string `json:"id,omitempty"` Name string `bson:"name,omitempty" json:"name,omitempty"` }
Dimension represents an overview for a single dimension. This includes a link to the code list API which provides metadata about the dimension and all possible values.
type DimensionLink ¶
type DimensionLink struct { CodeList LinkObject `bson:"code_list,omitempty" json:"code_list,omitempty"` Options LinkObject `bson:"options,omitempty" json:"options,omitempty"` Version LinkObject `bson:"version,omitempty" json:"version,omitempty"` }
DimensionLink contains all links needed for a dimension
type DimensionNodeResults ¶
type DimensionNodeResults struct {
Items []DimensionOption `json:"items"`
}
DimensionNodeResults wraps dimension node objects for pagination
type DimensionObject ¶
type DimensionObject struct { HRef string `json:"href"` ID string `json:"id"` Label string `json:"label"` }
DimensionObject represents the unique dimension option data relevant to the observation
type DimensionOption ¶
type DimensionOption struct { InstanceID string `bson:"instance_id,omitempty" json:"instance_id,omitempty"` Label string `bson:"label,omitempty" json:"label"` LastUpdated time.Time `bson:"last_updated,omitempty" json:"-"` Links DimensionOptionLinks `bson:"links,omitempty" json:"links"` Name string `bson:"name,omitempty" json:"dimension"` NodeID string `bson:"node_id,omitempty" json:"node_id"` Option string `bson:"option,omitempty" json:"option"` }
DimensionOption contains unique information and metadata used when processing the data
type DimensionOptionLinks ¶
type DimensionOptionLinks struct { Code LinkObject `bson:"code,omitempty" json:"code"` CodeList LinkObject `bson:"code_list,omitempty" json:"code_list"` Version LinkObject `bson:"version,omitempty" json:"version"` }
DimensionOptionLinks represents a list of link objects related to dimension options
type DimensionOptionResults ¶
type DimensionOptionResults struct {
Items []PublicDimensionOption `json:"items"`
}
DimensionOptionResults represents a structure for a list of dimension options
type DimensionValues ¶
DimensionValues holds all unique values for a dimension
type DownloadList ¶
type DownloadList struct { CSV *DownloadObject `bson:"csv,omitempty" json:"csv,omitempty"` CSVW *DownloadObject `bson:"csvw,omitempty" json:"csvw,omitempty"` XLS *DownloadObject `bson:"xls,omitempty" json:"xls,omitempty"` }
DownloadList represents a list of objects of containing information on the downloadable files
func CreateDownloadList ¶
func CreateDownloadList(reader io.Reader) (*DownloadList, error)
CreateDownloadList manages the creation of a list downloadable items from a reader
type DownloadObject ¶
type DownloadObject struct { HRef string `bson:"href,omitempty" json:"href,omitempty"` Private string `bson:"private,omitempty" json:"private,omitempty"` Public string `bson:"public,omitempty" json:"public,omitempty"` // TODO size is in bytes and probably should be an int64 instead of a string this // will have to change for several services (filter API, exporter services and web) Size string `bson:"size,omitempty" json:"size,omitempty"` }
DownloadObject represents information on the downloadable file
type Edition ¶
type Edition struct { Edition string `bson:"edition,omitempty" json:"edition,omitempty"` ID string `bson:"id,omitempty" json:"id,omitempty"` LastUpdated time.Time `bson:"last_updated,omitempty" json:"-"` Links *EditionUpdateLinks `bson:"links,omitempty" json:"links,omitempty"` State string `bson:"state,omitempty" json:"state,omitempty"` }
Edition represents information related to a single edition for a dataset
type EditionResults ¶
type EditionResults struct {
Items []*Edition `json:"items"`
}
EditionResults represents a structure for a list of editions for a dataset
type EditionUpdate ¶
type EditionUpdate struct { ID string `bson:"id,omitempty" json:"id,omitempty"` Current *Edition `bson:"current,omitempty" json:"current,omitempty"` Next *Edition `bson:"next,omitempty" json:"next,omitempty"` }
EditionUpdate represents an evolving edition containing both the next and current edition
func CreateEdition ¶
func CreateEdition(host, datasetID, edition string) (*EditionUpdate, error)
CreateEdition manages the creation of a an edition object
func (*EditionUpdate) PublishLinks ¶
func (ed *EditionUpdate) PublishLinks(ctx context.Context, host string, versionLink *LinkObject) error
PublishLinks applies the provided versionLink object to the edition being published only if that version is greater than the latest published version
func (*EditionUpdate) UpdateLinks ¶
func (ed *EditionUpdate) UpdateLinks(ctx context.Context, host string) error
UpdateLinks in the editions.next document, ensuring links can't regress once published to current
type EditionUpdateLinks ¶
type EditionUpdateLinks struct { Dataset *LinkObject `bson:"dataset,omitempty" json:"dataset,omitempty"` LatestVersion *LinkObject `bson:"latest_version,omitempty" json:"latest_version,omitempty"` Self *LinkObject `bson:"self,omitempty" json:"self,omitempty"` Versions *LinkObject `bson:"versions,omitempty" json:"versions,omitempty"` }
EditionUpdateLinks represents those links common the both the current and next edition
type EditionUpdateResults ¶
type EditionUpdateResults struct {
Items []*EditionUpdate `json:"items"`
}
EditionUpdateResults represents a structure for a list of evolving dataset with the current dataset and the updated dataset
type Event ¶
type Event struct { Message string `bson:"message,omitempty" json:"message"` MessageOffset string `bson:"message_offset,omitempty" json:"message_offset"` Time *time.Time `bson:"time,omitempty" json:"time"` Type string `bson:"type,omitempty" json:"type"` }
Event which has happened to an instance
type GeneralDetails ¶
type GeneralDetails struct { Description string `bson:"description,omitempty" json:"description,omitempty"` HRef string `bson:"href,omitempty" json:"href,omitempty"` Title string `bson:"title,omitempty" json:"title,omitempty"` }
GeneralDetails represents generic fields stored against an object (reused)
type GenericTaskDetails ¶
type ImportObservationsTask ¶
type ImportObservationsTask struct { InsertedObservations int64 `bson:"total_inserted_observations" json:"total_inserted_observations"` State string `bson:"state,omitempty" json:"state,omitempty"` }
ImportObservationsTask represents the task of importing instance observation data into the database.
type Instance ¶
type Instance struct { Alerts *[]Alert `bson:"alerts,omitempty" json:"alerts,omitempty"` CollectionID string `bson:"collection_id,omitempty" json:"collection_id,omitempty"` Dimensions []Dimension `bson:"dimensions,omitempty" json:"dimensions,omitempty"` Downloads *DownloadList `bson:"downloads,omitempty" json:"downloads,omitempty"` Edition string `bson:"edition,omitempty" json:"edition,omitempty"` Events *[]Event `bson:"events,omitempty" json:"events,omitempty"` Headers *[]string `bson:"headers,omitempty" json:"headers,omitempty"` ImportTasks *InstanceImportTasks `bson:"import_tasks,omitempty" json:"import_tasks"` InstanceID string `bson:"id,omitempty" json:"id,omitempty"` LastUpdated time.Time `bson:"last_updated,omitempty" json:"last_updated,omitempty"` LatestChanges *[]LatestChange `bson:"latest_changes,omitempty" json:"latest_changes,omitempty"` Links *InstanceLinks `bson:"links,omitempty" json:"links,omitempty"` ReleaseDate string `bson:"release_date,omitempty" json:"release_date,omitempty"` State string `bson:"state,omitempty" json:"state,omitempty"` Temporal *[]TemporalFrequency `bson:"temporal,omitempty" json:"temporal,omitempty"` TotalObservations *int `bson:"total_observations,omitempty" json:"total_observations,omitempty"` UniqueTimestamp bson.MongoTimestamp `bson:"unique_timestamp" json:"-"` Version int `bson:"version,omitempty" json:"version,omitempty"` }
Instance which presents a single dataset being imported
type InstanceImportTasks ¶
type InstanceImportTasks struct { BuildHierarchyTasks []*BuildHierarchyTask `bson:"build_hierarchies,omitempty" json:"build_hierarchies"` BuildSearchIndexTasks []*BuildSearchIndexTask `bson:"build_search_indexes,omitempty" json:"build_search_indexes"` ImportObservations *ImportObservationsTask `bson:"import_observations,omitempty" json:"import_observations"` }
InstanceImportTasks represents all of the tasks required to complete an import job.
type InstanceLinks ¶
type InstanceLinks struct { Dataset *LinkObject `bson:"dataset,omitempty" json:"dataset,omitempty"` Dimensions *LinkObject `bson:"dimensions,omitempty" json:"dimensions,omitempty"` Edition *LinkObject `bson:"edition,omitempty" json:"edition,omitempty"` Job *LinkObject `bson:"job,omitempty" json:"job"` Self *LinkObject `bson:"self,omitempty" json:"self,omitempty"` Spatial *LinkObject `bson:"spatial,omitempty" json:"spatial,omitempty"` Version *LinkObject `bson:"version,omitempty" json:"version,omitempty"` }
InstanceLinks holds all links for an instance
type InstanceResults ¶
type InstanceResults struct {
Items []Instance `json:"items"`
}
InstanceResults wraps instances objects for pagination
type LatestChange ¶
type LatestChange struct { Description string `bson:"description,omitempty" json:"description,omitempty"` Name string `bson:"name,omitempty" json:"name,omitempty"` Type string `bson:"type,omitempty" json:"type,omitempty"` }
LatestChange represents an object contining information on a single change between versions
type LinkObject ¶
type LinkObject struct { HRef string `bson:"href,omitempty" json:"href,omitempty"` ID string `bson:"id,omitempty" json:"id,omitempty"` }
LinkObject represents a generic structure for all links
type Metadata ¶
type Metadata struct { Alerts *[]Alert `json:"alerts,omitempty"` Contacts []ContactDetails `json:"contacts,omitempty"` Description string `json:"description,omitempty"` Dimensions []Dimension `json:"dimensions,omitempty"` Distribution []string `json:"distribution,omitempty"` Downloads *DownloadList `json:"downloads,omitempty"` Keywords []string `json:"keywords,omitempty"` LatestChanges *[]LatestChange `json:"latest_changes,omitempty"` License string `json:"license,omitempty"` Links *MetadataLinks `json:"links,omitempty"` Methodologies []GeneralDetails `json:"methodologies,omitempty"` NationalStatistic *bool `json:"national_statistic,omitempty"` NextRelease string `json:"next_release,omitempty"` Publications []GeneralDetails `json:"publications,omitempty"` Publisher *Publisher `json:"publisher,omitempty"` QMI *GeneralDetails `json:"qmi,omitempty"` RelatedDatasets []GeneralDetails `json:"related_datasets,omitempty"` ReleaseDate string `json:"release_date,omitempty"` ReleaseFrequency string `json:"release_frequency,omitempty"` Temporal *[]TemporalFrequency `json:"temporal,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"` }
Metadata represents information (metadata) relevant to a version
type MetadataLinks ¶
type MetadataLinks struct { AccessRights *LinkObject `json:"access_rights,omitempty"` Self *LinkObject `json:"self,omitempty"` Spatial *LinkObject `json:"spatial,omitempty"` Version *LinkObject `json:"version,omitempty"` WebsiteVersion *LinkObject `json:"website_version,omitempty"` }
MetadataLinks represents a link object to list of metadata) relevant to a version
type Observation ¶
type Observation struct { Dimensions map[string]*DimensionObject `json:"dimensions,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` Observation string `json:"observation"` }
Observation represents an object containing a single observation and its equivalent metadata
type ObservationLinks ¶
type ObservationLinks struct { DatasetMetadata *LinkObject `json:"dataset_metadata,omitempty"` Self *LinkObject `json:"self,omitempty"` Version *LinkObject `json:"version,omitempty"` }
ObservationLinks represents a link object to list of links relevant to the observation
type ObservationsDoc ¶
type ObservationsDoc struct { Dimensions map[string]Option `json:"dimensions"` Limit int `json:"limit"` Links *ObservationLinks `json:"links"` Observations []Observation `json:"observations"` Offset int `json:"offset"` TotalObservations int `json:"total_observations"` UnitOfMeasure string `json:"unit_of_measure,omitempty"` UsageNotes *[]UsageNote `json:"usage_notes,omitempty"` }
ObservationsDoc represents information (observations) relevant to a version
func CreateObservationsDoc ¶
func CreateObservationsDoc(rawQuery string, versionDoc *Version, datasetDoc *Dataset, observations []Observation, queryParameters map[string]string, offset, limit int) *ObservationsDoc
CreateObservationsDoc manages the creation of metadata across dataset and version docs
type Option ¶
type Option struct {
LinkObject *LinkObject `json:"option,omitempty"`
}
Option represents an object containing a list of link objects that refer to the code url for that dimension option
type PublicDimensionOption ¶
type PublicDimensionOption struct { Label string `bson:"label,omitempty" json:"label"` Links DimensionOptionLinks `bson:"links,omitempty" json:"links"` Name string `bson:"name,omitempty" json:"dimension"` Option string `bson:"option,omitempty" json:"option"` }
PublicDimensionOption hides values which are only used by interval services
type Publisher ¶
type Publisher struct { HRef string `bson:"href,omitempty" json:"href,omitempty"` Name string `bson:"name,omitempty" json:"name,omitempty"` Type string `bson:"type,omitempty" json:"type,omitempty"` }
Publisher represents an object containing information of the publisher
type TemporalFrequency ¶
type TemporalFrequency struct { EndDate string `bson:"end_date,omitempty" json:"end_date,omitempty"` Frequency string `bson:"frequency,omitempty" json:"frequency,omitempty"` StartDate string `bson:"start_date,omitempty" json:"start_date,omitempty"` }
TemporalFrequency represents a frequency for a particular period of time
type UsageNote ¶
type UsageNote struct { Note string `bson:"note,omitempty" json:"note,omitempty"` Title string `bson:"title,omitempty" json:"title,omitempty"` }
UsageNote represents a note containing extra information associated to the resource
type Version ¶
type Version struct { Alerts *[]Alert `bson:"alerts,omitempty" json:"alerts,omitempty"` CollectionID string `bson:"collection_id,omitempty" json:"collection_id,omitempty"` Dimensions []Dimension `bson:"dimensions,omitempty" json:"dimensions,omitempty"` Downloads *DownloadList `bson:"downloads,omitempty" json:"downloads,omitempty"` Edition string `bson:"edition,omitempty" json:"edition,omitempty"` Headers []string `bson:"headers,omitempty" json:"-"` ID string `bson:"id,omitempty" json:"id,omitempty"` LastUpdated time.Time `bson:"last_updated,omitempty" json:"-"` LatestChanges *[]LatestChange `bson:"latest_changes,omitempty" json:"latest_changes,omitempty"` Links *VersionLinks `bson:"links,omitempty" json:"links,omitempty"` ReleaseDate string `bson:"release_date,omitempty" json:"release_date,omitempty"` State string `bson:"state,omitempty" json:"state,omitempty"` Temporal *[]TemporalFrequency `bson:"temporal,omitempty" json:"temporal,omitempty"` UsageNotes *[]UsageNote `bson:"usage_notes,omitempty" json:"usage_notes,omitempty"` Version int `bson:"version,omitempty" json:"version,omitempty"` }
Version represents information related to a single version for an edition of a dataset
type VersionLinks ¶
type VersionLinks struct { Dataset *LinkObject `bson:"dataset,omitempty" json:"dataset,omitempty"` Dimensions *LinkObject `bson:"dimensions,omitempty" json:"dimensions,omitempty"` Edition *LinkObject `bson:"edition,omitempty" json:"edition,omitempty"` Self *LinkObject `bson:"self,omitempty" json:"self,omitempty"` Spatial *LinkObject `bson:"spatial,omitempty" json:"spatial,omitempty"` Version *LinkObject `bson:"version,omitempty" json:"-"` }
VersionLinks represents a list of specific links related to the version resource for an edition of a dataset
type VersionResults ¶
type VersionResults struct {
Items []Version `json:"items"`
}
VersionResults represents a structure for a list of versions for an edition of a dataset