client

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TableMetadataPath

func TableMetadataPath(req GetTableRequest) string

TableMetadataPath is also used by the Proof transport's exact route allowlist.

func TableTypeStrings

func TableTypeStrings() []string

TableTypeStrings returns a slice of all String values of the enum

Types

type Client

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

Client adapts the official BigQuery REST SDK to Braidplane resource policies.

func New

func New(ctx context.Context, config Config, creds Credentials) (*Client, error)

New creates a BigQuery REST client from runtime configuration and write-only credentials.

func (*Client) Close

func (c *Client) Close() error

Close releases idle HTTP connections held by the BigQuery client.

func (*Client) GetTable

func (c *Client) GetTable(ctx context.Context, req GetTableRequest) (*TableMetadata, error)

GetTable preserves observed identity and schema facts without inferred defaults.

func (*Client) InsertRows

func (c *Client) InsertRows(ctx context.Context, req InsertRowsRequest) (*InsertRowsResult, error)

InsertRows appends rows with one insertAll attempt.

func (*Client) ListDatasets

func (c *Client) ListDatasets(ctx context.Context, req ListDatasetsRequest) ([]Dataset, error)

ListDatasets lists datasets within the schema quota.

func (*Client) ListTables

func (c *Client) ListTables(ctx context.Context, req ListTablesRequest) ([]Table, error)

ListTables lists tables within the schema quota.

func (*Client) Query

func (c *Client) Query(ctx context.Context, req QueryRequest) (*QueryResult, error)

Query executes jobs.query within cumulative response and retained-row budgets.

func (*Client) QueryPages

func (c *Client) QueryPages(ctx context.Context, req QueryRequest, consume func(*QueryResult) error) (retErr error)

QueryPages consumes bounded pages from one query job without retaining prior pages.

func (*Client) TestConnection

func (c *Client) TestConnection(ctx context.Context, req TestConnectionRequest) error

TestConnection verifies credentials with a low-risk dataset request.

type Config

type Config struct {
	ProjectID          string `json:"project_id"                     validate:"required,min=1"`
	Location           string `json:"location,omitempty"             validate:"omitempty,min=1"`
	DefaultDataset     string `json:"default_dataset,omitempty"      validate:"omitempty,min=1"`
	TimeoutSeconds     int    `json:"timeout_seconds,omitempty"      validate:"omitempty,min=1,max=300"`
	MaximumBytesBilled int64  `json:"maximum_bytes_billed,omitempty" validate:"omitempty,min=1"`
	BaseURL            string `json:"base_url,omitempty"             validate:"omitempty,url"`
	TokenURL           string `json:"token_url,omitempty"            validate:"omitempty,url"`
	AllowPrivateHosts  bool   `json:"allow_private_hosts,omitempty"`
}

Config holds BigQuery connector runtime configuration.

type Credentials

type Credentials struct {
	ServiceAccountJSON string `json:"service_account_json,omitempty" validate:"required_without=AccessToken,excluded_with=AccessToken"`
	AccessToken        string `json:"access_token,omitempty" validate:"required_without=ServiceAccountJSON,excluded_with=ServiceAccountJSON"`
}

Credentials holds a service-account key or an access token resolved by credentialssvc.

type Dataset

type Dataset struct {
	ID string
}

Dataset is a provider dataset reference normalized for the adapter.

type Field

type Field struct {
	Name      string
	Type      string
	Mode      string
	Precision string
	Scale     string
	Fields    []Field
}

Field describes one BigQuery result or table schema field.

type GetTableRequest

type GetTableRequest struct {
	ProjectID string
	DatasetID string
	TableID   string
	Location  string
}

GetTableRequest identifies a BigQuery table metadata request.

type InsertRowsRequest

type InsertRowsRequest struct {
	ProjectID        string
	DatasetID        string
	TableID          string
	InsertIDPrefix   string
	Rows             []map[string]any
	MaxRequestBytes  int64
	MaxResponseBytes int64
}

InsertRowsRequest describes an append-style BigQuery insertAll request.

type InsertRowsResult

type InsertRowsResult struct {
	InsertedRows int
}

InsertRowsResult reports the number of rows accepted by BigQuery.

type ListDatasetsRequest

type ListDatasetsRequest struct {
	ProjectID string
	Location  string
}

ListDatasetsRequest identifies the project whose datasets should be listed.

type ListTablesRequest

type ListTablesRequest struct {
	ProjectID string
	DatasetID string
	Location  string
}

ListTablesRequest identifies the dataset whose tables should be listed.

type QueryParameter

type QueryParameter struct {
	Name  string
	Type  string
	Value any
}

QueryParameter is one BigQuery named query parameter.

type QueryRequest

type QueryRequest struct {
	ProjectID          string
	Location           string
	SQL                string
	Parameters         []QueryParameter
	Timeout            time.Duration
	MaximumBytesBilled int64
	MaxResultRows      int   // Materialized row bound (with overflow sentinel), or streamed quota (0 disables).
	MaxResponseBytes   int64 // Cumulative provider bytes and a separate retained-row budget.
}

QueryRequest describes a BigQuery jobs.query request after Braidplane binding.

type QueryResult

type QueryResult struct {
	Schema []Field
	Rows   []map[string]any
}

QueryResult contains provider rows up to the requested row cap.

type Table

type Table struct {
	DatasetID string
	TableID   string
}

Table is a provider table reference normalized for the adapter.

type TableMetadata

type TableMetadata struct {
	ProjectID string
	DatasetID string
	TableID   string
	Type      TableType
	Fields    []Field
}

TableMetadata preserves the observed resource identity, kind, and schema.

func ReadTableMetadata

func ReadTableMetadata(ctx context.Context, transport *http.Client, creds Credentials, req GetTableRequest) (*TableMetadata, error)

ReadTableMetadata uses fixed provider/authentication endpoints and the caller's restricted client. Service-account token_uri cannot widen metadata egress.

type TableType

type TableType int

TableType is the provider resource kind, not a guarantee of write access.

const (
	TableTypeUnknown          TableType = iota // unknown
	TableTypeTable                             // TABLE
	TableTypeView                              // VIEW
	TableTypeExternal                          // EXTERNAL
	TableTypeMaterializedView                  // MATERIALIZED_VIEW
	TableTypeSnapshot                          // SNAPSHOT
)

func TableTypeString

func TableTypeString(s string) (TableType, error)

TableTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func TableTypeValues

func TableTypeValues() []TableType

TableTypeValues returns all values of the enum

func (TableType) IsATableType

func (i TableType) IsATableType() bool

IsATableType returns "true" if the value is listed in the enum definition. "false" otherwise

func (TableType) MarshalJSON

func (i TableType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for TableType

func (TableType) MarshalText

func (i TableType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for TableType

func (TableType) String

func (i TableType) String() string

func (*TableType) UnmarshalJSON

func (i *TableType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for TableType

func (*TableType) UnmarshalText

func (i *TableType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for TableType

type TestConnectionRequest

type TestConnectionRequest struct {
	DatasetID string
	ProjectID string
	Location  string
}

TestConnectionRequest identifies the BigQuery project checked by connection tests.

Jump to

Keyboard shortcuts

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