models

package
v0.0.0-...-87f5b26 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventFilterOutputCreated      = "FilterOutputCreated"
	EventFilterOutputQueryStart   = "FilterOutputQueryStart"
	EventFilterOutputQueryEnd     = "FilterOutputQueryEnd"
	EventFilterOutputCSVGenStart  = "FilterOutputCSVGenStart"
	EventFilterOutputCSVGenEnd    = "FilterOutputCSVGenEnd"
	EventFilterOutputXLSXGenStart = "FilterOutputXLSXGenStart"
	EventFilterOutputXLSXGenEnd   = "FilterOutputXLSXGenEnd"
	EventFilterOutputCompleted    = "FilterOutputCompleted"
)

A list of event types

View Source
const (
	CreatedState   = "created"
	CompletedState = "completed"
)

A list of states

Variables

View Source
var (
	Unpublished = false
	Published   = true
)
View Source
var (
	ErrorReadingBody = errors.New("failed to read message body")
	ErrorParsingBody = errors.New("failed to parse json body")
	ErrorNoData      = errors.New("bad request - missing data in body")
)

A list of errors returned from package

Functions

func CreateDimensionOptions

func CreateDimensionOptions(reader io.Reader) ([]string, error)

CreateDimensionOptions manages the creation of options for a dimension from a reader

func CreatePatches

func CreatePatches(reader io.Reader) ([]dprequest.Patch, error)

CreatePatches manages the creation of an array of patch structs from the provided reader, and validates them

func ValidateFilterBlueprintUpdate

func ValidateFilterBlueprintUpdate(filter *Filter) error

ValidateFilterBlueprintUpdate checks the content of the filter structure for changes against the dataset

func ValidateFilterDimensions

func ValidateFilterDimensions(filterDimensions []Dimension, dimensions *dataset.VersionDimensions) error

ValidateFilterDimensions checks the selected filter dimension are valid for a version of a dataset

Types

type Dataset

type Dataset struct {
	ID      string `bson:"id"        json:"id"`
	Edition string `bson:"edition"   json:"edition"`
	Version int    `bson:"version"   json:"version"`
}

Dataset contains the uniique identifiers that make a dataset unique

type Dimension

type Dimension struct {
	URL        string   `bson:"dimension_url,omitempty" json:"dimension_url,omitempty"`
	Name       string   `bson:"name"                    json:"name"`
	Options    []string `bson:"options,omitempty"       json:"options"`
	IsAreaType *bool    `bson:"is_area_type,omitempty"  json:"is_area_type,omitempty"`
}

Dimension represents an object containing a list of dimension values and the dimension name

func (*Dimension) EncodedOptions

func (d *Dimension) EncodedOptions() []string

EncodedOptions returns the list of options for this dimension after escaping the values for URL query paramters

type DimensionItemLinks struct {
	Filter  LinkObject `json:"filter"`
	Options LinkObject `json:"options"`
	Self    LinkObject `json:"self"`
}

type DownloadItem

type DownloadItem struct {
	Skipped bool   `bson:"skipped,omitempty" json:"skipped,omitempty"`
	HRef    string `bson:"href,omitempty"    json:"href,omitempty"`
	Private string `bson:"private,omitempty" json:"private,omitempty"`
	Public  string `bson:"public,omitempty"  json:"public,omitempty"`
	Size    string `bson:"size,omitempty"    json:"size,omitempty"`
}

DownloadItem represents an object containing information for the download item

type Downloads

type Downloads struct {
	CSV *DownloadItem `bson:"csv,omitempty"  json:"csv,omitempty"`
	XLS *DownloadItem `bson:"xls,omitempty"  json:"xls,omitempty"`
}

Downloads represents a list of file types possible to download

type DuplicateDimensionError

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

DuplicateDimensionError is returned if a request contains a duplicate dimension

func (DuplicateDimensionError) Error

func (e DuplicateDimensionError) Error() string

type Event

type Event struct {
	Type string    `bson:"type,omitempty" json:"type"`
	Time time.Time `bson:"time,omitempty" json:"time"`
}

Event captures the time certain stages of filter response were completed

func (*Event) Validate

func (e *Event) Validate() error

Validate the content of the event structure are recognized event names and a non-zero time

type Filter

type Filter struct {
	UniqueTimestamp primitive.Timestamp `bson:"unique_timestamp,omitempty" json:"-"`
	LastUpdated     time.Time           `bson:"last_updated"               json:"-"`
	ETag            string              `bson:"e_tag"                      json:"-"`

	ID         string      `bson:"id"                    json:"id,omitempty"`
	Dataset    *Dataset    `bson:"dataset"              json:"dataset"`
	InstanceID string      `bson:"instance_id"          json:"instance_id"`
	Dimensions []Dimension `bson:"dimensions,omitempty" json:"dimensions,omitempty"`
	Downloads  *Downloads  `bson:"downloads,omitempty"  json:"downloads,omitempty"`
	Events     []*Event    `bson:"events,omitempty"     json:"events,omitempty"`
	FilterID   string      `bson:"filter_id"            json:"filter_id,omitempty"`
	State      string      `bson:"state,omitempty"      json:"state,omitempty"`
	Published  *bool       `bson:"published,omitempty"  json:"published,omitempty"`
	Links      LinkMap     `bson:"links"                json:"links,omitempty"`
	Type       string      `bson:"type,omitempty"       json:"type,omitempty"`
}

