codelist

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a codelist api client which can be used to make requests to the server

func New

func New(codelistAPIURL string) *Client

New creates a new instance of Client with a given filter api url

func NewWithHealthClient

func NewWithHealthClient(hcCli *healthcheck.Client) *Client

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

func (*Client) Checker

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

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

func (*Client) GetCodeByID

func (c *Client) GetCodeByID(ctx context.Context, userAuthToken string, serviceAuthToken string, codeListID string, edition string, codeID string) (CodeResult, error)

GetCodeByID returns information about a code

func (*Client) GetCodeListEditions

func (c *Client) GetCodeListEditions(ctx context.Context, userAuthToken string, serviceAuthToken string, codeListID string) (EditionsListResults, error)

GetCodeListEditions returns the editions for a codelist

func (*Client) GetCodes

func (c *Client) GetCodes(ctx context.Context, userAuthToken string, serviceAuthToken string, codeListID string, edition string) (CodesResults, error)

GetCodes returns the codes for a specific edition of a code list

func (*Client) GetDatasetsByCode

func (c *Client) GetDatasetsByCode(ctx context.Context, userAuthToken string, serviceAuthToken string, codeListID string, edition string, codeID string) (DatasetsResult, error)

GetDatasetsByCode returns datasets containing the codelist codeID.

func (*Client) GetGeographyCodeLists

func (c *Client) GetGeographyCodeLists(ctx context.Context, userAuthToken string, serviceAuthToken string) (CodeListResults, error)

GetGeographyCodeLists returns the geography codelists

func (*Client) GetIDNameMap

func (c *Client) GetIDNameMap(ctx context.Context, userAuthToken string, serviceAuthToken string, id string) (map[string]string, error)

GetIDNameMap returns dimension values in the form of an id name map

func (*Client) GetValues

func (c *Client) GetValues(ctx context.Context, userAuthToken string, serviceAuthToken string, id string) (DimensionValues, error)

GetValues returns dimension values from the codelist api

func (*Client) HealthClient

func (c *Client) HealthClient() *healthcheck.Client

HealthClient returns the underlying Healthcheck Client for this codelistAPI client

func (*Client) URL

func (c *Client) URL() string

URL returns the URL used by this client

type CodeLinks struct {
	CodeLists Link `json:"code_lists"`
	Datasets  Link `json:"datasets"`
	Self      Link `json:"self"`
}

CodeLinks represents the links an individual code item has

type CodeList

type CodeList struct {
	Links CodeListLinks `json:"links"`
}

CodeList containing links to all possible codes

type CodeListLinks struct {
	Self     *Link `json:"self"`
	Editions *Link `json:"editions"`
}

CodeListLinks contains links for a code list resource

type CodeListResults

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

CodeListResults contains an array of code lists which can be paginated

type CodeResult

type CodeResult struct {
	ID    string `json:"id"`
	Label string `json:"label"`
}

CodeResult represents a code list item

type CodesResults

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

CodesResults contains the list of codes for a specific code list and edition

type Dataset

type Dataset struct {
	Links          DatasetLinks     `json:"links"`
	DimensionLabal string           `json:"dimension_label"`
	Editions       []DatasetEdition `json:"editions"`
}

type DatasetEdition

type DatasetEdition struct {
	Links DatasetEditionLink `json:"links"`
}
type DatasetEditionLink struct {
	Self            Link `json:"self"`
	DatasetDimenion Link `json:"dataset_dimension"`
	LatestVersion   Link `json:"latest_version"`
}
type DatasetLinks struct {
	Self Link `json:"self"`
}

type DatasetsResult

type DatasetsResult struct {
	Datasets []Dataset `json:"items"`
	Count    int       `json:"total_count"`
}

type DimensionValues

type DimensionValues struct {
	Items           []Item `json:"items"`
	NumberOfResults int    `json:"number_of_results"`
}

DimensionValues represent the dimension values returned by the codelist api

type EditionsList

type EditionsList struct {
	Edition string           `json:"edition"`
	Label   string           `json:"label"`
	Links   EditionsListLink `json:"links"`
}

EditionsList containing links to all possible codes

type EditionsListLink struct {
	Self     *Link `json:"self"`
	Editions *Link `json:"editions"`
	Codes    *Link `json:"codes"`
}

EditionsListLink contains links for a code list resource

type EditionsListResults

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

EditionsListResults contains an array of code lists which can be paginated

type ErrInvalidCodelistAPIResponse

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

ErrInvalidCodelistAPIResponse is returned when the codelist api does not respond with a valid status

func (ErrInvalidCodelistAPIResponse) Code

Code returns the status code received from code list api if an error is returned

func (ErrInvalidCodelistAPIResponse) Error

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

type Item

type Item struct {
	Code  string    `json:"code"`
	Label string    `json:"label"`
	Links CodeLinks `json:"links"`
}

Item represents an individual code item returned by the codelist api

type Link struct {
	ID   string `json:"id,omitempty"     bson:"id"`
	Href string `json:"href"             bson:"href"`
}

Link contains the id and a link to a resource

Jump to

Keyboard shortcuts

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