Documentation
¶
Index ¶
- Constants
- func IsFailedState(state State) bool
- func IsValidJobType(state JobType) bool
- func IsValidState(state State) bool
- func ValidateDatasetID(id string) error
- func ValidateZebedeeURI(path string) error
- type Counter
- type Event
- type EventLinks
- type Job
- type JobConfig
- type JobLinks
- type JobType
- type JobValidator
- type LinkObject
- type State
- type StaticDatasetValidator
- func (v *StaticDatasetValidator) ValidateSourceID(sourceID string) error
- func (v *StaticDatasetValidator) ValidateSourceIDWithExternal(ctx context.Context, sourceID string, appClients *clients.ClientList) (string, error)
- func (v *StaticDatasetValidator) ValidateTargetID(targetID string) error
- func (v *StaticDatasetValidator) ValidateTargetIDWithExternal(ctx context.Context, targetID string, appClients *clients.ClientList) error
- type Task
- type TaskLinks
- type TaskMetadata
- type TaskType
- type User
Constants ¶
const ( // OpenGovernmentLicence is a const for populating license fields with // the Open Government Licence v3.0 OpenGovernmentLicence = "Open Government Licence v3.0" )
const ( // SystemUserID is the default user ID used for events when // no user ID is provided. This is typically used for // automated or system-generated events. SystemUserID = "system" )
Variables ¶
This section is empty.
Functions ¶
func IsFailedState ¶ added in v0.15.0
IsFailedState checks if the provided state is a failure state.
func IsValidJobType ¶ added in v0.7.0
IsValidJobType checks if the provided JobType is valid
func IsValidState ¶ added in v0.20.0
IsValidState checks if the provided state is a valid State.
func ValidateDatasetID ¶ added in v0.7.0
ValidateDatasetID validates if the given id is a valid dataset ID
func ValidateZebedeeURI ¶ added in v0.7.0
ValidateZebedeeURI validates if the given path is a valid URI path
Types ¶
type Counter ¶ added in v0.19.0
type Counter struct {
CounterName string `json:"counter_name" bson:"counter_name"`
CounterValue int `json:"counter_value" bson:"counter_value"`
}
Counter represents a counter relating to migration e.g. a counter for creating new job numbers
type Event ¶
type Event struct {
ID string `json:"id" bson:"_id"`
CreatedAt string `json:"created_at" bson:"created_at"`
RequestedBy *User `json:"requested_by" bson:"requested_by"`
Action string `json:"action" bson:"action"`
JobNumber int `json:"job_number" bson:"job_number"`
Links EventLinks `json:"links" bson:"links"`
}
Event represents a migration job event (state change)
type EventLinks ¶ added in v0.12.0
type EventLinks struct {
Self *LinkObject `bson:"self,omitempty" json:"self,omitempty"`
Job *LinkObject `bson:"job,omitempty" json:"job,omitempty"`
}
EventLinks contains HATEOAS links for a migration event
func NewEventLinks ¶ added in v0.12.0
func NewEventLinks(id, jobNumber string) EventLinks
NewEventLinks creates EventLinks for an event with the given ID and jobID
type Job ¶
type Job struct {
ID string `json:"id" bson:"_id"`
JobNumber int `json:"job_number" bson:"job_number"`
Label string `json:"label" bson:"label"`
LastUpdated time.Time `json:"last_updated" bson:"last_updated"`
State State `json:"state" bson:"state"`
Config *JobConfig `json:"config" bson:"config"`
Links JobLinks `json:"links" bson:"links"`
}
Job represents a migration job
type JobConfig ¶
type JobConfig struct {
SourceID string `json:"source_id" bson:"source_id"`
TargetID string `json:"target_id" bson:"target_id"`
Type JobType `json:"type" bson:"type"`
Validator JobValidator `json:"-" bson:"-"`
}
JobConfig represents the configuration for a migration job
func (*JobConfig) ValidateExternal ¶ added in v0.7.0
func (jc *JobConfig) ValidateExternal(ctx context.Context, appClients clients.ClientList) (string, error)
ValidateExternal performs validation of the JobConfig fields against external systems
func (*JobConfig) ValidateInternal ¶ added in v0.7.0
ValidateInternal performs internal validation of the JobConfig fields
type JobLinks ¶ added in v0.7.0
type JobLinks struct {
Self *LinkObject `bson:"self,omitempty" json:"self,omitempty"`
Tasks *LinkObject `bson:"tasks,omitempty" json:"tasks,omitempty"`
Events *LinkObject `bson:"events,omitempty" json:"events,omitempty"`
}
JobLinks contains HATEOS links for a migration job
func NewJobLinks ¶ added in v0.7.0
NewJobLinks creates JobLinks for a job with the given ID
type JobType ¶ added in v0.7.0
type JobType string
JobType represents the type of migration job
const (
JobTypeStaticDataset JobType = "static_dataset"
)
type JobValidator ¶ added in v0.7.0
type JobValidator interface {
ValidateSourceID(sourceID string) error
ValidateSourceIDWithExternal(ctx context.Context, sourceID string, appClients *clients.ClientList) (string, error)
ValidateTargetID(targetID string) error
ValidateTargetIDWithExternal(ctx context.Context, targetID string, appClients *clients.ClientList) error
}
JobValidator defines the contract for validating job configurations against external systems
func GetValidator ¶ added in v0.7.0
func GetValidator(jobType JobType) (JobValidator, error)
GetValidator retrieves the appropriate validator for the given jobType
type LinkObject ¶ added in v0.7.0
type LinkObject struct {
HRef string `bson:"href,omitempty" json:"href,omitempty"`
ID int `bson:"id,omitempty" json:"id,omitempty"`
}
LinkObject represents a generic structure for all links
type State ¶ added in v0.20.0
type State string
State represents the various states a migration job can be in.
const ( // StateSubmitted indicates a job or task has been submitted StateSubmitted State = "submitted" // StateInReview indicates a job or task is in review StateInReview State = "in_review" // StateApproved indicates a job or task has been approved StateApproved State = "approved" // StateRejected indicates a job or task has been rejected StateRejected State = "rejected" // StatePublished indicates a job or task has been published StatePublished State = "published" // StateCompleted indicates a job or task has completed successfully StateCompleted State = "completed" // StateMigrating indicates a job or task is currently migrating StateMigrating State = "migrating" // StatePublishing indicates a job or task is currently publishing StatePublishing State = "publishing" // StatePostPublishing indicates a job or task is in post-publishing phase StatePostPublishing State = "post_publishing" // StateReverting indicates a job or task is being reverted StateReverting State = "reverting" // StateFailedPostPublish indicates a job or task failed // during post-publishing StateFailedPostPublish State = "failed_post_publish" // StateFailedPublish indicates a job or task failed during publishing StateFailedPublish State = "failed_publish" // StateFailedMigration indicates a job or task failed during migration StateFailedMigration State = "failed_migration" // StateCancelled indicates a job or task has been cancelled StateCancelled State = "cancelled" )
func GetFailureStateForJobState ¶ added in v0.15.0
GetFailureStateForJobState returns the corresponding failure state for a given active job state.
func GetNonCancelledStates ¶ added in v0.7.0
func GetNonCancelledStates() []State
GetNonCancelledStates returns a slice of States excluding the 'cancelled' state.
type StaticDatasetValidator ¶ added in v0.7.0
type StaticDatasetValidator struct{}
StaticDatasetValidator implements JobValidator for static dataset migration jobs
func (*StaticDatasetValidator) ValidateSourceID ¶ added in v0.7.0
func (v *StaticDatasetValidator) ValidateSourceID(sourceID string) error
ValidateSourceID validates if the given source ID is a valid Zebedee URI
func (*StaticDatasetValidator) ValidateSourceIDWithExternal ¶ added in v0.7.0
func (v *StaticDatasetValidator) ValidateSourceIDWithExternal(ctx context.Context, sourceID string, appClients *clients.ClientList) (string, error)
ValidateSourceIDWithExternal validates if the given source ID exists in Zebedee and is of the correct type
func (*StaticDatasetValidator) ValidateTargetID ¶ added in v0.7.0
func (v *StaticDatasetValidator) ValidateTargetID(targetID string) error
ValidateTargetID validates if the given id is a valid dataset ID
func (*StaticDatasetValidator) ValidateTargetIDWithExternal ¶ added in v0.7.0
func (v *StaticDatasetValidator) ValidateTargetIDWithExternal(ctx context.Context, targetID string, appClients *clients.ClientList) error
ValidateTargetIDWithExternal validates that the target dataset ID does not already exist
type Task ¶ added in v0.11.0
type Task struct {
ID string `json:"id" bson:"_id"`
JobNumber int `json:"job_number" bson:"job_number"`
LastUpdated time.Time `json:"last_updated" bson:"last_updated"`
Source *TaskMetadata `json:"source" bson:"source"`
State State `json:"state" bson:"state"`
Target *TaskMetadata `json:"target" bson:"target"`
Type TaskType `json:"type" bson:"type"`
Links TaskLinks `json:"links" bson:"links"`
}
Task represents a migration task
type TaskLinks ¶ added in v0.11.0
type TaskLinks struct {
Self *LinkObject `bson:"self,omitempty" json:"self,omitempty"`
Job *LinkObject `bson:"job,omitempty" json:"job,omitempty"`
}
TaskLinks contains HATEOAS links for a migration task
func NewTaskLinks ¶ added in v0.11.0
NewTaskLinks creates TaskLinks for a task
type TaskMetadata ¶ added in v0.11.0
type TaskMetadata struct {
ID string `json:"id,omitempty" bson:"id,omitempty"`
DatasetID string `json:"dataset_id,omitempty" bson:"dataset_id,omitempty"`
EditionID string `json:"edition_id,omitempty" bson:"edition_id,omitempty"`
VersionID string `json:"version_id,omitempty" bson:"version_id,omitempty"`
Label string `json:"label,omitempty" bson:"label,omitempty"`
}
TaskMetadata represents metadata about a task's source or target
type TaskType ¶ added in v0.12.0
type TaskType string
TaskType represents the type of migration task
const ( // TaskTypeDatasetSeries indicates a dataset series task TaskTypeDatasetSeries TaskType = "dataset_series" // TaskTypeDatasetEdition indicates a dataset edition task TaskTypeDatasetEdition TaskType = "dataset_edition" // TaskTypeDatasetVersion indicates a dataset version task TaskTypeDatasetVersion TaskType = "dataset_version" // TaskTypeDatasetDownload indicates a dataset download task TaskTypeDatasetDownload TaskType = "dataset_download" )