models

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateBundle added in v1.2.0

func ValidateBundle(bundle *Bundle) error

ValidateBundle checks that the Bundle has all mandatory fields and valid values

func ValidateContentItem added in v1.2.0

func ValidateContentItem(contentItem *ContentItem) error

func ValidateError added in v1.2.0

func ValidateError(e *Error) error

func ValidateEvent added in v1.2.0

func ValidateEvent(event *Event) error

ValidateEvent validates that an Event has all required fields and values

Types

type Action added in v1.2.0

type Action string

Action enum type representing the action taken by a user

const (
	ActionCreate Action = "CREATE"
	ActionRead   Action = "READ"
	ActionUpdate Action = "UPDATE"
	ActionDelete Action = "DELETE"
)

Define the possible values for the Action enum

func (Action) IsValid added in v1.2.0

func (a Action) IsValid() bool

IsValid validates that the Action is a valid enum value

func (Action) String added in v1.2.0

func (a Action) String() string

String returns the string value of the Action

type Bundle

type Bundle struct {
	ID            string         `bson:"_id"                       json:"id"`
	BundleType    BundleType     `bson:"bundle_type"               json:"bundle_type"`
	CreatedBy     *User          `bson:"created_by,omitempty"      json:"created_by,omitempty"`
	CreatedAt     *time.Time     `bson:"created_at,omitempty"      json:"created_at,omitempty"`
	LastUpdatedBy *User          `bson:"last_updated_by,omitempty" json:"last_updated_by,omitempty"`
	PreviewTeams  *[]PreviewTeam `bson:"preview_teams"             json:"preview_teams"`
	ScheduledAt   *time.Time     `bson:"scheduled_at,omitempty"    json:"scheduled_at,omitempty"`
	State         *BundleState   `bson:"state,omitempty"           json:"state,omitempty"`
	Title         string         `bson:"title"                     json:"title"`
	UpdatedAt     *time.Time     `bson:"updated_at,omitempty"      json:"updated_at,omitempty"`
	ManagedBy     ManagedBy      `bson:"managed_by"                json:"managed_by"`
}

Bundle represents the response body when retrieving a bundle

func CreateBundle

func CreateBundle(reader io.Reader) (*Bundle, error)

CreateBundle creates a new Bundle from the provided reader

type BundleContent

type BundleContent struct {
	DatasetID string `bson:"dataset_id" json:"dataset_id"`
	EditionID string `bson:"edition_id" json:"edition_id"`
	ItemID    string `bson:"item_id" json:"item_id"`
	State     string `bson:"state" json:"state"`
	Title     string `bson:"title" json:"title"`
	URLPath   string `bson:"url_path" json:"url_path"`
}

BundleContent represents the content of the bundle

type BundleState added in v1.2.0

type BundleState string

BundleState enum type representing the state of the bundle

const (
	BundleStateDraft     BundleState = "DRAFT"
	BundleStateInReview  BundleState = "IN_REVIEW"
	BundleStateApproved  BundleState = "APPROVED"
	BundleStatePublished BundleState = "PUBLISHED"
)

Define the possible values for the BundleState enum

func (BundleState) IsValid added in v1.2.0

func (bs BundleState) IsValid() bool

IsValid validates that the BundleState is a valid enum value

func (BundleState) String added in v1.2.0

func (bs BundleState) String() string

String returns the string value of the BundleState

type BundleType added in v1.2.0

type BundleType string

BundleType enum type representing the type of the bundle

const (
	BundleTypeManual    BundleType = "MANUAL"
	BundleTypeScheduled BundleType = "SCHEDULED"
)

Define the possible values for the BundleType enum

func (BundleType) IsValid added in v1.2.0

func (bt BundleType) IsValid() bool

IsValid validates that the BundleType is a valid enum value

type Bundles added in v1.2.0

type Bundles struct {
	Items *[]Bundle `bson:"items" json:"items"`
}

Bundles represents a list of bundles

type Code added in v1.2.0

type Code string

Code enum representing the error code

const (
	CodeInternalServerError Code = "internal_server_error"
	CodeNotFound            Code = "not_found"
	CodeBadRequest          Code = "bad_request"
	CodeUnauthorized        Code = "unauthorized"
	CodeForbidden           Code = "forbidden"
	CodeConflict            Code = "conflict"
	JSONMarshalError        Code = "JSONMarshalError"
	JSONUnmarshalError      Code = "JSONUnmarshalError"
	WriteResponseError      Code = "WriteResponseError"
)

Define possible values for the Code enum

func (Code) IsValid added in v1.2.0

func (c Code) IsValid() bool

IsValid validates that the Code is a valid enum value

func (Code) String added in v1.2.0

func (c Code) String() string

String returns the string value of the Code

type ContentItem added in v1.2.0

type ContentItem struct {
	ID          string      `bson:"_id,omitempty"   json:"id,omitempty"`
	BundleID    string      `bson:"bundle_id"       json:"bundle_id"`
	ContentType ContentType `bson:"content_type"    json:"content_type"`
	Metadata    Metadata    `bson:"metadata"        json:"metadata"`
	State       *State      `bson:"state,omitempty" json:"state,omitempty"`
	Links       Links       `bson:"links"           json:"links"`
}

