cantabular

package
v2.260.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 23 Imported by: 27

Documentation

Index

Constants

View Source
const (
	Service         = "cantabular"
	ServiceAPIExt   = "cantabularAPIExt"
	ServiceMetadata = "cantabularMetadataService"
	SoftwareVersion = "v10"
)

Cantabular service names

View Source
const QueryAggregatedDimensionOptions = `` /* 265-byte string literal not displayed */

QueryAggregatedDimensionOptions is the graphQL query to obtain static dataset dimension options for aggregated population types

View Source
const QueryAllDimensions = `` /* 267-byte string literal not displayed */

QueryAllDimensions is the graphQL query to obtain all dimensions (variables without categories)

View Source
const QueryArea = `` /* 302-byte string literal not displayed */

QueryArea is the graphQL query to search for an area which exactly match a specific string.

View Source
const QueryAreas = `` /* 390-byte string literal not displayed */

QueryAreas is the graphQL query to search for areas and area types which match a specific string. This can be used to retrieve a list of all the areas for a given area type, or to search for specific area within all area types.

View Source
const QueryAreasWithoutPagination = `` /* 332-byte string literal not displayed */

QueryAreasWithoutPagination is the graphQL query to search for areas and area types which match a specific string.

View Source
const QueryBaseVariable = `` /* 248-byte string literal not displayed */
View Source
const QueryBlockedAreaCount = `` /* 261-byte string literal not displayed */
View Source
const QueryBlockedAreaCountWithFilters = `` /* 304-byte string literal not displayed */
View Source
const QueryCategorisations = `` /* 1002-byte string literal not displayed */
View Source
const QueryCategorisationsCounts = `` /* 323-byte string literal not displayed */
View Source
const QueryDimensionCategories = `` /* 273-byte string literal not displayed */
View Source
const QueryDimensionOptions = `` /* 248-byte string literal not displayed */

QueryDimensionOptions is the graphQL query to obtain static dataset dimension options (variables with categories)

View Source
const QueryDimensions = `` /* 432-byte string literal not displayed */

QueryDimensions is the graphQL query to obtain all non-geography base dimensions (variables without categories)

View Source
const QueryDimensionsByName = `` /* 433-byte string literal not displayed */

QueryDimensionsByName is the graphQL query to obtain dimensions by name (subset of variables, without categories)

View Source
const QueryDimensionsDescription = `` /* 248-byte string literal not displayed */
View Source
const QueryDimensionsSearch = `` /* 303-byte string literal not displayed */
View Source
const QueryGeographyDimensions = `` /* 469-byte string literal not displayed */

QueryGeographyDimensions is the graphQL query to obtain geography dimensions (subset of variables, without categories)

View Source
const QueryListDatasets = `
query {
	datasets {
		name
		description
		label
		type
	}
}`
View Source
const QueryNonGeoDimensionsByName = `` /* 446-byte string literal not displayed */

QueryNonGeoDimensionsByName is the graphQL query to obtain dimensions by name (subset of variables, without categories) but excluding geography dimensions

View Source
const QueryParentAreaCount = `` /* 238-byte string literal not displayed */
View Source
const QueryParents = `` /* 429-byte string literal not displayed */
View Source
const QueryStaticDataset = `` /* 381-byte string literal not displayed */

QueryStaticDataset is the graphQL query to obtain static dataset counts (variables with categories and counts)

View Source
const QueryStaticDatasetType = `
query($dataset: String!){
	dataset(name: $dataset) {
	  type
	}
}`

Query static dataset type

View Source
const QueryValues = `` /* 179-byte string literal not displayed */

Variables

This section is empty.

Functions

func GraphQLJSONToCSV added in v2.4.0

func GraphQLJSONToCSV(ctx context.Context, r io.Reader, w io.Writer) (int32, error)

GraphQLJSONToCSV converts a JSON response in r to CSV on w, returning the row count if an error happens, the process is aborted and the error is returned.

Types

type Categories added in v2.223.0

type Categories struct {
	Code  string `json:"code,omitempty"`
	Label string `json:"label,omitempty"`
}

type Category

type Category struct {
	Code  string `json:"code"`
	Label string `json:"label"`
}

Category represents the 'category' field from the GraphQL query dataset response

type Client

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

Client is the client for interacting with the Cantabular API

func NewClient

func NewClient(cfg Config, ua httpClient, g GraphQLClient) *Client

NewClient returns a new Client

func (*Client) CheckQueryCount added in v2.256.0

func (c *Client) CheckQueryCount(ctx context.Context, req StaticDatasetQueryRequest) (int, error)

Checks the number of observations returned from a cantabular query

func (*Client) Checker

func (c *Client) Checker(ctx context.Context, state *healthcheck.CheckState) error

Checker contacts the /vXX/datasets endpoint and updates the healthcheck state accordingly.

func (*Client) CheckerAPIExt added in v2.4.0

