zebedee

package
v2.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 18 Imported by: 40

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 within dataset landing page

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

Breadcrumb represents a breadcrumb from zebedee

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) 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) GetPageTitle

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

GetPageTitle retrieves a page title 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"`
	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"`
}

Description represents a description block within the dataset landing page

type Download

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

Download represents download within a dataset

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 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"`
}

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 NodeDescription

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

NodeDescription represents a node description

type PageTitle

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

PageTitle represents a page title from zebedee

type Related struct {
	Title string `json:"title"`
	URI   string `json:"uri"`
}

Related stores the Title and URI for any related data (eg related publications on a dataset page)

type Section

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

Section represents a section within dataset landing page

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 of a dataset

Jump to

Keyboard shortcuts

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