ContentItem represents information about the datasets to be published as part of the bundle

func CreateContentItem added in v1.2.0

func CreateContentItem(reader io.Reader) (*ContentItem, error)

type ContentType added in v1.2.0

type ContentType string

ContentType enum represents the type of content

const (
	ContentTypeDataset ContentType = "DATASET"
)

Define the possible values for the contentType enum

func (ContentType) IsValid added in v1.2.0

func (ct ContentType) IsValid() bool

IsValid validates that the ContentType is a valid enum value

type Contents added in v1.2.0

type Contents struct {
	PaginationFields
	Items []ContentItem `bson:"contents,omitempty" json:"contents,omitempty"`
}

Contents represents a list of contents related to a bundle

type Error added in v1.2.0

type Error struct {
	Code        *Code   `bson:"code,omitempty"        json:"code,omitempty"`
	Description string  `bson:"description,omitempty" json:"description,omitempty"`
	Source      *Source `bson:"source,omitempty"      json:"source,omitempty"`
}

Error represents the details of a specific error

func CreateError added in v1.2.0

func CreateError(reader io.Reader) (*Error, error)

type ErrorList added in v1.2.0

type ErrorList struct {
	Errors *[]Error `bson:"errors,omitempty" json:"errors,omitempty"`
}

ErrorList represents a list of errors

type Event added in v1.2.0

type Event struct {
	CreatedAt   *time.Time   `bson:"created_at,omitempty"   json:"created_at,omitempty"`
	RequestedBy *RequestedBy `bson:"requested_by,omitempty" json:"requested_by,omitempty"`
	Action      Action       `bson:"action,"                json:"action"`
	Resource    string       `bson:"resource"               json:"resource"`
	ContentItem *ContentItem `bson:"content_item,omitempty" json:"content_item,omitempty"`
	Bundle      *Bundle      `bson:"bundle,omitempty"       json:"bundle,omitempty"`
}

Event represents details of a specific change event forming part of the change and audit log for a bundle

func CreateEvent added in v1.2.0

func CreateEvent(reader io.Reader) (*Event, error)

CreateEvent creates an Event from a JSON request body

type EventsList added in v1.2.0

type EventsList struct {
	PaginationFields
	Items *[]Event `bson:"items,omitempty" json:"items,omitempty"`
}

EventsList represents the list of change events which form the change and audit log for a bundle

type Links struct {
	Edit    string `bson:"edit"    json:"edit"`
	Preview string `bson:"preview" json:"preview"`
}

Links represents the navigational links for onward actions related to the content item

type ManagedBy added in v1.2.0

type ManagedBy string

ManagedBy enum type representing the system that created and manages the bundle

const (
	ManagedByWagtail   ManagedBy = "WAGTAIL"
	ManagedByDataAdmin ManagedBy = "DATA-ADMIN"
)

Define the possible values for the ManagedBy enum

func (ManagedBy) IsValid added in v1.2.0

func (mb ManagedBy) IsValid() bool

IsValid validates that the ManagedBy is a valid enum value

type Metadata added in v1.2.0

type Metadata struct {
	DatasetID string `bson:"dataset_id"      json:"dataset_id"`
	EditionID string `bson:"edition_id"      json:"edition_id"`
	Title     string `bson:"title,omitempty" json:"title,omitempty"`
	VersionID int    `bson:"version_id"      json:"version_id"`
}

Metadata represents the metadata for the content item

type PaginationFields added in v1.1.0

type PaginationFields struct {
	Count      int `json:"count"`
	Limit      int `json:"limit"`
	Offset     int `json:"offset"`
	TotalCount int `json:"total_count"`
}

PaginationFields represents the fields used for pagination in an API response

type PreviewTeam added in v1.2.0

type PreviewTeam struct {
	ID string `bson:"id" json:"id"`
}

PreviewTeam represents a team who have permissions to view the dataset series in the bundle

type RequestedBy added in v1.2.0

type RequestedBy struct {
	ID    string `bson:"id"              json:"id"`
	Email string `bson:"email,omitempty" json:"email,omitempty"`
}

RequestedBy represents the user who made the request

type Source added in v1.2.0

type Source struct {
	Field     string `bson:"field,omitempty"     json:"field,omitempty"`
	Parameter string `bson:"parameter,omitempty" json:"parameter,omitempty"`
	Header    string `bson:"header,omitempty"    json:"header,omitempty"`
}

Source represents the details of which field or parameter the error relates to. Used to return validation errors to 4xx requests. Only one of the properties below can be returned in any single error.

type State added in v1.2.0

type State string

State enum represents the state of the content item

const (
	StateApproved  State = "APPROVED"
	StatePublished State = "PUBLISHED"
)

Define the possible values for the state enum

func (State) IsValid added in v1.2.0

func (s State) IsValid() bool

IsValid validates that the State is a valid enum value

type User added in v1.2.0

type User struct {
	Email string `bson:"email" json:"email"`
}

User represents the user who created or updated the bundle

Jump to

Keyboard shortcuts

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