func (c *Client) CheckerAPIExt(ctx context.Context, state *healthcheck.CheckState) error

CheckerAPIExt contacts the /graphql endpoint with an empty query and updates the healthcheck state accordingly.

func (*Client) CheckerMetadataService added in v2.196.0

func (c *Client) CheckerMetadataService(ctx context.Context, state *healthcheck.CheckState) error

CheckerMetadataService contacts the /graphql endpoint and updates the healthcheck state accordingly.

func (*Client) GetAggregatedDimensionOptions added in v2.168.0

GetAggregatedDimensionOptions performs an alternative graphQL query to obtain the requested dimension options, specifically for aggregated population type static datasets

func (*Client) GetAllDimensions added in v2.163.0

func (c *Client) GetAllDimensions(ctx context.Context, dataset string) (*GetDimensionsResponse, error)

GetAllDimensions performs a graphQL query to obtain all the dimensions for the provided cantabular dataset. The whole response is loaded to memory.

func (*Client) GetArea added in v2.175.0

func (c *Client) GetArea(ctx context.Context, req GetAreaRequest) (*GetAreaResponse, error)

GetArea performs a graphQL query to retrieve the exact area (category) for a given area type

func (*Client) GetAreas added in v2.96.11

func (c *Client) GetAreas(ctx context.Context, req GetAreasRequest) (*GetAreasResponse, error)

GetAreas performs a graphQL query to retrieve the areas (categories) for a given area type. If the category is left empty, then all categories are returned. Results can also be filtered by area by passing a variable name.

func (*Client) GetAreasTotalCount added in v2.198.0

func (c *Client) GetAreasTotalCount(ctx context.Context, req GetAreasRequest) (int, error)

func (*Client) GetBaseVariable added in v2.184.0

func (c *Client) GetBaseVariable(ctx context.Context, req GetBaseVariableRequest) (*GetBaseVariableResponse, error)

(c *Client) GetBaseVariable gets a base variable for a provided catergorisation

func (*Client) GetBlockedAreaCount added in v2.223.0

func (c *Client) GetBlockedAreaCount(ctx context.Context, req GetBlockedAreaCountRequest) (*GetBlockedAreaCountResult, error)

func (*Client) GetCategorisations added in v2.173.0

GetCategorisations returns a list of variables that map to the provided variable

func (*Client) GetCategorisationsCounts added in v2.239.0

GetCategorisationsCounts returns a count of of variables that map to the provided variables

func (*Client) GetCodebook

func (c *Client) GetCodebook(ctx context.Context, req GetCodebookRequest) (*GetCodebookResponse, error)

GetCodebook gets a Codebook from cantabular.

func (*Client) GetDimensionCategories added in v2.217.0

func (*Client) GetDimensionOptions added in v2.7.1

GetDimensionOptions performs a graphQL query to obtain the requested dimension options. It returns a Table with a list of Cantabular dimensions, where 'Variable' is the dimension and 'Categories' are the options The whole response is loaded to memory.

func (*Client) GetDimensions added in v2.7.1

func (c *Client) GetDimensions(ctx context.Context, req GetDimensionsRequest) (*GetDimensionsResponse, error)

GetDimensions performs a graphQL query to obtain all the non-geography dimensions for the provided cantabular dataset. The whole response is loaded to memory.

func (*Client) GetDimensionsByName added in v2.7.1

func (c *Client) GetDimensionsByName(ctx context.Context, req GetDimensionsByNameRequest) (*GetDimensionsResponse, error)

GetDimensionsByName performs a graphQL query to obtain only the dimensions that match the provided dimension names for the provided cantabular dataset. The whole response is loaded to memory.

func (*Client) GetDimensionsDescription added in v2.216.0

func (c *Client) GetDimensionsDescription(ctx context.Context, req GetDimensionsDescriptionRequest) (*GetDimensionsResponse, error)

GetDimensionsDescription performs a graphQL query to get the description of the passed dimensions

func (*Client) GetGeographyBatchProcess added in v2.163.0

func (c *Client) GetGeographyBatchProcess(ctx context.Context, datasetID string, processBatch GetGeographyBatchProcessor, batchSize, maxWorkers int) error

GetGeographyBatchProcess gets the geography dimensions from the API in batches, calling the provided function for each batch.

func (*Client) GetGeographyDimensions added in v2.8.1

GetGeographyDimensions performs a graphQL query to obtain the geography dimensions for the provided cantabular dataset. The whole response is loaded to memory.

func (*Client) GetGeographyDimensionsInBatches added in v2.163.0

func (c *Client) GetGeographyDimensionsInBatches(ctx context.Context, datasetID string, batchSize, maxWorkers int) (*gql.Dataset, error)

GetGeographyDimensionsInBatches performs a graphQL query to obtain all the geography dimensions for the provided cantabular dataset. The whole response is loaded to memory.

func (*Client) GetParentAreaCount added in v2.170.0

