Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Checker(ctx context.Context, check *healthcheck.CheckState) error
- func (c *Client) CreateDataset(ctx context.Context, headers Headers, dataset models.Dataset) (models.DatasetUpdate, error)
- func (c *Client) DeleteDataset(ctx context.Context, headers Headers, datasetID string) error
- func (c *Client) GetDataset(ctx context.Context, headers Headers, datasetID string) (dataset models.Dataset, err error)
- func (c *Client) GetDatasetByPath(ctx context.Context, headers Headers, path string) (dataset models.Dataset, err error)
- func (c *Client) GetDatasetCurrentAndNext(ctx context.Context, headers Headers, datasetID string) (dataset models.DatasetUpdate, err error)
- func (c *Client) GetDatasetEditions(ctx context.Context, headers Headers, queryParams *QueryParams) (datasetEditionsList DatasetEditionsList, err error)
- func (c *Client) GetDatasets(ctx context.Context, headers Headers, q *QueryParams) (datasets DatasetsList, err error)
- func (c *Client) GetDatasetsInBatches(ctx context.Context, headers Headers, batchSize, maxWorkers int) (datasets DatasetsList, err error)
- func (c *Client) GetEdition(ctx context.Context, headers Headers, datasetID, editionID string) (edition models.Edition, err error)
- func (c *Client) GetEditions(ctx context.Context, headers Headers, datasetID string, ...) (editionList EditionsList, err error)
- func (c *Client) GetVersion(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (version models.Version, err error)
- func (c *Client) GetVersionDimensionOptions(ctx context.Context, headers Headers, ...) (versionDimensionOptionsList VersionDimensionOptionsList, err error)
- func (c *Client) GetVersionDimensions(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (versionDimensionsList VersionDimensionsList, err error)
- func (c *Client) GetVersionMetadata(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (metadata models.Metadata, err error)
- func (c *Client) GetVersionV2(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (version models.Version, err error)
- func (c *Client) GetVersionWithHeaders(ctx context.Context, headers Headers, datasetID, edition, version string) (v models.Version, h ResponseHeaders, err error)
- func (c *Client) GetVersionWithResponse(ctx context.Context, headers Headers, datasetID, edition, versionID string) (v models.Version, resp *http.Response, err error)
- func (c *Client) GetVersions(ctx context.Context, headers Headers, datasetID, editionID string, ...) (versionsList VersionsList, err error)
- func (c *Client) GetVersionsInBatches(ctx context.Context, headers Headers, datasetID, edition string, ...) (versions VersionsList, err error)
- func (c *Client) GetVersionsInBatchesWithQueryParams(ctx context.Context, headers Headers, datasetID, edition string, ...) (versions VersionsList, err error)
- func (c *Client) Health() *health.Client
- func (c *Client) PostVersion(ctx context.Context, headers Headers, datasetID, editionID, versionID string, ...) (createdVersion *models.Version, err error)
- func (c *Client) PutDataset(ctx context.Context, headers Headers, datasetID string, d models.Dataset) error
- func (c *Client) PutInstance(ctx context.Context, headers Headers, instanceID string, i UpdateInstance) (eTag string, err error)
- func (c *Client) PutMetadata(ctx context.Context, headers Headers, datasetID, edition, version string, ...) error
- func (c *Client) PutVersion(ctx context.Context, headers Headers, datasetID, editionID, versionID string, ...) (updatedVersion models.Version, err error)
- func (c *Client) PutVersionState(ctx context.Context, headers Headers, ...) (err error)
- func (c *Client) URL() string
- type Clienter
- type DatasetEditionsList
- type DatasetsBatchProcessor
- type DatasetsList
- type EditionsList
- type ErrInvalidDatasetAPIResponse
- type GenericBatchGetter
- type GenericBatchProcessor
- type Headers
- type QueryParams
- type ResponseHeaders
- type UpdateInstance
- type VersionDimensionOptionsList
- type VersionDimensionsList
- type VersionsBatchProcessor
- type VersionsList
Constants ¶
This section is empty.
Variables ¶
var ( // ErrHeaderNotFound returned if the requested header is not present in the provided request ErrHeaderNotFound = errors.New("header not found") // ErrResponseNil return if GetResponseX header function is called with a nil response ErrResponseNil = errors.New("error getting request header, response was nil") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewWithHealthClient ¶
NewWithHealthClient creates a new instance of service API Client, reusing the URL and Clienter from the provided healthcheck client
func (*Client) Checker ¶
func (c *Client) Checker(ctx context.Context, check *healthcheck.CheckState) error
Checker calls the health.Client's Checker method
func (*Client) CreateDataset ¶
func (c *Client) CreateDataset(ctx context.Context, headers Headers, dataset models.Dataset) (models.DatasetUpdate, error)
CreateDataset creates a new dataset by posting to the POST /datasets endpoint
func (*Client) DeleteDataset ¶
DeleteDataset deletes a dataset by ID
func (*Client) GetDataset ¶
func (c *Client) GetDataset(ctx context.Context, headers Headers, datasetID string) (dataset models.Dataset, err error)
Get returns dataset level information for a given dataset id
func (*Client) GetDatasetByPath ¶
func (c *Client) GetDatasetByPath(ctx context.Context, headers Headers, path string) (dataset models.Dataset, err error)
GetDatasetByPath returns dataset level information for a given dataset path
func (*Client) GetDatasetCurrentAndNext ¶
func (c *Client) GetDatasetCurrentAndNext(ctx context.Context, headers Headers, datasetID string) (dataset models.DatasetUpdate, err error)
GetDatasetCurrentAndNext returns dataset level information but contains both next and current documents
func (*Client) GetDatasetEditions ¶
func (c *Client) GetDatasetEditions(ctx context.Context, headers Headers, queryParams *QueryParams) (datasetEditionsList DatasetEditionsList, err error)
GetDatasetEditions returns a list of dataset series that have unpublished versions or match the given state
func (*Client) GetDatasets ¶
func (c *Client) GetDatasets(ctx context.Context, headers Headers, q *QueryParams) (datasets DatasetsList, err error)
GetDatasets returns the list of datasets
func (*Client) GetDatasetsInBatches ¶
func (c *Client) GetDatasetsInBatches(ctx context.Context, headers Headers, batchSize, maxWorkers int) (datasets DatasetsList, err error)
GetDatasetsInBatches retrieves a list of datasets in concurrent batches and accumulates the results
func (*Client) GetEdition ¶
func (c *Client) GetEdition(ctx context.Context, headers Headers, datasetID, editionID string) (edition models.Edition, err error)
GetEdition retrieves a single edition document from a given datasetID and edition label
func (*Client) GetEditions ¶
func (c *Client) GetEditions(ctx context.Context, headers Headers, datasetID string, queryParams *QueryParams) (editionList EditionsList, err error)
GetEditions returns a paginated list of editions for a dataset
func (*Client) GetVersion ¶
func (c *Client) GetVersion(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (version models.Version, err error)
GetVersion retrieves a specific version for an edition of a dataset
func (*Client) GetVersionDimensionOptions ¶
func (c *Client) GetVersionDimensionOptions(ctx context.Context, headers Headers, datasetID, editionID, versionID, dimensionID string, queryParams *QueryParams) (versionDimensionOptionsList VersionDimensionOptionsList, err error)
Returns the options for a dimension
func (*Client) GetVersionDimensions ¶
func (c *Client) GetVersionDimensions(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (versionDimensionsList VersionDimensionsList, err error)
GetVersionDimensions will return a list of dimensions for a given version of a dataset
func (*Client) GetVersionMetadata ¶
func (c *Client) GetVersionMetadata(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (metadata models.Metadata, err error)
GetVersionMetadata returns the metadata for a given dataset id, edition and version
func (*Client) GetVersionV2 ¶
func (c *Client) GetVersionV2(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (version models.Version, err error)
GetVersionV2 does the same as GetVersion but uses unmarshalResponseBodyExpectingErrorResponseV2
func (*Client) GetVersionWithHeaders ¶
func (c *Client) GetVersionWithHeaders(ctx context.Context, headers Headers, datasetID, edition, version string) (v models.Version, h ResponseHeaders, err error)
GetVersionWithHeaders gets a specific version for an edition from the dataset api and additional response headers
func (*Client) GetVersionWithResponse ¶
func (c *Client) GetVersionWithResponse(ctx context.Context, headers Headers, datasetID, edition, versionID string) (v models.Version, resp *http.Response, err error)
Returns the full response so the etag in the header can be processed and returned
func (*Client) GetVersions ¶
func (c *Client) GetVersions(ctx context.Context, headers Headers, datasetID, editionID string, queryParams *QueryParams) (versionsList VersionsList, err error)
GetVersions returns a paginated list of versions for an edition
func (*Client) GetVersionsInBatches ¶
func (c *Client) GetVersionsInBatches(ctx context.Context, headers Headers, datasetID, edition string, batchSize, maxWorkers int) (versions VersionsList, err error)
GetVersionsInBatches retrieves a list of versions in concurrent batches and accumulates the results
func (*Client) GetVersionsInBatchesWithQueryParams ¶
func (c *Client) GetVersionsInBatchesWithQueryParams(ctx context.Context, headers Headers, datasetID, edition string, reqLimit, reqOffset, batchSize, maxWorkers int) (versions VersionsList, err error)
GetVersionsInBatches retrieves a list of versions in concurrent batches and accumulates the results
func (*Client) PostVersion ¶
func (c *Client) PostVersion(ctx context.Context, headers Headers, datasetID, editionID, versionID string, version models.Version, isLatest bool) (createdVersion *models.Version, err error)
PostVersion creates a specific version for a dataset series
func (*Client) PutDataset ¶
func (c *Client) PutDataset(ctx context.Context, headers Headers, datasetID string, d models.Dataset) error
PutDataset update the dataset
func (*Client) PutInstance ¶
func (c *Client) PutInstance(ctx context.Context, headers Headers, instanceID string, i UpdateInstance) (eTag string, err error)
PutInstance updates an instance
func (*Client) PutMetadata ¶
func (c *Client) PutMetadata(ctx context.Context, headers Headers, datasetID, edition, version string, metadata models.EditableMetadata) error
PutMetadata updates the dataset and the version metadata
func (*Client) PutVersion ¶
func (c *Client) PutVersion(ctx context.Context, headers Headers, datasetID, editionID, versionID string, version models.Version) (updatedVersion models.Version, err error)
PutVersion updates a specific version for a dataset series
type Clienter ¶
type Clienter interface {
Checker(ctx context.Context, check *healthcheck.CheckState) error
Health() *health.Client
URL() string
CreateDataset(ctx context.Context, headers Headers, dataset models.Dataset) (datasetUpdate models.DatasetUpdate, err error)
DeleteDataset(ctx context.Context, headers Headers, datasetID string) error
GetDataset(ctx context.Context, headers Headers, datasetID string) (dataset models.Dataset, err error)
GetDatasetByPath(ctx context.Context, headers Headers, path string) (dataset models.Dataset, err error)
GetDatasetCurrentAndNext(ctx context.Context, headers Headers, datasetID string) (dataset models.DatasetUpdate, err error)
GetDatasetEditions(ctx context.Context, headers Headers, queryParams *QueryParams) (datasetEditionsList DatasetEditionsList, err error)
GetDatasets(ctx context.Context, headers Headers, q *QueryParams) (datasets DatasetsList, err error)
GetDatasetsInBatches(ctx context.Context, headers Headers, batchSize, maxWorkers int) (datasets DatasetsList, err error)
GetEdition(ctx context.Context, headers Headers, datasetID, editionID string) (edition models.Edition, err error)
GetEditions(ctx context.Context, headers Headers, datasetID string, queryParams *QueryParams) (editionList EditionsList, err error)
GetVersion(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (version models.Version, err error)
GetVersionDimensions(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (versionDimensionsList VersionDimensionsList, err error)
GetVersionDimensionOptions(ctx context.Context, headers Headers, datasetID, editionID, versionID, dimensionID string, queryParams *QueryParams) (versionDimensionOptionsList VersionDimensionOptionsList, err error)
GetVersionMetadata(ctx context.Context, headers Headers, datasetID, editionID, versionID string) (metadata models.Metadata, err error)
GetVersionWithHeaders(ctx context.Context, headers Headers, datasetID, edition, version string) (v models.Version, h ResponseHeaders, err error)
GetVersionWithResponse(ctx context.Context, headers Headers, datasetID, edition, versionID string) (v models.Version, resp *http.Response, err error)
GetVersions(ctx context.Context, headers Headers, datasetID, editionID string, queryParams *QueryParams) (versionsList VersionsList, err error)
GetVersionsInBatches(ctx context.Context, headers Headers, datasetID, edition string, batchSize, maxWorkers int) (versions VersionsList, err error)
PostVersion(ctx context.Context, headers Headers, datasetID, editionID, versionID string, version models.Version, isLatest bool) (createdVersion *models.Version, err error)
PutDataset(ctx context.Context, headers Headers, datasetID string, d models.Dataset) error
PutInstance(ctx context.Context, headers Headers, instanceID string, i UpdateInstance) (eTag string, err error)
PutMetadata(ctx context.Context, headers Headers, datasetID, edition, version string, metadata models.EditableMetadata) error
PutVersion(ctx context.Context, headers Headers, datasetID, editionID, versionID string, version models.Version) (updatedVersion models.Version, err error)
PutVersionState(ctx context.Context, headers Headers, datasetID, editionID, versionID, state string) (err error)
}
type DatasetEditionsList ¶
type DatasetEditionsList struct {
Items []models.DatasetEdition `json:"items"`
Count int `json:"count"`
Offset int `json:"offset"`
Limit int `json:"limit"`
TotalCount int `json:"total_count"`
}
DatasetEditionsList represents an object containing a list of paginated dataset editions. This struct is based on the `pagination.page` struct which is returned when we call the `api.getDatasetEditions` endpoint
type DatasetsBatchProcessor ¶
type DatasetsBatchProcessor func(DatasetsList) (abort bool, err error)
DatasetsBatchProcessor is the type corresponding to a batch processing function for a dataset List.
type DatasetsList ¶
type DatasetsList struct {
Items []models.DatasetUpdate `json:"items"`
Count int `json:"count"`
Offset int `json:"offset"`
Limit int `json:"limit"`
TotalCount int `json:"total_count"`
}
List represents an object containing a list of datasets
type EditionsList ¶
type EditionsList struct {
Items []models.Edition `json:"items"`
Count int `json:"count"`
Offset int `json:"offset"`
Limit int `json:"limit"`
TotalCount int `json:"total_count"`
}
EditionList represents an object containing a list of paginated versions. This struct is based on the `pagination.page` struct which is returned when we call the `api.getEditions` endpoint
type ErrInvalidDatasetAPIResponse ¶
type ErrInvalidDatasetAPIResponse struct {
// contains filtered or unexported fields
}
ErrInvalidDatasetAPIResponse is returned when the dataset api does not respond with a valid status
func (ErrInvalidDatasetAPIResponse) Code ¶
func (e ErrInvalidDatasetAPIResponse) Code() int
Code returns the status code received from dataset api if an error is returned
func (ErrInvalidDatasetAPIResponse) Error ¶
func (e ErrInvalidDatasetAPIResponse) Error() string
Error should be called by the user to print out the stringified version of the error
type GenericBatchGetter ¶
type GenericBatchGetter func(offset int) (batch interface{}, totalCount int, eTag string, err error)
GenericBatchGetter defines the method signature for a batch getter to obtain a batch of some generic resource
type GenericBatchProcessor ¶
GenericBatchProcessor defines the method signature for a batch processor to process a batch of some generic resource
type Headers ¶
type Headers struct {
CollectionID string
DownloadServiceToken string `json:"-"`
AccessToken string `json:"-"` // could be user or service token for auth v2
IfMatch string
}
Contains the headers to be added to any request
type QueryParams ¶
QueryParams represents the possible query parameters that a caller can provide
func (*QueryParams) Validate ¶
func (q *QueryParams) Validate() error
Validate validates tht no negative values are provided for limit or offset, and that the length of IDs is lower than the maximum
type ResponseHeaders ¶
type ResponseHeaders struct {
ETag string
}
ResponseHeaders represents headers that are available in the HTTP response
type UpdateInstance ¶
type UpdateInstance struct {
Alerts *[]models.Alert `json:"alerts"`
CollectionID string `json:"collection_id"`
Downloads models.DownloadList `json:"downloads"`
Edition string `json:"edition"`
Dimensions []models.Dimension `json:"dimensions"`
ID string `json:"id"`
InstanceID string `json:"instance_id"`
LatestChanges []models.LatestChange `json:"latest_changes"`
ReleaseDate string `json:"release_date"`
State string `json:"state"`
Temporal []models.TemporalFrequency `json:"temporal"`
Version int `json:"version"`
NumberOfObservations int64 `json:"total_observations,omitempty"`
ImportTasks *models.InstanceImportTasks `json:"import_tasks,omitempty"`
CSVHeader []string `json:"headers,omitempty"`
Type string `json:"type,omitempty"`
IsBasedOn *models.IsBasedOn `json:"is_based_on,omitempty"`
}
type VersionDimensionOptionsList ¶
type VersionDimensionOptionsList struct {
Items []models.PublicDimensionOption
}
VersionDimensionOptionsList represent a list of PublicDimensionOption
func (VersionDimensionOptionsList) ToString ¶
func (m VersionDimensionOptionsList) ToString() string
type VersionDimensionsList ¶
VersionDimensionsList represent a list of Dimension
type VersionsBatchProcessor ¶
type VersionsBatchProcessor func(VersionsList) (abort bool, err error)
VersionsBatchProcessor is the type corresponding to a batch processing function for a dataset List.
type VersionsList ¶
type VersionsList struct {
Items []models.Version `json:"items"`
Count int `json:"count"`
Offset int `json:"offset"`
Limit int `json:"limit"`
TotalCount int `json:"total_count"`
}
VersionsList represents an object containing a list of paginated versions. This struct is based on the `pagination.page` struct which is returned when we call the `api.getVersions` endpoint