Documentation
¶
Index ¶
- Constants
- Variables
- func EndpointURLWithToken(raw, token string) string
- func IsAlreadyExists(err error) bool
- func IsNotFound(err error) bool
- func IsUnauthorized(err error) bool
- func RedactEndpointURL(raw string) string
- type AzureDestination
- type Chain
- type Client
- func (c *Client) ActivateStream(ctx context.Context, id string) error
- func (c *Client) AddDomainMask(ctx context.Context, endpointID, domainMask string) (*SecurityEntry, error)
- func (c *Client) AddEndpointIP(ctx context.Context, endpointID, ip string) (*SecurityEntry, error)
- func (c *Client) AddEndpointTag(ctx context.Context, id, label string) error
- func (c *Client) AddEndpointToken(ctx context.Context, endpointID string) (*EndpointToken, error)
- func (c *Client) AddJWT(ctx context.Context, endpointID string, jwt JWT) (*JWT, error)
- func (c *Client) AddMethodRateLimit(ctx context.Context, endpointID string, limiter MethodRateLimit) (*MethodRateLimit, error)
- func (c *Client) AddReferrer(ctx context.Context, endpointID, referrer string) (*SecurityEntry, error)
- func (c *Client) AddRequestFilter(ctx context.Context, endpointID string, methods []string) (*RequestFilter, error)
- func (c *Client) CreateEndpoint(ctx context.Context, chain, network string) (*Endpoint, error)
- func (c *Client) CreateKVList(ctx context.Context, key string, items []string) error
- func (c *Client) CreateStream(ctx context.Context, input StreamInput) (*Stream, error)
- func (c *Client) DeleteEndpoint(ctx context.Context, id string) error
- func (c *Client) DeleteIPCustomHeader(ctx context.Context, endpointID string) error
- func (c *Client) DeleteKVList(ctx context.Context, key string) error
- func (c *Client) DeleteKVValue(ctx context.Context, key string) error
- func (c *Client) DeleteRateLimitOverride(ctx context.Context, endpointID, overrideID string) error
- func (c *Client) DeleteStream(ctx context.Context, id string) error
- func (c *Client) FindEndpointByLabel(ctx context.Context, label string) (*EndpointSummary, error)
- func (c *Client) GetEndpoint(ctx context.Context, id string) (*Endpoint, error)
- func (c *Client) GetEndpointSecurity(ctx context.Context, endpointID string) (*EndpointSecurity, error)
- func (c *Client) GetEndpointURLs(ctx context.Context, id string) (*EndpointURLs, error)
- func (c *Client) GetKVList(ctx context.Context, key string) ([]string, error)
- func (c *Client) GetKVValue(ctx context.Context, key string) (string, error)
- func (c *Client) GetRateLimits(ctx context.Context, endpointID string) (*EndpointRateLimits, error)
- func (c *Client) GetStream(ctx context.Context, id string) (*Stream, error)
- func (c *Client) ListChains(ctx context.Context) ([]Chain, error)
- func (c *Client) ListEndpoints(ctx context.Context, filter EndpointFilter) ([]EndpointSummary, error)
- func (c *Client) ListMethodRateLimits(ctx context.Context, endpointID string) ([]MethodRateLimit, error)
- func (c *Client) PauseStream(ctx context.Context, id string) error
- func (c *Client) RemoveDomainMask(ctx context.Context, endpointID, domainMaskID string) error
- func (c *Client) RemoveEndpointIP(ctx context.Context, endpointID, ipID string) error
- func (c *Client) RemoveEndpointTag(ctx context.Context, id string, tagID int64) error
- func (c *Client) RemoveEndpointToken(ctx context.Context, endpointID, tokenID string) error
- func (c *Client) RemoveJWT(ctx context.Context, endpointID, jwtID string) error
- func (c *Client) RemoveMethodRateLimit(ctx context.Context, endpointID, limiterID string) error
- func (c *Client) RemoveReferrer(ctx context.Context, endpointID, referrerID string) error
- func (c *Client) RemoveRequestFilter(ctx context.Context, endpointID, filterID string) error
- func (c *Client) SetEndpointLabel(ctx context.Context, id, label string) error
- func (c *Client) SetEndpointMultichain(ctx context.Context, id string, enabled bool) error
- func (c *Client) SetEndpointStatus(ctx context.Context, id, status string) error
- func (c *Client) SetIPCustomHeader(ctx context.Context, endpointID, headerName string) error
- func (c *Client) SetKVValue(ctx context.Context, key, value string) error
- func (c *Client) SetRateLimits(ctx context.Context, endpointID string, overrides RateLimitOverrides) error
- func (c *Client) SetSecurityOptions(ctx context.Context, endpointID string, patch SecurityOptionsPatch) error
- func (c *Client) UpdateKVList(ctx context.Context, key string, add, remove []string) error
- func (c *Client) UpdateMethodRateLimit(ctx context.Context, endpointID, limiterID string, limiter MethodRateLimit) error
- func (c *Client) UpdateRequestFilter(ctx context.Context, endpointID, filterID string, methods []string) error
- func (c *Client) UpdateStream(ctx context.Context, id string, update StreamUpdate) (*Stream, error)
- type Endpoint
- type EndpointFilter
- type EndpointRateLimits
- type EndpointSecurity
- type EndpointSummary
- type EndpointToken
- type EndpointURLs
- type Error
- type HeaderMap
- type JWT
- type KafkaDestination
- type MethodRateLimit
- type Network
- type NetworkURLs
- type Option
- type PostgresDestination
- type RateLimit
- type RateLimitOverrides
- type RequestFilter
- type S3Destination
- type SecurityEntry
- type SecurityOptions
- type SecurityOptionsPatch
- type Stream
- type StreamDestination
- type StreamInput
- type StreamUpdate
- type Tag
- type WebhookDestination
Constants ¶
const ( // RateLimitUnset is what the Admin API reports for a bucket with no // endpoint-level override. RateLimitUnset = -1 SourcePlanDefault = "plan_default" SourceUserOverride = "user_override" BucketRPS = "rps" BucketRPM = "rpm" BucketRPD = "rpd" )
const ( StreamStatusActive = "active" StreamStatusPaused = "paused" StreamStatusTerminated = "terminated" StreamStatusCompleted = "completed" )
const ( DestinationWebhook = "webhook" DestinationS3 = "s3" DestinationAzure = "azure" DestinationPostgres = "postgres" DestinationKafka = "kafka" )
const DefaultBaseURL = "https://api.quicknode.com"
const KVBatchLimit = 1500
KVBatchLimit is the most items one list write may add and remove together. Larger changes are split into several writes, so a failure part way through leaves some of them applied.
const StreamRangeUnset int64 = -1
StreamRangeUnset is what the API reports for an end_range that runs forever, and what it accepts as a start_range meaning the latest block.
const URLTokenPlaceholder = "REPLACE_WITH_TOKEN"
URLTokenPlaceholder stands in for the auth token in SafeHTTPURL and SafeWSSURL. It keeps the shape of the real URL, including any path suffix the chain appends, so the token's position stays visible and a caller can substitute one without guessing where it goes.
Variables ¶
var KVKeyPattern = regexp.MustCompile(`^[A-Za-z0-9 ._:$-]+$`)
KVKeyPattern matches the list and value keys the Key-Value API accepts.
Functions ¶
func EndpointURLWithToken ¶ added in v0.2.0
EndpointURLWithToken puts token in the credential's position of an endpoint URL, whether that position holds a real token or URLTokenPlaceholder.
func IsAlreadyExists ¶ added in v0.3.0
func IsNotFound ¶
func IsUnauthorized ¶
IsUnauthorized reports the two ways the Admin API rejects a key: an invalid key, and a key on a plan without Admin API access.
func RedactEndpointURL ¶
RedactEndpointURL replaces the credential in an endpoint URL with URLTokenPlaceholder. The Admin API returns URLs shaped https://<subdomain>.quiknode.pro/<token>[/<suffix>], and the suffix differs by chain, so the placeholder goes in the token's position and nothing is cut out. The result keeps the real URL's shape and is safe to log.
Types ¶
type AzureDestination ¶ added in v0.4.0
type AzureDestination struct {
StorageAccount string `json:"storage_account"`
Container string `json:"container"`
BlobPrefix string `json:"blob_prefix"`
FileType string `json:"file_type"`
FileCompressionType string `json:"file_compression_type"`
SASToken string `json:"sas_token,omitempty"`
MaxRetry int64 `json:"max_retry"`
RetryIntervalSec int64 `json:"retry_interval_sec"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ActivateStream ¶ added in v0.4.0
func (*Client) AddDomainMask ¶
func (*Client) AddEndpointIP ¶
func (*Client) AddEndpointTag ¶
func (*Client) AddEndpointToken ¶
func (*Client) AddMethodRateLimit ¶
func (c *Client) AddMethodRateLimit(ctx context.Context, endpointID string, limiter MethodRateLimit) (*MethodRateLimit, error)
func (*Client) AddReferrer ¶
func (*Client) AddRequestFilter ¶
func (*Client) CreateEndpoint ¶
func (*Client) CreateKVList ¶ added in v0.4.0
CreateKVList writes a new list. Creating a list whose key already exists adds the items to it rather than replacing it, so callers check first.
func (*Client) CreateStream ¶ added in v0.4.0
func (*Client) DeleteEndpoint ¶
func (*Client) DeleteIPCustomHeader ¶
func (*Client) DeleteKVList ¶ added in v0.4.0
func (*Client) DeleteKVValue ¶ added in v0.4.0
func (*Client) DeleteRateLimitOverride ¶
DeleteRateLimitOverride drops one bucket back to the plan default. A 404 is success, since an absent override is the state the caller asked for.
func (*Client) DeleteStream ¶ added in v0.4.0
func (*Client) FindEndpointByLabel ¶
FindEndpointByLabel resolves a label to a single endpoint. Labels are not unique, so more than one match is an error.
func (*Client) GetEndpoint ¶
func (*Client) GetEndpointSecurity ¶
func (*Client) GetEndpointURLs ¶ added in v0.2.0
func (*Client) GetKVList ¶ added in v0.4.0
GetKVList returns every item in the list, in the API's sorted order. A list that does not exist reads the same as an empty one, so both return no items and no error.
func (*Client) GetKVValue ¶ added in v0.4.0
GetKVValue returns an error that satisfies IsNotFound when the key has no value.
func (*Client) GetRateLimits ¶
func (*Client) ListEndpoints ¶
func (c *Client) ListEndpoints(ctx context.Context, filter EndpointFilter) ([]EndpointSummary, error)
ListEndpoints walks every page, so a caller gets the whole account rather than the first twenty rows.
func (*Client) ListMethodRateLimits ¶
func (*Client) PauseStream ¶ added in v0.4.0
func (*Client) RemoveDomainMask ¶
func (*Client) RemoveEndpointIP ¶
func (*Client) RemoveEndpointTag ¶
func (*Client) RemoveEndpointToken ¶
func (*Client) RemoveMethodRateLimit ¶
func (*Client) RemoveReferrer ¶
func (*Client) RemoveRequestFilter ¶
func (*Client) SetEndpointLabel ¶
func (*Client) SetEndpointMultichain ¶
func (*Client) SetEndpointStatus ¶
func (*Client) SetIPCustomHeader ¶
func (*Client) SetKVValue ¶ added in v0.4.0
SetKVValue stores the value, replacing any value the key already has.
func (*Client) SetRateLimits ¶
func (c *Client) SetRateLimits(ctx context.Context, endpointID string, overrides RateLimitOverrides) error
SetRateLimits writes the settings the caller manages. Managing none sends no request at all. The route rejects an empty rate_limits object, so it is left out when no bucket is set.
func (*Client) SetSecurityOptions ¶
func (c *Client) SetSecurityOptions(ctx context.Context, endpointID string, patch SecurityOptionsPatch) error
SetSecurityOptions writes the settable toggles. The read path reports them as booleans and the write path takes the strings "enabled" and "disabled", so the conversion happens here once, for every caller. A patch that manages nothing sends no request at all.
func (*Client) UpdateKVList ¶ added in v0.4.0
UpdateKVList adds and removes items in batches of at most KVBatchLimit.
func (*Client) UpdateMethodRateLimit ¶
func (c *Client) UpdateMethodRateLimit(ctx context.Context, endpointID, limiterID string, limiter MethodRateLimit) error
UpdateMethodRateLimit edits a limiter in place. The route takes the whole object, not a delta, and it does not accept interval, so a changed interval has to replace the limiter.
func (*Client) UpdateRequestFilter ¶
func (*Client) UpdateStream ¶ added in v0.4.0
type Endpoint ¶
type Endpoint struct {
ID string
Chain string
Network string
Label string
Status string
// SafeHTTPURL and SafeWSSURL carry URLTokenPlaceholder where the token
// belongs, so they can be logged or displayed. HTTPURLWithToken and
// WSSURLWithToken are what the API returned, credential included.
SafeHTTPURL string
SafeWSSURL string
HTTPURLWithToken string
WSSURLWithToken string
Multichain bool
Tokens []EndpointToken
Tags []Tag
Security SecurityOptions
}
type EndpointFilter ¶
type EndpointFilter struct {
Search string
Networks []string
Statuses []string
Labels []string
TagLabels []string
}
EndpointFilter narrows a listing. Empty fields are left off the query, and the API treats several values in one field as "any of".
type EndpointRateLimits ¶ added in v0.5.0
type EndpointSecurity ¶
type EndpointSecurity struct {
Options SecurityOptions
IPs []SecurityEntry
DomainMasks []SecurityEntry
Referrers []SecurityEntry
JWTs []JWT
RequestFilters []RequestFilter
Tokens []EndpointToken
}
type EndpointSummary ¶
type EndpointSummary struct {
ID string
Name string
Label string
Chain string
Network string
Status string
SafeHTTPURL string
SafeWSSURL string
Dedicated bool
FlatRate bool
Multichain bool
Tags []Tag
}
EndpointSummary is one row of the list route. It carries less than a full endpoint read: no tokens, no security and no rate limits. The list route returns credentialed URLs, so the URLs here are redacted on the way in and the working form is only available from a full endpoint read.
type EndpointToken ¶
EndpointToken is one of an endpoint's auth tokens. An endpoint can carry several, so this is a list.
type EndpointURLs ¶ added in v0.2.0
type EndpointURLs struct {
NetworkURLs
Multichain map[string]NetworkURLs
}
EndpointURLs is what the URLs route returns: the endpoint's own network, and for a multichain endpoint every network it serves, keyed by network slug.
type Error ¶
Error carries an Admin API failure. The Admin API can report a failure either through the HTTP status or through the "error" field of a 200 response body, so both paths produce this type.
type HeaderMap ¶ added in v0.4.0
HeaderMap is a webhook's extra request headers. The API stores header values as strings or numbers, so decoding accepts both, and it rejects a missing headers object, so a nil map encodes as an empty one.
func (HeaderMap) MarshalJSON ¶ added in v0.4.0
func (*HeaderMap) UnmarshalJSON ¶ added in v0.4.0
type KafkaDestination ¶ added in v0.4.0
type KafkaDestination struct {
BootstrapServers string `json:"bootstrap_servers"`
TopicName string `json:"topic_name"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Mechanisms string `json:"mechanisms,omitempty"`
Protocol string `json:"protocol,omitempty"`
CompressionType string `json:"compression_type"`
BatchSize int64 `json:"batch_size"`
LingerMs int64 `json:"linger_ms"`
MaxMessageBytes int64 `json:"max_message_bytes"`
TimeoutSec int64 `json:"timeout_sec"`
MaxRetry int64 `json:"max_retry"`
RetryIntervalSec int64 `json:"retry_interval_sec"`
SSLCAPEM string `json:"ssl_ca_pem,omitempty"`
SSLCertificatePEM string `json:"ssl_certificate_pem,omitempty"`
SSLKeyPEM string `json:"ssl_key_pem,omitempty"`
}
type MethodRateLimit ¶
type MethodRateLimit struct {
ID string
Methods []string
Rate int
Interval string
Status string
Created string
LimitByIP bool
}
MethodRateLimit throttles a named set of RPC methods independently of the endpoint-wide buckets.
type NetworkURLs ¶ added in v0.2.0
type NetworkURLs struct {
SafeHTTPURL string
SafeWSSURL string
HTTPURLWithToken string
WSSURLWithToken string
}
NetworkURLs is one network's URLs, in the same safe and credentialed forms as Endpoint's.
type Option ¶
type Option func(*options)
func WithBaseURL ¶
func WithHTTPClient ¶
func WithMaxRetries ¶
func WithRequestsPerSecond ¶
WithRequestsPerSecond throttles outbound calls. A terraform apply over a large workspace bursts many Admin API calls at once, so the provider paces itself and does not lean on the API to reject the excess.
func WithUserAgent ¶ added in v0.4.0
WithUserAgent sets the User-Agent header on every request.
type PostgresDestination ¶ added in v0.4.0
type PostgresDestination struct {
Host string `json:"host"`
Port int64 `json:"port"`
Database string `json:"database"`
TableName string `json:"table_name"`
Username string `json:"username"`
Password string `json:"password"`
SSLMode string `json:"sslmode"`
MaxRetry int64 `json:"max_retry"`
RetryIntervalSec int64 `json:"retry_interval_sec"`
}
type RateLimit ¶
RateLimit is one bucket as the API reports it. A plan_default carries no id, because only an override can be deleted.
type RateLimitOverrides ¶
RateLimitOverrides names the settings a write can change. A nil field is left alone, so a configuration that manages only one bucket does not disturb the others.
type RequestFilter ¶
type S3Destination ¶ added in v0.4.0
type S3Destination struct {
Endpoint string `json:"endpoint"`
Bucket string `json:"bucket"`
Region string `json:"region,omitempty"`
ObjectPrefix string `json:"object_prefix"`
FileType string `json:"file_type"`
FileCompressionType string `json:"file_compression_type"`
UseSSL bool `json:"use_ssl"`
AccessKey string `json:"access_key"`
SecretKey string `json:"secret_key"`
MaxRetry int64 `json:"max_retry"`
RetryIntervalSec int64 `json:"retry_interval_sec"`
}
type SecurityEntry ¶
type SecurityOptions ¶
type SecurityOptions struct {
Tokens bool
Referrers bool
JWTs bool
IPs bool
DomainMasks bool
HSTS bool
Cors bool
RequestFilters bool
ResponseLogging bool
IPCustomHeader string
}
SecurityOptions carries the toggles the Admin API reports for an endpoint. Tokens through Cors are settable. RequestFilters and ResponseLogging are reported but cannot be written, so the provider surfaces them read-only.
type SecurityOptionsPatch ¶
type SecurityOptionsPatch struct {
Tokens *bool
Referrers *bool
JWTs *bool
IPs *bool
DomainMasks *bool
HSTS *bool
Cors *bool
}
SecurityOptionsPatch names the settable toggles. A nil field is left alone, which keeps a write from clobbering a toggle the configuration does not manage.
type Stream ¶ added in v0.4.0
type Stream struct {
ID string
Name string
Status string
Network string
Dataset string
Region string
// FilterFunction is the filter's source code. The API carries it base64
// encoded; the client encodes and decodes it.
FilterFunction string
FilterLanguage string
StartRange int64
EndRange int64
DatasetBatchSize int64
ElasticBatchEnabled bool
RestreamBatchOnReorg bool
FixBlockReorgs int64
KeepDistanceFromTip int64
NotificationEmail string
// Sequence is the last block delivered. It moves on its own while the
// stream runs.
Sequence int64
Destination StreamDestination
ExtraDestinations []StreamDestination
}
type StreamDestination ¶ added in v0.4.0
type StreamDestination struct {
Webhook *WebhookDestination
S3 *S3Destination
Azure *AzureDestination
Postgres *PostgresDestination
Kafka *KafkaDestination
// contains filtered or unexported fields
}
StreamDestination holds exactly one destination type. A type the API reports but the client does not model, such as one configured in the dashboard, leaves every field nil and is named by Type.
func (StreamDestination) MarshalJSON ¶ added in v0.4.0
func (d StreamDestination) MarshalJSON() ([]byte, error)
func (StreamDestination) Type ¶ added in v0.4.0
func (d StreamDestination) Type() string
func (*StreamDestination) UnmarshalJSON ¶ added in v0.4.0
func (d *StreamDestination) UnmarshalJSON(raw []byte) error
type StreamInput ¶ added in v0.4.0
type StreamInput struct {
Name string
Network string
Dataset string
Region string
Status string
FilterFunction string
FilterLanguage string
StartRange *int64
EndRange *int64
DatasetBatchSize int64
ElasticBatchEnabled bool
RestreamBatchOnReorg *bool
FixBlockReorgs *int64
KeepDistanceFromTip *int64
NotificationEmail *string
Destination StreamDestination
ExtraDestinations []StreamDestination
}
type StreamUpdate ¶ added in v0.4.0
type StreamUpdate struct {
Name *string
FilterFunction *string
FilterLanguage *string
StartRange *int64
EndRange *int64
DatasetBatchSize *int64
ElasticBatchEnabled *bool
RestreamBatchOnReorg *bool
FixBlockReorgs *int64
KeepDistanceFromTip *int64
NotificationEmail *string
Destination *StreamDestination
ExtraDestinations *[]StreamDestination
}
StreamUpdate sends only the fields that are set. Network, dataset and region cannot change after creation, and status changes go through PauseStream and ActivateStream, which run the plan checks a PATCH skips.
type WebhookDestination ¶ added in v0.4.0
type WebhookDestination struct {
URL string `json:"url"`
Compression string `json:"compression"`
Headers HeaderMap `json:"headers"`
MaxRetry int64 `json:"max_retry"`
RetryIntervalSec int64 `json:"retry_interval_sec"`
PostTimeoutSec int64 `json:"post_timeout_sec"`
SecurityToken string `json:"security_token,omitempty"`
MTLS *bool `json:"mtls,omitempty"`
SSLCAPEM string `json:"ssl_ca_pem,omitempty"`
}