func (c *Client) GetParentAreaCount(ctx context.Context, req GetParentAreaCountRequest) (*GetParentAreaCountResult, error)

GetParentAreaCount returns the count of the areas for the parent of the provided variable with applied filter. Also returns the list of categories itself.

func (*Client) GetParents added in v2.148.0

func (c *Client) GetParents(ctx context.Context, req GetParentsRequest) (*GetParentsResponse, error)

GetParents returns a list of variables that map to the provided variable

func (*Client) ListDatasets added in v2.9.0

func (c *Client) ListDatasets(ctx context.Context) (*ListDatasetsResponse, error)

func (*Client) MetadataDatasetQuery added in v2.190.0

func (c *Client) MetadataDatasetQuery(ctx context.Context, req MetadataDatasetQueryRequest) (*MetadataDatasetQuery, error)

MetadataDatasetQuery takes cantabular dataset id, language and variables (dimensions) params and returns a struct representing the metadata server response for a dataset query

func (*Client) MetadataTableQuery added in v2.190.0

func (c *Client) MetadataTableQuery(ctx context.Context, req MetadataTableQueryRequest) (*MetadataTableQuery, error)

MetadataTableQuery takes variables (typically a ONS dataset id) and language params and returns a struct representing the metadata server response for a table query which typically contain variables (dimensions) and Cantabular dataset id

func (*Client) SearchDimensions added in v2.9.3

func (c *Client) SearchDimensions(ctx context.Context, req SearchDimensionsRequest) (*GetDimensionsResponse, error)

SearchDimensionsRequest performs a graphQL query to obtain the dimensions that match the provided text in the provided cantabular dataset. The whole response is loaded to memory.

func (*Client) StaticDatasetQuery

func (c *Client) StaticDatasetQuery(ctx context.Context, req StaticDatasetQueryRequest) (*StaticDatasetQuery, error)

StaticDatasetQuery performs a query for a static dataset against the Cantabular Extended API using the /graphql endpoint and returns a StaticDatasetQuery, loading the whole response to memory. Use this method only if large query responses are NOT expected

func (*Client) StaticDatasetQueryStreamCSV added in v2.4.0

func (c *Client) StaticDatasetQueryStreamCSV(ctx context.Context, req StaticDatasetQueryRequest, consume Consumer) (int32, error)

StaticDatasetQueryStreamCSV performs a StaticDatasetQuery call and then starts 2 go-routines to transform the response body into a CSV stream and consume the transformed output with the provided Consumer concurrently. The number of CSV rows, including the header, is returned along with any error during the process. Use this method if large query responses are expected.

func (*Client) StaticDatasetQueryStreamJson added in v2.256.0

func (c *Client) StaticDatasetQueryStreamJson(ctx context.Context, req StaticDatasetQueryRequest, consume Consumer) (GetObservationsResponse, error)

StaticDatasetQueryStreamJson performs a StaticDatasetQuery call and then starts 2 go-routines to transform the response body into a Json stream and consume the transformed output with the provided Consumer concurrently. Returns a json formatted response Use this method if large query responses are expected.

func (*Client) StaticDatasetType added in v2.243.0

func (c *Client) StaticDatasetType(ctx context.Context, datasetName string) (*gql.Dataset, error)

StaticDatasetType will return the type of dataset

func (*Client) StatusCode added in v2.9.5

func (c *Client) StatusCode(err error) int

StatusCode provides a callback function whereby users can check a returned error for an embedded HTTP status code

type Codebook

type Codebook []Variable

Codebook represents a 'codebook' object returned from Cantabular Server

type Config

type Config struct {
	Host           string
	ExtApiHost     string
	GraphQLTimeout time.Duration
}

Config holds the config used to initialise the Cantabular Client

type Consumer added in v2.4.0

type Consumer = stream.Consumer

Consumer is a stream func to read from a reader

type Dataset

type Dataset struct {
	Name             string    `json:"name"`
	Digest           string    `json:"digest"`
	Description      string    `json:"description"`
	Size             int       `json:"size"`
	RulebaseVariable string    `json:"ruleBaseVariable"`
	DateTime         time.Time `json:"datetime"`
}

Dataset represents a 'dataset' object returned from Cantabular Server

type DatasetJSONLinks struct {
	Self Link `json:"self"`
}

type Dimension

type Dimension struct {
	Count      int          `json:"count"`
	Categories []Category   `json:"categories"`
	Variable   VariableBase `json:"variable"`
}

Dimension represents the 'dimension' field from a GraphQL query dataset response

type Dimensions added in v2.4.0

type Dimensions []Dimension

Dimensions describes the structure of a table

func (Dimensions) NewIterator added in v2.4.0

func (dims Dimensions) NewIterator(ctx context.Context) *Iterator

NewIterator creates an iterator over a table on these Dimensions

type DimensionsTable added in v2.7.1

type DimensionsTable struct {
	Dimensions []Dimension `json:"dimensions"`
	Error      string      `json:"error,omitempty" `
}