Filter represents a structure for a filter job

func CreateFilter

func CreateFilter(reader io.Reader) (*Filter, error)

CreateFilter manages the creation of a filter from a reader

func (*Filter) Hash

func (f *Filter) Hash(extraBytes []byte) (string, error)

Hash generates a SHA-1 hash of the filter 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 filter and an update applied to it.

func (*Filter) RemoveDuplicateEvents

func (filter *Filter) RemoveDuplicateEvents(currentFilter *Filter)

func (*Filter) ValidateFilterOutputUpdate

func (filter *Filter) ValidateFilterOutputUpdate(currentFilter *Filter) error

ValidateFilterOutputUpdate checks the content of the filter structure

type LinkMap

type LinkMap struct {
	Dimensions      *LinkObject `bson:"dimensions"                 json:"dimensions,omitempty"`
	FilterOutput    *LinkObject `json:"filter_output,omitempty"`
	FilterBlueprint *LinkObject `bson:"filter_blueprint,omitempty" json:"filter_blueprint,omitempty"`
	Self            *LinkObject `bson:"self"                       json:"self,omitempty"`
	Version         *LinkObject `bson:"version"                    json:"version,omitempty"`
}

LinkMap contains a named *LinkObject for each link to other resources

type LinkObject

type LinkObject struct {
	ID   string `bson:"id,omitempty" json:"id,omitempty"`
	HRef string `bson:"href"         json:"href,omitempty"`
}

LinkObject represents a generic structure for all links

type NewFilter

type NewFilter struct {
	Dataset    *Dataset    `bson:"dataset" json:"dataset"`
	Dimensions []Dimension `bson:"dimensions,omitempty" json:"dimensions,omitempty"`
}

NewFilter creates a filter by using the dataset id, edition and version

func CreateNewFilter

func CreateNewFilter(reader io.Reader) (*NewFilter, error)

CreateNewFilter manages the creation of a filter blueprint being updated (new filter)

func (*NewFilter) ValidateNewFilter

func (filter *NewFilter) ValidateNewFilter() error

ValidateNewFilter checks the content of the filter structure

type PublicDimension

type PublicDimension struct {
	Name  string                  `bson:"name"                    json:"name"`
	Links *PublicDimensionLinkMap `bson:"links"                   json:"links"`
}

PublicDimension represents information about a single dimension as served by /dimensions and /dimensions/<id>

type PublicDimensionLinkMap

type PublicDimensionLinkMap struct {
	Self    *LinkObject `bson:"self"                 json:"self"`
	Filter  *LinkObject `bson:"filter"               json:"filter"`
	Options *LinkObject `bson:"options"              json:"options,omitempty"`
}

PublicDimensionLinkMap is the links map for the PublicDimension structure

type PublicDimensionOption

type PublicDimensionOption struct {
	Links  *PublicDimensionOptionLinkMap `bson:"links"               json:"links"`
	Option string                        `bson:"option"              json:"option"`
}

PublicDimensionOption represents information about a single dimension option as served by /options and /options/<id>

type PublicDimensionOptionLinkMap

type PublicDimensionOptionLinkMap struct {
	Self      *LinkObject `bson:"self"                 json:"self"`
	Filter    *LinkObject `bson:"filter"               json:"filter"`
	Dimension *LinkObject `bson:"dimension"            json:"dimension"`
}

PublicDimensionOptionLinkMap is the links map for the PublicDimensionOption structure

type PublicDimensionOptions

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

PublicDimensionOptions represents information about a set of dimension options

type PublicDimensions

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

type UpdateDimensionResponse

type UpdateDimensionResponse struct {
	ID    string             `json:"id"`
	Name  string             `json:"name"`
	Label string             `json:"label"`
	Links DimensionItemLinks `json:"links"`
}

type Version

type Version struct {
	ID      string       `json:"id,omitempty"`
	Links   VersionLinks `json:"links,omitempty"`
	State   string       `json:"state,omitempty"`
	Version int          `json:"version,omitempty"`
}

Version represents the json returned from the dataset API for a version resource

type VersionLinks struct {
	Dataset *LinkObject `bson:"dataset,omitempty" json:"dataset"`
	Edition *LinkObject `bson:"edition,omitempty" json:"edition"`
	Self    *LinkObject `bson:"self,omitempty"    json:"self"`
	Version *LinkObject `bson:"version,omitempty" json:"version"`
}

VersionLinks represents a list of link objects related to the version resource

Jump to

Keyboard shortcuts

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