Documentation
¶
Index ¶
- Constants
- Variables
- func CheckState(docType, state string) error
- func CleanDataset(dataset *Dataset)
- func ParseAndValidateVersionNumber(ctx context.Context, version string) (int, error)
- func ValidateDataset(dataset *Dataset) error
- func ValidateImportTask(task GenericTaskDetails) error
- func ValidateInstanceState(state string) error
- func ValidateStateFilter(filterList []string) error
- func ValidateVersion(version *Version) error
- type Alert
- type AlertType
- type BuildHierarchyTask
- type BuildSearchIndexTask
- type CachedDimensionOption
- type Contact
- type ContactDetails
- type Dataset
- type DatasetEdition
- type DatasetLinks
- type DatasetType
- type DatasetUpdate
- type Dimension
- type DimensionLink
- type DimensionNodeResults
- type DimensionObject
- type DimensionOption
- type DimensionOptionLinks
- type DimensionValues
- type Distribution
- type DistributionFormat
- type DistributionMediaType
- type DownloadList
- type DownloadObject
- type EditableMetadata
- type Edition
- type EditionUpdate
- type EditionUpdateLinks
- type Error
- type ErrorResponse
- type Event
- type GeneralDetails
- type GenericTaskDetails
- type ImportObservationsTask
- type Instance
- type InstanceImportTasks
- type InstanceLinks
- type IsBasedOn
- type LatestChange
- type LinkObject
- type Metadata
- type MetadataLinks
- type Observation
- type ObservationLinks
- type ObservationsDoc
- type Option
- type PublicDimensionOption
- type Publisher
- type QualityDesignation
- type StateUpdate
- type SuccessResponse
- type TemporalFrequency
- type UsageNote
- type Version
- type VersionLinks
Constants ¶
const ( BodyReadError = "RequestBodyReadError" JSONMarshalError = "JSONMarshalError" JSONUnmarshalError = "JSONUnmarshalError" WriteResponseError = "WriteResponseError" ErrDatasetNotFound = "ErrDatasetNotFound" ErrMissingParameters = "ErrMissingParameters" ErrVersionAlreadyExists = "ErrVersionAlreadyExists" InternalError = "InternalServerError" NotFoundError = "NotFound" MissingConfigError = "MissingConfig" UnknownRequestTypeError = "UnknownRequestType" NotImplementedError = "NotImplemented" BodyCloseError = "BodyCloseError" ErrInvalidTypeError = "InvalidType" )
const ( ErrorMarshalFailedDescription = "failed to marshal the error" ErrorUnmarshalFailedDescription = "failed to unmarshal the request body" WriteResponseFailedDescription = "failed to write http response" BodyReadFailedDescription = "endpoint returned an error reading the request body" MissingConfigDescription = "required configuration setting is missing" NotImplementedDescription = "this feature has not been implemented yet" BodyClosedFailedDescription = "the request body failed to close" InternalErrorDescription = "Internal Server Error" ErrDatasetNotFoundDescription = "dataset not found" ErrMissingParametersDescription = "missing properties in JSON" ErrVersionAlreadyExistsDescription = "an unpublished version of this dataset already exists" ErrInvalidType = "version type should be static" )
API error descriptions
const ( CreatedState = "created" SubmittedState = "submitted" CompletedState = "completed" EditionConfirmedState = "edition-confirmed" AssociatedState = "associated" ApprovedState = "approved" PublishedState = "published" DetachedState = "detached" FailedState = "failed" )
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") ErrVersionStateDatasetTypeInvalid = errors.New("incorrect state for dataset type") ErrVersionStateInvalid = errors.New("incorrect state, can be one of the following: edition-confirmed, associated, approved or published") )
List of error variables
var (
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 CleanDataset ¶ added in v1.27.0
func CleanDataset(dataset *Dataset)
CleanDataset trims URI and any hrefs contained in the database
func ParseAndValidateVersionNumber ¶ added in v1.42.0
ParseAndValidateVersionNumber checks the version is a positive integer above 0
func ValidateDataset ¶ added in v1.23.0
ValidateDataset checks the dataset has invalid fields
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 TODO: Refactor this to reduce the complexity
Types ¶
type Alert ¶
type Alert struct {
Date string `bson:"date,omitempty" json:"date,omitempty"`
Description string `bson:"description,omitempty" json:"description,omitempty"`
Type AlertType `bson:"type,omitempty" json:"type,omitempty"`
}
Alert represents an object containing information on an alert
type AlertType ¶ added in v1.67.0
type AlertType string
AlertType defines possible types of alerts
Define the possible values for the AlertType enum
func (AlertType) IsValid ¶ added in v1.67.0
IsValid validates that the AlertType is a valid enum value
func (AlertType) MarshalJSON ¶ added in v1.67.0
MarshalJSON marshals the AlertType to JSON
func (*AlertType) UnmarshalJSON ¶ added in v1.67.0
UnmarshalJSON unmarshals a string to AlertType
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"`
Order *int `bson:"order,omitempty" json:"order"`
}
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:"last_updated,omitempty"`
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"`
Type string `bson:"type,omitempty" json:"type,omitempty"`
IsBasedOn *IsBasedOn `bson:"is_based_on,omitempty" json:"is_based_on,omitempty"`
CanonicalTopic string `bson:"canonical_topic,omitempty" json:"canonical_topic,omitempty"`
Subtopics []string `bson:"subtopics,omitempty" json:"subtopics,omitempty"`
Survey string `bson:"survey,omitempty" json:"survey,omitempty"`
RelatedContent []GeneralDetails `bson:"related_content,omitempty" json:"related_content,omitempty"`
Topics []string `bson:"topics,omitempty" json:"topics,omitempty"`
}
Dataset represents information related to a single dataset
func CreateDataset ¶
CreateDataset manages the creation of a dataset from a reader
func (*Dataset) UpdateMetadata ¶ added in v1.56.0
func (d *Dataset) UpdateMetadata(metadata EditableMetadata)
UpdateMetadata updates the metadata fields for a dataset
type DatasetEdition ¶ added in v1.82.0
type DatasetEdition struct {
DatasetID string `json:"dataset_id"`
Title string `json:"title"`
Edition string `json:"edition"`
EditionTitle string `json:"edition_title"`
LatestVersion LinkObject `json:"latest_version"`
ReleaseDate string `json:"release_date"`
State string `json:"state"`
}
DatasetEdition represents a dataset edition
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 DatasetType ¶ added in v1.25.0
type DatasetType int
DatasetType defines possible dataset types
const ( Filterable DatasetType = iota CantabularTable CantabularBlob CantabularFlexibleTable CantabularMultivariateTable Static Invalid )
possible dataset types
func GetDatasetType ¶ added in v1.25.0
func GetDatasetType(datasetType string) (DatasetType, error)
GetDatasetType returns a dataset type for a given dataset
func ValidateDatasetType ¶ added in v1.25.0
func ValidateDatasetType(ctx context.Context, datasetType string) (*DatasetType, error)
ValidateDatasetType checks the dataset.type field has valid type
func (DatasetType) String ¶ added in v1.25.0
func (dt DatasetType) String() string
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 Note: Stored as Dataset (in `dataset` Collection) in MongoDB
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"`
Variable string `bson:"variable,omitempty" json:"variable,omitempty"`
NumberOfOptions *int `bson:"number_of_options,omitempty" json:"number_of_options,omitempty"`
IsAreaType *bool `bson:"is_area_type,omitempty" json:"is_area_type,omitempty"`
QualityStatementText string `bson:"quality_statement_text,omitempty" json:"quality_statement_text,omitempty"`
QualityStatementURL string `bson:"quality_statement_url,omitempty" json:"quality_statement_url,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"`
Order *int `bson:"order,omitempty" json:"order"`
}
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 DimensionValues ¶
DimensionValues holds all unique values for a dimension
type Distribution ¶ added in v1.70.0
type Distribution struct {
Title string `bson:"title,omitempty" json:"title,omitempty"`
Format DistributionFormat `bson:"format,omitempty" json:"format,omitempty"`
MediaType DistributionMediaType `bson:"media_type,omitempty" json:"media_type,omitempty"`
DownloadURL string `bson:"download_url,omitempty" json:"download_url,omitempty"`
ByteSize int64 `bson:"byte_size,omitempty" json:"byte_size,omitempty"`
}
Distribution represents a specific distribution of the dataset
type DistributionFormat ¶ added in v1.70.0
type DistributionFormat string
DistributionFormat enum type representing the allowable formats for the distribution download file
const ( DistributionFormatCSV DistributionFormat = "csv" DistributionFormatSDMX DistributionFormat = "sdmx" DistributionFormatXLS DistributionFormat = "xls" DistributionFormatXLSX DistributionFormat = "xlsx" DistributionFormatCSDB DistributionFormat = "csdb" DistributionFormatCSVWMeta DistributionFormat = "csvw-metadata" )
Define the possible values for the DistributionFormat enum
func (*DistributionFormat) IsValid ¶ added in v1.70.0
func (f *DistributionFormat) IsValid() bool
IsValid validates that the DistributionFormat is a valid enum value
func (DistributionFormat) MarshalJSON ¶ added in v1.70.0
func (f DistributionFormat) MarshalJSON() ([]byte, error)
MarshalJSON marshals the DistributionFormat to JSON
func (DistributionFormat) String ¶ added in v1.70.0
func (f DistributionFormat) String() string
String returns the string value of the DistributionFormat
func (*DistributionFormat) UnmarshalJSON ¶ added in v1.70.0
func (f *DistributionFormat) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals a string to DistributionFormat
type DistributionMediaType ¶ added in v1.70.0
type DistributionMediaType string
DistributionMediaType enum type representing the allowable media types for the distribution download file
const ( DistributionMediaTypeCSV DistributionMediaType = "text/csv" DistributionMediaTypeSDMX DistributionMediaType = "application/vnd.sdmx.structurespecificdata+xml" DistributionMediaTypeXLS DistributionMediaType = "application/vnd.ms-excel" DistributionMediaTypeXLSX DistributionMediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" DistributionMediaTypeCSDB DistributionMediaType = "text/plain" DistributionMediaTypeCSVWMeta DistributionMediaType = "application/ld+json" )
Define the possible values for the DistributionMediaType enum
func (*DistributionMediaType) IsValid ¶ added in v1.70.0
func (mt *DistributionMediaType) IsValid() bool
IsValid validates that the DistributionMediaType is a valid enum value
func (DistributionMediaType) MarshalJSON ¶ added in v1.70.0
func (mt DistributionMediaType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the DistributionMediaType to JSON
func (DistributionMediaType) String ¶ added in v1.70.0
func (mt DistributionMediaType) String() string
String returns the string value of the DistributionMediaType
func (*DistributionMediaType) UnmarshalJSON ¶ added in v1.70.0
func (mt *DistributionMediaType) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals a string to DistributionMediaType
type DownloadList ¶
type DownloadList struct {
XLS *DownloadObject `bson:"xls,omitempty" json:"xls,omitempty"`
XLSX *DownloadObject `bson:"xlsx,omitempty" json:"xlsx,omitempty"`
CSV *DownloadObject `bson:"csv,omitempty" json:"csv,omitempty"`
TXT *DownloadObject `bson:"txt,omitempty" json:"txt,omitempty"`
CSVW *DownloadObject `bson:"csvw,omitempty" json:"csvw,omitempty"`
}
DownloadList represents a list of objects of containing information on the downloadable files. Items are in a specific order and should not be changed (xls, xlsx, csv, txt, csvw)
func CreateDownloadList ¶
func CreateDownloadList(reader io.Reader) (*DownloadList, error)
CreateDownloadList manages the creation of a list downloadable items from a reader
func (*DownloadList) ExtensionsMapping ¶ added in v1.79.0
func (dl *DownloadList) ExtensionsMapping() map[*DownloadObject]string
Maps `DownloadObjects` in input `DownloadList` to their corresponding extension strings
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 EditableMetadata ¶ added in v1.56.0
type EditableMetadata struct {
Alerts *[]Alert `json:"alerts,omitempty"`
CanonicalTopic string `json:"canonical_topic,omitempty"`
Contacts []ContactDetails `json:"contacts,omitempty"`
Description string `json:"description,omitempty"`
Dimensions []Dimension `json:"dimensions,omitempty"`
Distributions *[]Distribution `json:"distributions,omitempty"`
Keywords []string `json:"keywords,omitempty"`
LastUpdated time.Time `json:"last_updated,omitempty"`
LatestChanges *[]LatestChange `json:"latest_changes,omitempty"`
License string `json:"license,omitempty"`
Methodologies []GeneralDetails `json:"methodologies,omitempty"`
NationalStatistic *bool `json:"national_statistic,omitempty"`
NextRelease string `json:"next_release,omitempty"`
Publications []GeneralDetails `json:"publications,omitempty"`
QMI *GeneralDetails `json:"qmi,omitempty"`
RelatedDatasets []GeneralDetails `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"`
QualityDesignation QualityDesignation `json:"quality_designation,omitempty"`
Topics []string `json:"topics,omitempty"`
}
EditableMetadata represents the metadata fields that can be edited
type Edition ¶
type Edition struct {
Edition string `bson:"edition,omitempty" json:"edition,omitempty"`
EditionTitle string `bson:"edition_title,omitempty" json:"edition_title,omitempty"`
ID string `bson:"id,omitempty" json:"id,omitempty"`
DatasetID string `bson:"dataset_id,omitempty" json:"dataset_id,omitempty"`
Version int `bson:"version,omitempty" json:"version,omitempty"`
LastUpdated time.Time `bson:"last_updated,omitempty" json:"-"`
ReleaseDate string `bson:"release_date,omitempty" json:"release_date,omitempty"`
Links *EditionUpdateLinks `bson:"links,omitempty" json:"links,omitempty"`
State string `bson:"state,omitempty" json:"state,omitempty"`
Alerts *[]Alert `bson:"alerts,omitempty" json:"alerts,omitempty"`
UsageNotes *[]UsageNote `bson:"usage_notes,omitempty" json:"usage_notes,omitempty"`
Distributions *[]Distribution `bson:"distributions,omitempty" json:"distributions,omitempty"`
IsBasedOn *IsBasedOn `bson:"is_based_on,omitempty" json:"is_based_on,omitempty"`
Type string `bson:"type,omitempty" json:"type,omitempty"`
QualityDesignation QualityDesignation `bson:"quality_designation,omitempty" json:"quality_designation,omitempty"`
}
Edition represents information related to a single edition 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 an edition object
func (*EditionUpdate) PublishLinks ¶
func (ed *EditionUpdate) PublishLinks(ctx context.Context, 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 Error ¶ added in v1.81.0
type Error struct {
Cause error `json:"-"` // The underlying error, if available.
Code string `json:"code"` // Error code representing the type of error.
Description string `json:"description"` // Detailed description of the error.
}
Error represents a custom error type with additional context and description.
func NewError ¶ added in v1.81.0
NewError creates and logs a new Error with the provided context, cause, code, and description.
func NewValidationError ¶ added in v1.81.0
NewValidationError creates a new Error specifically for validation errors with a code and description.
type ErrorResponse ¶ added in v1.81.0
type ErrorResponse struct {
Errors []Error `json:"errors"`
Status int `json:"-"`
Headers map[string]string `json:"-"`
}
func NewErrorResponse ¶ added in v1.81.0
func NewErrorResponse(statusCode int, headers map[string]string, errors ...Error) *ErrorResponse
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"`
ETag string `bson:"e_tag" json:"-"`
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 bsonprim.Timestamp `bson:"unique_timestamp" json:"-"`
Version int `bson:"version,omitempty" json:"version,omitempty"`
Type string `bson:"type,omitempty" json:"type,omitempty"`
IsBasedOn *IsBasedOn `bson:"is_based_on,omitempty" json:"is_based_on,omitempty"`
LowestGeography string `bson:"lowest_geography,omitempty" json:"lowest_geography,omitempty"`
Description string `bson:"description,omitempty" json:"description,omitempty"`
Title string `bson:"title,omitempty" json:"title,omitempty"`
NextRelease string `bson:"next_release,omitempty" json:"next_release,omitempty"`
}
Instance which presents a single dataset being imported
func (*Instance) Hash ¶ added in v1.34.0
Hash generates a SHA-1 hash of the instance struct. SHA-1 is not cryptographically safe, but it has been selected for performance as we are only interested in uniqueness. ETag field value is ignored when generating a hash. An optional byte array can be provided to append to the hash. This can be used, for example, to calculate a hash of this instance and an update applied to it.
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 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 containing 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 {
EditableMetadata
Distribution []string `json:"distribution,omitempty"`
Downloads *DownloadList `json:"downloads,omitempty"`
Links *MetadataLinks `json:"links,omitempty"`
TableID string `json:"table_id,omitempty"`
CSVHeader []string `json:"headers,omitempty"`
Edition string `json:"edition,omitempty"`
EditionTitle string `json:"edition_title,omitempty"`
DatasetLinks *DatasetLinks `json:"dataset_links,omitempty"`
ID string `json:"id,omitempty"`
Publisher *Publisher `json:"publisher,omitempty"`
Temporal *[]TemporalFrequency `json:"temporal,omitempty"`
Theme string `json:"theme,omitempty"`
URI string `json:"uri,omitempty"`
Coverage string `json:"coverage,omitempty"`
TablePopulation string `json:"table_population,omitempty"`
AreaType string `json:"area_type,omitempty"`
Classifications string `json:"classifications,omitempty"`
Source string `json:"source,omitempty"`
IsBasedOn *IsBasedOn `json:"is_based_on,omitempty"`
Type string `json:"type,omitempty"`
Version int `json:"version,omitempty"`
}
Metadata represents information (metadata) relevant to a version
func CreateCantabularMetaDataDoc ¶ added in v1.37.0
CreateCantabularMetaDataDoc manages the creation of metadata across dataset and version docs for cantabular datasets note: logic to retrieve the newly-added Cantabular-specific fields to the Metadata model will be created at a later date
func CreateMetaDataDoc ¶
CreateMetaDataDoc manages the creation of metadata across dataset and version docs
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 QualityDesignation ¶ added in v1.67.0
type QualityDesignation string
QualityDesignation enum type representing the allowable quality designations for a dataset
const ( QualityDesignationAccreditedOfficial QualityDesignation = "accredited-official" QualityDesignationOfficialInDevelopment QualityDesignation = "official-in-development" QualityDesignationOfficial QualityDesignation = "official" )
Define the possible values for the QualityDesignation enum
func (*QualityDesignation) IsValid ¶ added in v1.67.0
func (qd *QualityDesignation) IsValid() bool
IsValid validates that the QualityDesignation is a valid enum value
func (QualityDesignation) MarshalJSON ¶ added in v1.67.0
func (qd QualityDesignation) MarshalJSON() ([]byte, error)
MarshalJSON marshals the QualityDesignation to JSON
func (QualityDesignation) String ¶ added in v1.70.0
func (qd QualityDesignation) String() string
String returns the string value of the QualityDesignation
func (*QualityDesignation) UnmarshalJSON ¶ added in v1.67.0
func (qd *QualityDesignation) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals a string to QualityDesignation
type StateUpdate ¶ added in v1.75.0
type StateUpdate struct {
State string `json:"state"`
}
type SuccessResponse ¶ added in v1.81.0
type SuccessResponse struct {
Body []byte `json:"-"`
Status int `json:"-"`
Headers map[string]string `json:"-"`
}
func NewSuccessResponse ¶ added in v1.81.0
func NewSuccessResponse(jsonBody []byte, statusCode int, headers map[string]string) *SuccessResponse
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"`
DatasetID string `bson:"-" json:"dataset_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"`
EditionTitle string `bson:"edition_title,omitempty" json:"edition_title,omitempty"`
Headers []string `bson:"headers,omitempty" json:"-"`
ID 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 *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"`
IsBasedOn *IsBasedOn `bson:"is_based_on,omitempty" json:"is_based_on,omitempty"`
Version int `bson:"version,omitempty" json:"version,omitempty"`
Type string `bson:"type,omitempty" json:"type,omitempty"`
ETag string `bson:"e_tag" json:"-"`
LowestGeography string `bson:"lowest_geography,omitempty" json:"lowest_geography,omitempty"`
QualityDesignation QualityDesignation `bson:"quality_designation,omitempty" json:"quality_designation,omitempty"`
Distributions *[]Distribution `bson:"distributions,omitempty" json:"distributions,omitempty"`
}
Version represents information related to a single version for an edition of a dataset
func CreateVersion ¶
CreateVersion manages the creation of a version from a reader
func (*Version) Hash ¶ added in v1.41.0
Hash generates a SHA-1 hash of the version struct. SHA-1 is not cryptographically safe, but it has been selected for performance as we are only interested in uniqueness. ETag field value is ignored when generating a hash. An optional byte array can be provided to append to the hash. This can be used, for example, to calculate a hash of this version and an update applied to it.
func (*Version) UpdateMetadata ¶ added in v1.56.0
func (v *Version) UpdateMetadata(metadata EditableMetadata)
UpdateMetadata updates the metadata fields for a version
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
func (*VersionLinks) DeepCopy ¶ added in v1.41.0
func (vl *VersionLinks) DeepCopy() *VersionLinks