DimensionsTable represents the 'table' field from the GraphQL dataset response, which contains only dimensions and error fields

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

ErrorResponse models the error response from cantabular

type Filter added in v2.9.6

type Filter struct {
	Codes    []string `json:"codes"`
	Variable string   `json:"variable"`
}

Filter holds the fields for the Cantabular GraphQL 'Filter' object used for specifying categories returned in tables

type GetAggregatedDimensionOptionsRequest added in v2.168.0

type GetAggregatedDimensionOptionsRequest struct {
	Dataset        string
	DimensionNames []string
}

GetAggregatedDimensionOptionsRequest holds the required inputs for the GetAggregatedDimensionOptions query

type GetAggregatedDimensionOptionsResponse added in v2.168.0

type GetAggregatedDimensionOptionsResponse struct {
	Dataset gql.Dataset `json:"dataset"`
}

GetAggregatedDimensionOptionsResponse holds the response body for the GetAggregatedDimensionOptions query

type GetAreaRequest added in v2.175.0

type GetAreaRequest struct {
	Dataset  string
	Variable string
	Category string
}

GetAreaRequest holds the request required for the POST [cantabular-ext]/graphql QueryArea query

type GetAreaResponse added in v2.175.0

type GetAreaResponse struct {
	Dataset gql.Dataset `json:"dataset"`
}

GetAreaResponse holds the response body for POST [cantabular-ext]/graphql

type GetAreasRequest added in v2.96.11

type GetAreasRequest struct {
	PaginationParams
	Dataset  string
	Variable string
	Category string
}

GetAreasRequest holds the request variables required for the POST [cantabular-ext]/graphql QueryAreas query.

type GetAreasResponse added in v2.96.11

type GetAreasResponse struct {
	PaginationResponse
	Dataset gql.Dataset `json:"dataset"`
}

GetAreasResponse holds the response body for POST [cantabular-ext]/graphql with a query to obtain static dataset variables and categories, without values.

type GetBaseVariableRequest added in v2.184.0

type GetBaseVariableRequest struct {
	Dataset  string
	Variable string
}

type GetBaseVariableResponse added in v2.184.0

type GetBaseVariableResponse struct {
	Dataset gql.Dataset `json:"dataset"`
}

type GetBlockedAreaCountRequest added in v2.223.0

type GetBlockedAreaCountRequest struct {
	Dataset   string
	Variables []string
	Filters   []Filter
}

type GetBlockedAreaCountResponse added in v2.223.0

type GetBlockedAreaCountResponse struct {
	Dataset struct {
		Table Table `json:"table"`
	} `json:"dataset"`
}

GetParentAreaCountResponse is the response body for the GetParentAreaCount query

type GetBlockedAreaCountResult added in v2.223.0

type GetBlockedAreaCountResult struct {
	Passed     int    `json:"passed"`
	Blocked    int    `json:"blocked"`
	Total      int    `json:"total"`
	TableError string `json:"table_error,omitempty"`
}

type GetCategorisationCountsResponse added in v2.239.0

type GetCategorisationCountsResponse struct {
	Counts map[string]int `json:"counts"`
}

type GetCategorisationsCountsRequest added in v2.239.0

type GetCategorisationsCountsRequest struct {
	Dataset   string
	Variables []string
}

type GetCategorisationsRequest added in v2.173.0

type GetCategorisationsRequest struct {
	PaginationParams
	Dataset  string
	Variable string
}

GetCategorisationsRequest holds the input parameters for the GetCategorisations query

type GetCategorisationsResponse added in v2.173.0

type GetCategorisationsResponse struct {
	PaginationResponse
	Dataset gql.Dataset `json:"dataset"`
}

GetCategorisationsResponse is the response body for the GetCategorisations query

type GetCodebookRequest

type GetCodebookRequest struct {
	DatasetName string
	Variables   []string
	Categories  bool
}

GetCodebookRequest holds the query parameters for GET [cantabular-srv]/codebook/{dataset}?cats=xxx&v=xxx

type GetCodebookResponse

type GetCodebookResponse struct {
	Codebook Codebook `json:"codebook"`
	Dataset  Dataset  `json:"dataset"`
}

GetCodebookResponse holds the response body for GET [cantabular-srv]/codebook/{dataset}?cats=xxx&v=xxx

type GetDimensionCategoriesRequest added in v2.217.0

type GetDimensionCategoriesRequest struct {
	PaginationParams
	Dataset   string   `json:"dataset"`
	Variables []string `json:"variables"`
}

type GetDimensionCategoriesResponse added in v2.217.0

type GetDimensionCategoriesResponse struct {
	PaginationResponse
	Dataset gql.Dataset `json:"dataset"`
}

type GetDimensionOptionsRequest added in v2.8.1

type GetDimensionOptionsRequest struct {
	Dataset        string
	DimensionNames []string
	Filters        []Filter
}

