zebedee

package
v2.119.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: MIT Imports: 19 Imported by: 35

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Date     string `json:"date"`
	Markdown string `json:"markdown"`
	Type     string `json:"type"`
}

Alert represents an alert

type Breadcrumb struct {
	URI         string          `json:"uri"`
	Description NodeDescription `json:"description"`
	Type        string          `json:"type"`
}

Breadcrumb represents a breadcrumb from zebedee

type Bulletin added in v2.4.0

type Bulletin struct {
	RelatedBulletins []Link      `json:"relatedBulletins"`
	Sections         []Section   `json:"sections"`
	Accordion        []Section   `json:"accordion"`
	RelatedData      []Link      `json:"relatedData"`
	Charts           []Figure    `json:"charts"`
	Tables           []Figure    `json:"tables"`
	Images           []Figure    `json:"images"`
	Equations        []Figure    `json:"equations"`
	Links            []Link      `json:"links"`
	Type             string      `json:"type"`
	URI              string      `json:"uri"`
	Description      Description `json:"description"`
	Versions         []Version   `json:"versions"`
	Alerts           []Alert     `json:"alerts"`
	LatestReleaseURI string      `json:"latestReleaseUri"`
}

type Client

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

Client represents a zebedee client

func New

func New(zebedeeURL string) *Client

New creates a new Zebedee Client, set ZEBEDEE_REQUEST_TIMEOUT_SECOND environment variable to modify default client timeout as zebedee can often be slow to respond

func NewClientWithClienter

func NewClientWithClienter(zebedeeURL string, clienter dphttp.Clienter) *Client

NewWithSetTimeoutAndMaxRetry creates a new Zebedee Client, with a configurable timeout and maximum number of retries

func NewWithHealthClient

func NewWithHealthClient(hcCli *healthcheck.Client) *Client

NewWithHealthClient creates a new instance of Client, reusing the URL and Clienter from the provided health check client.

func (*Client) Checker

func (c *Client) Checker(ctx context.Context, check *health.CheckState) error

Checker calls zebedee health endpoint and returns a check object to the caller.

func (*Client) Get

func (c *Client) Get(ctx context.Context, userAccessToken, path string) ([]byte, error)

Get returns a response for the requested uri in zebedee

func (*Client) GetBreadcrumb

func (c *Client) GetBreadcrumb(ctx context.Context, userAccessToken, collectionID, lang, uri string) ([]Breadcrumb, error)

GetBreadcrumb returns a Breadcrumb

func (*Client) GetBulletin added in v2.4.0

func (c *Client) GetBulletin(ctx context.Context, userAccessToken, collectionID, lang, uri string) (Bulletin, error)

GetBulletin retrieves a bulletin from zebedee

func (*Client) GetCollection

func (c *Client) GetCollection(ctx context.Context, userAccessToken, collectionID string) (Collection, error)

func (*Client) GetDataset

func (c *Client) GetDataset(ctx context.Context, userAccessToken, collectionID, lang, uri string) (Dataset, error)

GetDataset returns details about a dataset from zebedee

func (*Client) GetDatasetLandingPage

func (c *Client) GetDatasetLandingPage(ctx context.Context, userAccessToken, collectionID, lang, path string) (DatasetLandingPage, error)

GetDatasetLandingPage returns a DatasetLandingPage populated with data from a zebedee response. If an error is returned there is a chance that a partly completed DatasetLandingPage is returned

func (*Client) GetFileSize

func (c *Client) GetFileSize(ctx context.Context, userAccessToken, collectionID, lang, uri string) (FileSize, error)

GetFileSize retrieves a given filesize from zebedee

func (*Client) GetHomepageContent

func (c *Client) GetHomepageContent(ctx context.Context, userAccessToken, collectionID, lang, path string) (HomepageContent, error)

func (*Client) GetPageDescription added in v2.9.7

func (c *Client) GetPageDescription(ctx context.Context, userAccessToken, collectionID, lang, uri string) (PageDescription, error)

GetPageDescription retrieves a page description from zebedee

func (*Client) GetPageTitle

func (c *Client) GetPageTitle(ctx context.Context, userAccessToken, collectionID, lang, uri string) (PageTitle, error)

GetPageTitle retrieves a page title from zebedee

func (*Client) GetPublishedData added in v2.2.0

func (c *Client) GetPublishedData(ctx context.Context, uriString string) ([]byte, error)

GetPublishedData returns []byte

func (*Client) GetPublishedIndex added in v2.5.0

func (c *Client) GetPublishedIndex(ctx context.Context, params *PublishedIndexRequestParams) (PublishedIndex, error)

GetPublishedIndex returns PublishedIndex

func (*Client) GetRelease added in v2.9.7

func (c *Client) GetRelease(ctx context.Context, userAccessToken, collectionID, lang, uri string) (Release, error)

GetRelease retrieves a release from zebedee

func (*Client) GetResourceBody

func (c *Client) GetResourceBody(ctx context.Context, userAccessToken, collectionID, lang, uri string) ([]byte, error)

GetResourceBody returns body of a resource e.g. JSON definition of a table

