Documentation
¶
Index ¶
- Constants
- func IsNotFound(err error) bool
- func IsUnauthorized(err error) bool
- func RedactEndpointURL(raw string) string
- type Chain
- type Client
- 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) DeleteEndpoint(ctx context.Context, id string) error
- func (c *Client) DeleteIPCustomHeader(ctx context.Context, endpointID string) error
- func (c *Client) DeleteRateLimitOverride(ctx context.Context, endpointID, overrideID 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) GetRateLimits(ctx context.Context, endpointID string) ([]RateLimit, 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) 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) SetRateLimits(ctx context.Context, endpointID string, overrides RateLimitOverrides) error
- func (c *Client) SetSecurityOptions(ctx context.Context, endpointID string, patch SecurityOptionsPatch) 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
- type Endpoint
- type EndpointFilter
- type EndpointSecurity
- type EndpointSummary
- type EndpointToken
- type Error
- type JWT
- type MethodRateLimit
- type Network
- type Option
- type RateLimit
- type RateLimitOverrides
- type RequestFilter
- type SecurityEntry
- type SecurityOptions
- type SecurityOptionsPatch
- type Tag
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 DefaultBaseURL = "https://api.quicknode.com"
const URLTokenPlaceholder = "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 ¶
This section is empty.
Functions ¶
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 Client ¶
type Client struct {
// contains filtered or unexported fields
}
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) DeleteEndpoint ¶
func (*Client) DeleteIPCustomHeader ¶
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) 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) 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) 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) SetRateLimits ¶
func (c *Client) SetRateLimits(ctx context.Context, endpointID string, overrides RateLimitOverrides) error
SetRateLimits writes the buckets the caller manages. Managing none sends no request at all.
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) 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.
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 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 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 MethodRateLimit ¶
type MethodRateLimit struct {
ID string
Methods []string
Rate int
Interval string
Status string
Created string
}
MethodRateLimit throttles a named set of RPC methods independently of the endpoint-wide buckets.
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.
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 buckets a write can set. A nil field is left alone, so a configuration that manages only one bucket does not disturb the others.
type RequestFilter ¶
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.