GetDimensionOptionsRequest holds the request variables required from the caller for making a request to obtain dimension options (categories) for the provided cantabular Dataset and dimension names (Cantabular variables)

POST [cantabular-ext]/graphql with the encoded query

type GetDimensionOptionsResponse added in v2.7.1

type GetDimensionOptionsResponse struct {
	Dataset StaticDatasetDimensionOptions `json:"dataset"`
}

GetDimensionOptionsResponse holds the response body for POST [cantabular-ext]/graphql with a query to obtain static dataset variables and categories, without values.

type GetDimensionsByNameRequest added in v2.8.1

type GetDimensionsByNameRequest struct {
	Dataset          string
	DimensionNames   []string
	ExcludeGeography bool
}

GetDimensionsByNameRequest holds the request variables required from the caller for making a request to obtain dimensions (Cantabular variables) by name POST [cantabular-ext]/graphql

type GetDimensionsDescriptionRequest added in v2.216.0

type GetDimensionsDescriptionRequest struct {
	Dataset        string
	DimensionNames []string
}

type GetDimensionsRequest added in v2.163.0

type GetDimensionsRequest struct {
	PaginationParams
	Dataset string
	Text    string
}

type GetDimensionsResponse added in v2.7.1

type GetDimensionsResponse struct {
	PaginationResponse
	Dataset gql.Dataset `json:"dataset"`
}

GetDimensionsResponse holds the response body for POST [cantabular-ext]/graphql with a query to obtain variables

type GetGeographyBatchProcessor added in v2.163.0

type GetGeographyBatchProcessor func(response *GetGeographyDimensionsResponse) (abort bool, err error)

GetGeographyBatchProcessor is the type corresponding to a batch processing function for Geography dimensions

type GetGeographyDimensionsRequest added in v2.122.0

type GetGeographyDimensionsRequest struct {
	PaginationParams
	Dataset string `json:"dataset"`
	Text    string `json:"text"`
}

GetGeographyDimensionsRequest holds the request parameters for POST [cantabular-ext]/graphql with a query to obtain geography variables

type GetGeographyDimensionsResponse added in v2.8.1

type GetGeographyDimensionsResponse struct {
	PaginationResponse
	Dataset gql.Dataset `json:"dataset"`
}

GetGeographyDimensionsResponse holds the response body for POST [cantabular-ext]/graphql with a query to obtain geography variables

type GetObservationResponse added in v2.256.0

type GetObservationResponse struct {
	Dimensions  []ObservationDimension `json:"dimensions"`
	Observation float32                `json:"observation"`
}

type GetObservationsResponse added in v2.256.0

type GetObservationsResponse struct {
	Observations      []GetObservationResponse `json:"observations"`
	Links             DatasetJSONLinks         `json:"links"`
	TotalObservations int                      `json:"total_observations"`
	BlockedAreas      int                      `json:"blocked_areas"`
	TotalAreas        int                      `json:"total_areas"`
	AreasReturned     int                      `json:"areas_returned"`
}

func GraphQLJSONToJson added in v2.256.0

func GraphQLJSONToJson(ctx context.Context, r io.Reader, w io.Writer) (GetObservationsResponse, error)

GraphQLJSONToJson converts a JSON response in r to a different schema on w, returning the response if an error happens, the process is aborted and the error is returned.

type GetParentAreaCountRequest added in v2.170.0

type GetParentAreaCountRequest struct {
	Dataset   string
	Variable  string
	Parent    string
	SVariable string
	Codes     []string
}

GetParentAreaCountRequest holds the input parameters for the GetParentAreaCount query

type GetParentAreaCountResponse added in v2.170.0

type GetParentAreaCountResponse struct {
	Dataset struct {
		Table Table `json:"table"`
	} `json:"dataset"`
}

GetParentAreaCountResponse is the response body for the GetParentAreaCount query

type GetParentAreaCountResult added in v2.170.0

type GetParentAreaCountResult struct {
	Dimension Dimension
}

GetParentAreaCountResult is the useful part of the response for GetParentAreaCount

type GetParentsRequest added in v2.148.0

type GetParentsRequest struct {
	PaginationParams
	Dataset  string
	Variable string
}

GetParentsRequest holds the input parameters for the GetParents query

type GetParentsResponse added in v2.148.0

type GetParentsResponse struct {
	PaginationResponse
	Dataset gql.Dataset `json:"dataset"`
}

GetParentsResponse is the response body for the GetParents query

type GraphQLClient

type GraphQLClient interface {
	Query(ctx context.Context, query interface{}, vars map[string]interface{}) error
}

GraphQLClient is the Client used by the GraphQL package to make queries

type Iterator added in v2.4.0

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

Iterator facilitates reading the coordinates of each cell in row-major order

func (*Iterator) CategoryAtColumn added in v2.4.0

func (it *Iterator) CategoryAtColumn(i int) (Category, error)

CategoryAtColumn returns the i-th coordinate of the current cell

func (*Iterator) End added in v2.4.0