func (*Client) GetTimeseriesMainFigure

func (c *Client) GetTimeseriesMainFigure(ctx context.Context, userAccessToken, collectionID, lang, uri string) (TimeseriesMainFigure, error)

func (*Client) GetWithHeaders

func (c *Client) GetWithHeaders(ctx context.Context, userAccessToken, path string) ([]byte, http.Header, error)

GetWithHeaders returns a response for the requested uri in zebedee, providing the headers too

func (*Client) Put

func (c *Client) Put(ctx context.Context, userAccessToken, path string, payload []byte) (*http.Response, error)

Put updates a resource in zebedee

func (*Client) PutDatasetInCollection

func (c *Client) PutDatasetInCollection(ctx context.Context, userAccessToken, collectionID, lang, datasetID, state string) error

func (*Client) PutDatasetVersionInCollection

func (c *Client) PutDatasetVersionInCollection(ctx context.Context, userAccessToken, collectionID, lang, datasetID, edition, version, state string) error

type Collection

type Collection struct {
	ID              string           `json:"id"`
	Name            string           `json:"name"`
	Inprogress      []CollectionItem `json:"inProgress"`
	Complete        []CollectionItem `json:"complete"`
	Reviewed        []CollectionItem `json:"reviewed"`
	Datasets        []CollectionItem `json:"datasets"`
	DatasetVersions []CollectionItem `json:"datasetVersions"`
	ApprovalStatus  string           `json:"approvalStatus"`
	Type            string           `json:"type"`
}

type CollectionItem

type CollectionItem struct {
	ID           string `json:"id"`
	State        string `json:"state"`
	LastEditedBy string `json:"lastEditedBy"`
	Title        string `json:"title"`
	URI          string `json:"uri"`
	Edition      string `json:"edition,omitempty"`
	Version      string `json:"version,omitempty"`
}

type CollectionState

type CollectionState struct {
	State string `json:"state"`
}

type Contact

type Contact struct {
	Name      string `json:"name"`
	Email     string `json:"email"`
	Telephone string `json:"telephone"`
}

Contact represents a contact within dataset landing page

type Dataset

type Dataset struct {
	Type               string              `json:"type"`
	URI                string              `json:"uri"`
	Description        Description         `json:"description"`
	Downloads          []Download          `json:"downloads"`
	SupplementaryFiles []SupplementaryFile `json:"supplementaryFiles"`
	Versions           []Version           `json:"versions"`
}

Dataset represents a dataset response from zebedee

type DatasetLandingPage

type DatasetLandingPage struct {
	Type                      string      `json:"type"`
	URI                       string      `json:"uri"`
	Description               Description `json:"description"`
	Section                   Section     `json:"section"`
	Datasets                  []Related   `json:"datasets"`
	RelatedLinks              []Related   `json:"links"`
	RelatedFilterableDatasets []Related   `json:"relatedFilterableDatasets"`
	RelatedDatasets           []Related   `json:"relatedDatasets"`
	RelatedDocuments          []Related   `json:"relatedDocuments"`
	RelatedMethodology        []Related   `json:"relatedMethodology"`
	RelatedMethodologyArticle []Related   `json:"relatedMethodologyArticle"`
	Alerts                    []Alert     `json:"alerts"`
	Timeseries                bool        `json:"timeseries"`
}

DatasetLandingPage is the page model of the Zebedee response for a dataset landing page type

type Description

type Description struct {
	Title              string   `json:"title"`
	Edition            string   `json:"edition"`
	Summary            string   `json:"summary"`
	Keywords           []string `json:"keywords"`
	MetaDescription    string   `json:"metaDescription"`
	NationalStatistic  bool     `json:"nationalStatistic"`
	LatestRelease      bool     `json:"latestRelease"`
	Contact            Contact  `json:"contact"`
	ReleaseDate        string   `json:"releaseDate"`
	NextRelease        string   `json:"nextRelease"`
	DatasetID          string   `json:"datasetId"`
	Unit               string   `json:"unit"`
	PreUnit            string   `json:"preUnit"`
	Source             string   `json:"source"`
	VersionLabel       string   `json:"versionLabel"`
	Finalised          bool     `json:"finalised,omitempty"`
	Cancelled          bool     `json:"cancelled,omitempty"`
	CancellationNotice []string `json:"cancellationNotice,omitempty"`
	Published          bool     `json:"published,omitempty"`
	ProvisionalDate    string   `json:"provisionalDate,omitempty"`
}

Description represents a page description

type Download

type Download struct {
	File string `json:"file"`
	Size string
}

Download represents download within a dataset

type EmergencyBanner added in v2.4.9

type EmergencyBanner struct {
	Type        string `json:"type"`
	Title       string `json:"title"`
	Description string `json:"description"`
	URI         string `json:"uri"`
	LinkText    string `json:"linkText"`
}

type ErrInvalidZebedeeResponse

type ErrInvalidZebedeeResponse struct {
	ActualCode int
	URI        string
}

ErrInvalidZebedeeResponse is returned when zebedee does not respond with a valid status

