models

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

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

CreatedState represents onse possible state of the job resource

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildHierarchyTask

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

BuildHierarchyTask represents a task of importing a single hierarchy.

type BuildSearchIndexTask

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

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

type CodeList

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

type DataBakerEvent

type DataBakerEvent struct {
	JobID string `avro:"job_id"`
}

DataBakerEvent used to trigger the databaker process

type Event

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

Event which has happened to an instance

type IDLink struct {
	ID   string `json:"id"`
	HRef string `json:"href"`
}

IDLink holds the ID and a link to the resource

type ImportData

type ImportData struct {
	JobID         string
	Recipe        string          `json:"recipe,omitempty"`
	Format        string          `json:"format,omitempty"`
	UploadedFiles *[]UploadedFile `json:"files,omitempty"`
	InstanceIDs   []string
}

ImportData used to create a message to data baker or direct to the dimension-extractor

type ImportObservationsTask

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

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

type Instance

type Instance struct {
	InstanceID        string               `json:"id,omitempty"`
	Links             *InstanceLinks       `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"`
}

Instance which presents a single dataset being imported

func CreateInstance

func CreateInstance(job *Job, datasetID, datasetURL string, codelists []CodeList) *Instance

CreateInstance from a job ID

type InstanceImportTasks

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

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

type InstanceLinks struct {
	Job     IDLink `json:"job,omitempty"`
	Dataset IDLink `json:"dataset,omitempty"`
}

type Job

type Job struct {
	ID              string              `bson:"id,omitempty"               json:"id,omitempty"`
	RecipeID        string              `bson:"recipe,omitempty"           json:"recipe,omitempty"`
	State           string              `bson:"state,omitempty"            json:"state,omitempty"`
	UploadedFiles   *[]UploadedFile     `bson:"files,omitempty"            json:"files,omitempty"`
	Links           LinksMap            `bson:"links,omitempty"            json:"links,omitempty"`
	LastUpdated     time.Time           `bson:"last_updated,omitempty"     json:"last_updated,omitempty"`
	UniqueTimestamp bson.MongoTimestamp `bson:"unique_timestamp,omitempty" json:"-"`
}

Job for importing datasets

func CreateJob

func CreateJob(reader io.Reader) (*Job, error)

CreateJob from a json message

func (*Job) Validate

func (job *Job) Validate() error

Validate the content of a job

func (*Job) ValidateState

func (job *Job) ValidateState() error

ValidateState checks the state is valid

type JobResults

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

JobResults for list of Job items

type LinksMap

type LinksMap struct {
	Instances []IDLink `bson:"instances,omitempty" json:"instances,omitempty"`
	Self      IDLink   `bson:"self,omitempty" json:"self,omitempty"`
}

LinksMap represents a list of links related to a job resource

type Recipe

type Recipe struct {
	ID              string           `json:"id"`
	Alias           string           `json:"alias"`
	Format          string           `json:"format,omitempty"`
	OutputInstances []RecipeInstance `json:"output_instances"`
	InputFiles      []file           `json:"files,omitempty"`
	CantabularBlob  string           `json:"cantabular_blob,omitempty"`
}

this should probably be replaced with an import of github.com/ONSdigital/dp-code-list-api/{pkg when unstubbed}

type RecipeInstance

type RecipeInstance struct {
	DatasetID string     `json:"dataset_id"`
	CodeLists []CodeList `json:"code_lists"`
}

type UploadedFile

type UploadedFile struct {
	AliasName string `bson:"alias_name" json:"alias_name" avro:"alias-name"`
	URL       string `bson:"url"        json:"url"        avro:"url"`
}

UploadedFile used for a file which has been uploaded to a bucket

func CreateUploadedFile

func CreateUploadedFile(reader io.Reader) (*UploadedFile, error)

CreateUploadedFile from a json message

func (UploadedFile) Validate

func (s UploadedFile) Validate() error

Validate the content of the structure

Jump to

Keyboard shortcuts

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