func (it *Iterator) End() bool

End returns true if there are no more cells in the table

func (*Iterator) Next added in v2.4.0

func (it *Iterator) Next() error

Next advances to the next table cell. It should not be called if End() would return true. If the Iterator contet is done, an error will be returned.

type Link struct {
	HREF  string `json:"href"`
	Label string `json:"label,omitempty"`
	ID    string `json:"id,omitempty"`
}

type ListDatasetsResponse added in v2.213.0

type ListDatasetsResponse struct {
	Datasets []gql.Dataset `json:"datasets"`
}

type MapFrom

type MapFrom struct {
	SourceNames []string `json:"sourceNames,omitempty"`
	Code        []string `json:"codes,omitempty"`
}

MapFrom represents the 'mapFrom' object from variable when category information is included

type MetadataDatasetQuery added in v2.190.0

type MetadataDatasetQuery struct {
	Dataset struct {
		Label       graphql.String `graphql:"label" json:"label"`
		Description graphql.String `graphql:"description" json:"description"`
		Meta        struct {
			Source struct {
				Contact struct {
					ContactName    graphql.String `graphql:"Contact_Name" json:"contact_name"`
					ContactEmail   graphql.String `graphql:"Contact_Email" json:"contact_email"`
					ContactPhone   graphql.String `graphql:"Contact_Phone" json:"contact_phone"`
					ContactWebsite graphql.String `graphql:"Contact_Website" json:"contact_website"`
				} `graphql:"Contact" json:"contact"`
				Licence                    graphql.String `graphql:"Licence" json:"licence"`
				MethodologyLink            graphql.String `graphql:"Methodology_Link" json:"methodology_link"`
				MethodologyStatement       graphql.String `graphql:"Methodology_Statement" json:"methodology_statement"`
				NationalStatisticCertified graphql.String `graphql:"Nationals_Statistic_Certified" json:"national_statistic_certified"`
			} `graphql:"Source" json:"source"`
		} `graphql:"meta" json:"meta"`
		Vars []struct {
			Description graphql.String `json:"description"`
			Label       graphql.String `json:"label"`
			Name        graphql.String `json:"name"`
			Meta        struct {
				DefaultClassificationFlag graphql.String `graphql:"Default_Classification_Flag" json:"default_classification_flag"`
				Mnemonic2011              graphql.String `graphql:"Mnemonic_2011" json:"mnemonic_2011"`
				Version                   graphql.String `graphql:"Version" json:"version"`

				ONSVariable struct {
					ComparabilityComments graphql.String `graphql:"Comparability_Comments" json:"comparability_comments"`
					GeographicCoverage    graphql.String `graphql:"Geographic_Coverage" json:"geographic_coverage"`
					GeographicTheme       graphql.String `graphql:"Geographic_Theme" json:"geographic_theme"`
					QualityStatementText  graphql.String `graphql:"Quality_Statement_Text"  json:"quality_statement_text"`
					QualitySummaryURL     graphql.String `graphql:"Quality_Summary_URL"  json:"quality_summary_url"`
					UkComparisonComments  graphql.String `graphql:"Uk_Comparison_Comments"  json:"uk_comparison_comments"`
					VariableMnemonic      graphql.String `graphql:"Variable_Mnemonic"  json:"variable_mnemonic"`
					VariableMnemonic2011  graphql.String `graphql:"Variable_Mnemonic_2011" json:"variable_mnemonic_2011"`
					VariableTitle         graphql.String `graphql:"Variable_Title"  json:"variable_title"`

					Version graphql.String `graphql:"Version"  json:"version"`

					Questions []struct {
						QuestionCode             graphql.String `graphql:"Question_Code" json:"question_code"`
						QuestionFirstAskedInYear graphql.String `graphql:"Question_First_Asked_In_Year" json:"question_first_asked_in_year"`
						QuestionLabel            graphql.String `graphql:"Question_Label" json:"question_label"`
						ReasonForAskingQuestion  graphql.String `graphql:"Reason_For_Asking_Question" json:"reason_for_asking_question"`
						Version                  graphql.String `graphql:"Version" json:"version"`
					} `graphql:"Questions" json:"questions,omitempty"`

					StatisticalUnit struct {
						StatisticalUnit     graphql.String `graphql:"Statistical_Unit" json:"statistical_unit"`
						StatisticalUnitDesc graphql.String `graphql:"Statistical_Unit_Description" json:"statistical_unit_desc"`
					} `graphql:"Statistical_Unit" json:"statistical_unit"`

					Topic struct {
						TopicMnemonic    graphql.String `graphql:"Topic_Mnemonic" json:"topic_mnemonic"`
						TopicDescription graphql.String `graphql:"Topic_Description" json:"topic_description"`
						TopicTitle       graphql.String `graphql:"Topic_Title" json:"topic_title"`
					} `graphql:"Topic" json:"topic"`

					VariableType struct {
						VariableTypeCode        graphql.String `graphql:"Variable_Type_Code" json:"variable_type_code"`
						VariableTypeDescription graphql.String `graphql:"Variable_Type_Description" json:"variable_type_description"`
					} `graphql:"Variable_Type" json:"variable_type"`
				} `graphql:"ONS_Variable" json:"ONS_Variable"`

				Topics []struct {
					TopicMnemonic    graphql.String `graphql:"Topic_Mnemonic" json:"topic_mnemonic"`
					TopicDescription graphql.String `graphql:"Topic_Description" json:"topic_description"`
					TopicTitle       graphql.String `graphql:"Topic_Title" json:"topic_title"`
				} `graphql:"Topics" json:"topics"`
			} `json:"meta"`
		} `graphql:"vars(names: $vars)" json:"vars"`
	} `graphql:"dataset(name: $ds, lang: $lang)" json:"dataset"`
}