func (ErrInvalidZebedeeResponse) Error

Error should be called by the user to print out the stringified version of the error

type Featured struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URI         string `json:"uri"`
	ImageID     string `json:"image"`
}

type Figure added in v2.4.0

type Figure struct {
	Title    string `json:"title"`
	Filename string `json:"filename"`
	Version  string `json:"version"`
	URI      string `json:"uri"`
}

Figure represents a figure (charts, tables)

type FileSize

type FileSize struct {
	Size int `json:"fileSize"`
}

FileSize represents a file size from zebedee

type HomepageContent

type HomepageContent struct {
	Intro           Intro               `json:"intro"`
	FeaturedContent []Featured          `json:"featuredContent"`
	AroundONS       []Featured          `json:"aroundONS"`
	ServiceMessage  string              `json:"serviceMessage"`
	URI             string              `json:"uri"`
	Type            string              `json:"type"`
	Description     HomepageDescription `json:"description"`
	EmergencyBanner EmergencyBanner     `json:"emergencyBanner"`
}

HomepageContent represents the page model of the Zebedee response for the ONS homepage

type HomepageDescription

type HomepageDescription struct {
	Title           string   `json:"title"`
	Summary         string   `json:"summary"`
	Keywords        []string `json:"keywords"`
	MetaDescription string   `json:"metaDescription"`
	Unit            string   `json:"unit"`
	PreUnit         string   `json:"preUnit"`
	Source          string   `json:"source"`
}

type Intro

type Intro struct {
	Title    string `json:"title"`
	Markdown string `json:"markdown"`
}
type Link struct {
	Title   string `json:"title"`
	Summary string `json:"summary,omitempty"`
	URI     string `json:"uri"`
}

Link represents any link on website

type NodeDescription

type NodeDescription struct {
	Title string `json:"title"`
}

NodeDescription represents a node description

type PageDescription added in v2.9.7

type PageDescription struct {
	URI         string      `json:"uri"`
	Description Description `json:"description"`
}

PageDescription represents the content returned by zebedee when requesting a page description

type PageTitle

type PageTitle struct {
	Title   string `json:"title"`
	Edition string `json:"edition"`
	URI     string `json:"uri"`
}

PageTitle represents a page title from zebedee

type PublishedIndex added in v2.5.0

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

PublishedIndex represents an index of published content

type PublishedIndexItem added in v2.5.0

type PublishedIndexItem struct {
	URI string `json:"uri"`
}

PublishedIndexItem represents an individual content item returned from the PublishedIndex endpoint

type PublishedIndexRequestParams added in v2.5.0

type PublishedIndexRequestParams struct {
	Limit  *int
	Offset int
}

PublishedIndexRequestParams represents request parameters for making paged PublishedIndex requests

type Related = Link

Related stores the Title and URI for any related data (e.g. related publications on a dataset page) Deprecated: use Link

type Release added in v2.9.7

type Release struct {
	Markdown                  []string            `json:"markdown"`
	RelatedDocuments          []Link              `json:"relatedDocuments"`
	RelatedDatasets           []Link              `json:"relatedDatasets"`
	RelatedMethodology        []Link              `json:"relatedMethodology"`
	RelatedMethodologyArticle []Link              `json:"relatedMethodologyArticle"`
	Links                     []Link              `json:"links"`
	DateChanges               []ReleaseDateChange `json:"dateChanges"`
	URI                       string              `json:"uri"`
	Description               Description         `json:"description"`
}

type ReleaseDateChange added in v2.9.7

type ReleaseDateChange struct {
	Date         string `json:"previousDate"`
	ChangeNotice string `json:"changeNotice"`
}

type Section

type Section struct {
	Title    string `json:"title"`
	Markdown string `json:"markdown"`
}

Section represents a markdown section

type SupplementaryFile

type SupplementaryFile struct {
	Title string `json:"title"`
	File  string `json:"file"`
	Size  string
}

SupplementaryFile represents a SupplementaryFile within a dataset

type TimeseriesDataPoint

type TimeseriesDataPoint struct {
	Value string `json:"value"`
	Label string `json:"label"`
}

type TimeseriesDescription

type TimeseriesDescription struct {
	CDID        string `json:"cdid"`
	Unit        string `json:"unit"`
	ReleaseDate string `json:"releaseDate"`
}

type TimeseriesMainFigure

type TimeseriesMainFigure struct {
	Description      TimeseriesDescription `json:"description"`
	Years            []TimeseriesDataPoint `json:"years"`
	Quarters         []TimeseriesDataPoint `json:"quarters"`
	Months           []TimeseriesDataPoint `json:"months"`
	RelatedDocuments []Related             `json:"relatedDocuments"`
	URI              string                `json:"uri"`
}

TimeseriesMainFigure represents timeseries data for main figure on the homepage

type Version

type Version struct {
	URI         string `json:"uri"`
	ReleaseDate string `json:"updateDate"`
	Notice      string `json:"correctionNotice"`
	Label       string `json:"label"`
}

Version represents a version

Jump to

Keyboard shortcuts

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