MetadataDatasetQuery represents the metadata schema for a dataset based query. It's used for forming a request (see the graphql tags) and parsing a response (json tags)

type MetadataDatasetQueryRequest added in v2.190.0

type MetadataDatasetQueryRequest struct {
	Dataset   string   `json:"dataset"`
	Lang      string   `json:"lang"`
	Variables []string `json:"variables"`
}

MetadataDatasetQueryRequest represents the params for a GraphQL dataset request

type MetadataQueryResult added in v2.190.0

type MetadataQueryResult struct {
	TableQueryResult   *MetadataTableQuery   `json:"table_query_result"`
	DatasetQueryResult *MetadataDatasetQuery `json:"dataset_query_result"`
}

MetadataQueryResult represents the full response including both the table response and the dataset response

type MetadataTableQuery added in v2.190.0

type MetadataTableQuery struct {
	Service struct {
		Tables []struct {
			Name        graphql.String   `json:"name"`
			DatasetName graphql.String   `json:"dataset_name"`
			Label       graphql.String   `json:"label"`
			Description graphql.String   `json:"description"`
			Vars        []graphql.String `json:"vars"`
			Meta        struct {
				Alternate_Geographic_Variables []graphql.String `graphql:"Alternate_Geographic_Variables" json:"alternate_geographic_variables"`
				Contact                        struct {
					ContactName    graphql.String `graphql:"Contact_Name" json:"contact_name"`
					ContactEmail   graphql.String `graphql:"Contact_Email" json:"contact_email"`
					ContactPhone   graphql.String `graphql:"Contact_Phone" json:"contact_phone"`
					ContactWebsite graphql.String `graphql:"Contact_Website" json:"contact_website" `
				} `graphql:"Contact" json:"contact"`

				CensusReleases []struct {
					CensusReleaseDescription graphql.String `graphql:"Census_Release_Description" json:"census_release_description" `
					CensusReleaseNumber      graphql.String `graphql:"Census_Release_Number" json:"census_release_number" `
					ReleaseDate              graphql.String `graphql:"Release_Date" json:"release_date" `
				} `graphql:"Census_Releases" json:"census_releases"`

				DatasetMnemonic2011 graphql.String `graphql:"Dataset_Mnemonic_2011" json:"dataset_mnemonic2011" `
				DatasetPopulation   graphql.String `graphql:"Dataset_Population" json:"dataset_population"`
				GeographicCoverage  graphql.String `graphql:"Geographic_Coverage" json:"geographic_coverage"`
				LastUpdated         graphql.String `graphql:"Last_Updated" json:"last_updated"`
				Observation_Type    struct {
					Observation_Type_Description graphql.String `graphql:"Observation_Type_Description" json:"observation_type_description"`

					Observation_Type_Label graphql.String `graphql:"Observation_Type_Label" json:"observation_type_label"`

					Decimal_Places graphql.String `graphql:"Decimal_Places" json:"decimal_places"`

					Prefix graphql.String `graphql:"Prefix" json:"prefix"`

					Suffix graphql.String `graphql:"Suffix" json:"suffix"`

					FillTrailingSpaces graphql.String `graphql:"FillTrailingSpaces" json:"fill_trailing_spaces"`

					NegativeSign graphql.String `graphql:"NegativeSign" json:"negative_sign"`

					Observation_Type_Code graphql.String `graphql:"Observation_Type_Code" json:"observation_type_code"`
				} `graphql:"Observation_Type" json:"observation_type"`

				Publications []struct {
					PublisherName    graphql.String `graphql:"Publisher_Name" json:"publisher_name"`
					PublicationTitle graphql.String `graphql:"Publication_Title" json:"publication_title"`
					PublisherWebsite graphql.String `graphql:"Publisher_Website" json:"publisher_website"`
				} `graphql:"Publications" json:"publications"`

				RelatedDatasets []graphql.String `graphql:"Related_Datasets" json:"related_datasets"`

				StatisticalUnit struct {
					StatisticalUnit            graphql.String `graphql:"Statistical_Unit" json:"statistical_unit"`
					StatisticalUnitDescription graphql.String `graphql:"Statistical_Unit_Description" json:"statistical_unit_description"`
				} `graphql:"Statistical_Unit" json:"statistical_unit"`

				Version graphql.String `graphql:"Version" json:"version"`
			} `json:"meta"`
		} `graphql:"tables(names: $vars)" json:"tables"`
	} `graphql:"service(lang: $lang)" json:"service"`
}

MetadataTableQuery represents the metadata schema for a table based query. It's used for forming a request (see the graphql tags) and parsing a response (json tags)

type MetadataTableQueryRequest added in v2.190.0

type MetadataTableQueryRequest struct {
	Lang      string   `json:"lang"`
	Variables []string `json:"variables"`
}

MetadataTableQueryRequest represents the params for a GraphQL table request

type ObservationDimension added in v2.256.0

type ObservationDimension struct {
	Dimension   string `json:"dimension"`
	DimensionID string `json:"dimension_id"`
	Option      string `json:"option"`
	OptionID    string `json:"option_id"`
}

type PaginationParams added in v2.122.0

type PaginationParams struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
}

type PaginationResponse added in v2.122.0

type PaginationResponse struct {
	PaginationParams
	Count      int `json:"count"`
	TotalCount int `json:"total_count"`
}

type QueryData added in v2.8.1

type QueryData struct {
	PaginationParams
	Dataset   string
	Text      string
	Variables []string
	Filters   []Filter
	Category  string
	Rule      bool
	Base      bool
}

QueryData holds all the possible required variables to encode any of the graphql queries defined in this file.

func (*QueryData) Encode added in v2.8.1

func (data *QueryData) Encode(query string) (bytes.Buffer, error)

Encode the provided graphQL query with the data in QueryData returns a byte buffer with the encoded query, along with any encoding error that might happen

type RuleVariable added in v2.223.0

type RuleVariable struct {
	Categories []Categories `json:"categories,omitempty"`
	Count      int          `json:"count,omitempty"`
}

type Rules added in v2.223.0

type Rules struct {
	Blocked RuleVariable `json:"blocked,omitempty"`
	Passed  RuleVariable `json:"passed,omitempty"`
	Total   RuleVariable `json:"evaluated,omitempty"`
}

type SearchDimensionsRequest added in v2.9.3

type SearchDimensionsRequest struct {
	Dataset string
	Text    string
}

SearchDimensionsRequest holds the request variables required from the caller for making a request to search dimensions (Cantabular variables) by text POST [cantabular-ext]/graphql

type StaticDataset

type StaticDataset struct {
	Table Table `json:"table" graphql:"table(variables: $variables)"`
}

StaticDataset represents the 'dataset' field from a GraphQL static dataset query response

type StaticDatasetDimensionOptions added in v2.7.1

type StaticDatasetDimensionOptions struct {
	Table DimensionsTable `json:"table"`
}

StaticDatasetDimensionOptions represents the 'dataset' field from a GraphQL static dataset query response, containing a DimensionsTable, without values

type StaticDatasetQuery

type StaticDatasetQuery struct {
	Dataset StaticDataset `json:"dataset" graphql:"dataset(name: $name)"`
}

StaticDatasetQuery holds the query for a static dataset landing page from POST [cantabular-ext]/graphql. It is used both as the internal query request to GraphQL as well as the response to the caller, as GraphQL query responses are essentially unmarshalled into the requests.

type StaticDatasetQueryRequest

type StaticDatasetQueryRequest struct {
	Dataset   string   `json:"dataset"`
	Variables []string `json:"variables"`
	Filters   []Filter `json:"filters"`
}

StaticDatasetQueryRequest holds the request variables required from the caller for making a request for a static dataset landing page from POST [cantabular-ext]/graphql

type StaticDatasetQueryTypeResponse added in v2.243.0

type StaticDatasetQueryTypeResponse struct {
	Dataset gql.Dataset `json:"dataset"`
}

type Table

type Table struct {
	Dimensions []Dimension `json:"dimensions"`
	Values     []float32   `json:"values"`
	Error      string      `json:"error,omitempty" `
	Rules      Rules       `json:"rules,omitempty"`
}

Table represents the 'table' field from the GraphQL dataset query response

type Variable

type Variable struct {
	VariableBase
	Len     int       `json:"len"`
	Codes   []string  `json:"codes,omitempty"`
	Labels  []string  `json:"labels,omitempty"`
	MapFrom []MapFrom `json:"mapFrom,omitempty"`
}

Variable represents a 'variable' object returned from Cantabular

type VariableBase

type VariableBase struct {
	Name  string `json:"name"`
	Label string `json:"label"`
}

VariableBase represents the minimum amount of fields returned by Cantabular for a 'variable' object. Is kept separate from the full Variable struct because GraphQL/Cantabular has difficulty unmarshaling into a struct with unexpected objects (in this case MapFrom), even if they're set to not be included

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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