Documentation
¶
Overview ¶
Package cfapi contains the small set of Cloudflare wire formats used by the DNSControl provider. Requests are executed by cloudflare-go/v7.
Index ¶
- func AccountIdentifier(id string) string
- func ZoneIdentifier(id string) string
- type API
- func (a *API) CreateDNSRecord(ctx context.Context, zone string, params CreateDNSRecordParams) (DNSRecord, error)
- func (a *API) CreateWorkerRoute(ctx context.Context, zone string, params CreateWorkerRouteParams) (WorkerRoute, error)
- func (a *API) CreateZone(ctx context.Context, name string, jumpStart bool, account Account, ...) (Zone, error)
- func (a *API) DeleteDNSRecord(ctx context.Context, zone, id string) error
- func (a *API) DeleteRulesetRule(ctx context.Context, zone string, params DeleteRulesetRuleParams) error
- func (a *API) DeleteWorkerRoute(ctx context.Context, zone, id string) (WorkerRoute, error)
- func (a *API) EditUniversalSSLSetting(ctx context.Context, zone string, setting UniversalSSLSetting) (UniversalSSLSetting, error)
- func (a *API) GetEntrypointRuleset(ctx context.Context, zone, phase string) (Ruleset, error)
- func (a *API) ListDNSRecords(ctx context.Context, zone string, _ ListDNSRecordsParams) ([]DNSRecord, any, error)
- func (a *API) ListWorkerRoutes(ctx context.Context, zone string, _ ListWorkerRoutesParams) (WorkerRoutesResponse, error)
- func (a *API) ListZones(ctx context.Context) ([]Zone, error)
- func (a *API) Raw(ctx context.Context, method, path string, body any, _ any) (RawResult, error)
- func (a *API) SetDebug(enabled bool)
- func (a *API) UniversalSSLSettingDetails(ctx context.Context, zone string) (UniversalSSLSetting, error)
- func (a *API) UpdateDNSRecord(ctx context.Context, zone string, params UpdateDNSRecordParams) (DNSRecord, error)
- func (a *API) UpdateEntrypointRuleset(ctx context.Context, zone string, params UpdateEntrypointRulesetParams) (Ruleset, error)
- func (a *API) UploadWorker(ctx context.Context, account string, params CreateWorkerParams) (any, error)
- type Account
- type CreateDNSRecordParams
- type CreateWorkerParams
- type CreateWorkerRouteParams
- type DNSRecord
- type DNSRecordSettings
- type DeleteRulesetRuleParams
- type ListDNSRecordsParams
- type ListWorkerRoutesParams
- type NotFoundError
- type Option
- type PageRule
- type RawResult
- type Ruleset
- type RulesetRule
- type RulesetRuleActionParameters
- type RulesetRuleActionParametersFromValue
- type RulesetRuleActionParametersTargetURL
- type UniversalSSLSetting
- type UpdateDNSRecordParams
- type UpdateEntrypointRulesetParams
- type WorkerRoute
- type WorkerRoutesResponse
- type Zone
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccountIdentifier ¶
AccountIdentifier returns the account ID unchanged.
func ZoneIdentifier ¶
ZoneIdentifier returns the zone ID unchanged.
Types ¶
type API ¶
type API struct {
APIEmail string
// contains filtered or unexported fields
}
API is a Cloudflare API client.
func NewWithAPIToken ¶
NewWithAPIToken creates an API that authenticates with a token.
func (*API) CreateDNSRecord ¶
func (a *API) CreateDNSRecord(ctx context.Context, zone string, params CreateDNSRecordParams) (DNSRecord, error)
CreateDNSRecord creates a DNS record.
func (*API) CreateWorkerRoute ¶
func (a *API) CreateWorkerRoute(ctx context.Context, zone string, params CreateWorkerRouteParams) (WorkerRoute, error)
CreateWorkerRoute creates a Worker route.
func (*API) CreateZone ¶
func (a *API) CreateZone(ctx context.Context, name string, jumpStart bool, account Account, zoneType string) (Zone, error)
CreateZone creates a zone.
func (*API) DeleteDNSRecord ¶
DeleteDNSRecord deletes a DNS record.
func (*API) DeleteRulesetRule ¶
func (a *API) DeleteRulesetRule(ctx context.Context, zone string, params DeleteRulesetRuleParams) error
DeleteRulesetRule deletes a rule from a ruleset.
func (*API) DeleteWorkerRoute ¶
DeleteWorkerRoute deletes a Worker route.
func (*API) EditUniversalSSLSetting ¶
func (a *API) EditUniversalSSLSetting(ctx context.Context, zone string, setting UniversalSSLSetting) (UniversalSSLSetting, error)
EditUniversalSSLSetting updates a zone's Universal SSL setting.
func (*API) GetEntrypointRuleset ¶
GetEntrypointRuleset returns a zone's entrypoint ruleset for a phase.
func (*API) ListDNSRecords ¶
func (a *API) ListDNSRecords(ctx context.Context, zone string, _ ListDNSRecordsParams) ([]DNSRecord, any, error)
ListDNSRecords returns all DNS records in a zone.
func (*API) ListWorkerRoutes ¶
func (a *API) ListWorkerRoutes(ctx context.Context, zone string, _ ListWorkerRoutesParams) (WorkerRoutesResponse, error)
ListWorkerRoutes returns a zone's Worker routes.
func (*API) UniversalSSLSettingDetails ¶
func (a *API) UniversalSSLSettingDetails(ctx context.Context, zone string) (UniversalSSLSetting, error)
UniversalSSLSettingDetails returns a zone's Universal SSL setting.
func (*API) UpdateDNSRecord ¶
func (a *API) UpdateDNSRecord(ctx context.Context, zone string, params UpdateDNSRecordParams) (DNSRecord, error)
UpdateDNSRecord updates a DNS record.
func (*API) UpdateEntrypointRuleset ¶
func (a *API) UpdateEntrypointRuleset(ctx context.Context, zone string, params UpdateEntrypointRulesetParams) (Ruleset, error)
UpdateEntrypointRuleset replaces a zone's entrypoint ruleset for a phase.
func (*API) UploadWorker ¶
func (a *API) UploadWorker(ctx context.Context, account string, params CreateWorkerParams) (any, error)
UploadWorker uploads a Worker script.
type CreateDNSRecordParams ¶
type CreateDNSRecordParams DNSRecord
CreateDNSRecordParams is the request body for creating a DNS record.
type CreateWorkerParams ¶
CreateWorkerParams is the parameters for uploading a Worker script.
type CreateWorkerRouteParams ¶
type CreateWorkerRouteParams struct {
Pattern string `json:"pattern"`
Script string `json:"script,omitempty"`
}
CreateWorkerRouteParams is the request body for creating a Worker route.
type DNSRecord ¶
type DNSRecord struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Content string `json:"content,omitempty"`
Meta any `json:"meta,omitempty"`
Data any `json:"data,omitempty"`
Priority *uint16 `json:"priority,omitempty"`
TTL int `json:"ttl,omitempty"`
Proxied *bool `json:"proxied,omitempty"`
Proxiable bool `json:"proxiable,omitempty"`
Comment string `json:"comment,omitempty"`
Tags []string `json:"tags,omitempty"`
Settings DNSRecordSettings `json:"settings"`
}
DNSRecord is a Cloudflare DNS record.
type DNSRecordSettings ¶
type DNSRecordSettings struct {
FlattenCNAME *bool `json:"flatten_cname,omitempty"`
}
DNSRecordSettings holds per-record settings.
type DeleteRulesetRuleParams ¶
DeleteRulesetRuleParams identifies a ruleset rule to delete.
type ListDNSRecordsParams ¶
type ListDNSRecordsParams struct{}
ListDNSRecordsParams is the parameters for listing DNS records.
type ListWorkerRoutesParams ¶
type ListWorkerRoutesParams struct{}
ListWorkerRoutesParams is the parameters for listing Worker routes.
type NotFoundError ¶
type NotFoundError struct{ Err error }
NotFoundError indicates the requested resource does not exist.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
func (*NotFoundError) Unwrap ¶
func (e *NotFoundError) Unwrap() error
type Option ¶
Option configures an API.
func UsingRetryPolicy ¶
UsingRetryPolicy sets the maximum number of retries.
type RawResult ¶
type RawResult struct {
Success bool `json:"success"`
Errors json.RawMessage `json:"errors"`
}
RawResult is the status portion of an API response.
type Ruleset ¶
type Ruleset struct {
ID string `json:"id,omitempty"`
Rules []RulesetRule `json:"rules"`
}
Ruleset is a Cloudflare ruleset.
type RulesetRule ¶
type RulesetRule struct {
ID string `json:"id,omitempty"`
Action string `json:"action"`
Description string `json:"description,omitempty"`
Expression string `json:"expression"`
ActionParameters *RulesetRuleActionParameters `json:"action_parameters,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Ref string `json:"ref,omitempty"`
}
RulesetRule is a rule within a Ruleset.
type RulesetRuleActionParameters ¶
type RulesetRuleActionParameters struct {
FromValue *RulesetRuleActionParametersFromValue `json:"from_value,omitempty"`
}
RulesetRuleActionParameters holds a rule's action parameters.
type RulesetRuleActionParametersFromValue ¶
type RulesetRuleActionParametersFromValue struct {
StatusCode uint16 `json:"status_code,omitempty"`
TargetURL RulesetRuleActionParametersTargetURL `json:"target_url"`
PreserveQueryString *bool `json:"preserve_query_string,omitempty"`
}
RulesetRuleActionParametersFromValue holds redirect action parameters.
type RulesetRuleActionParametersTargetURL ¶
type RulesetRuleActionParametersTargetURL struct {
Expression string `json:"expression,omitempty"`
}
RulesetRuleActionParametersTargetURL is a redirect's target URL.
type UniversalSSLSetting ¶
type UniversalSSLSetting struct {
Enabled bool `json:"enabled"`
}
UniversalSSLSetting is a zone's Universal SSL setting.
type UpdateDNSRecordParams ¶
type UpdateDNSRecordParams struct {
ID string `json:"-"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Content string `json:"content,omitempty"`
Data any `json:"data,omitempty"`
Priority *uint16 `json:"priority,omitempty"`
TTL int `json:"ttl,omitempty"`
Proxied *bool `json:"proxied,omitempty"`
Comment *string `json:"comment,omitempty"`
Tags []string `json:"tags"`
Settings DNSRecordSettings `json:"settings"`
}
UpdateDNSRecordParams is the request body for updating a DNS record.
type UpdateEntrypointRulesetParams ¶
type UpdateEntrypointRulesetParams struct {
Phase string `json:"-"`
Rules []RulesetRule `json:"rules"`
}
UpdateEntrypointRulesetParams is the request body for updating an entrypoint ruleset.
type WorkerRoute ¶
type WorkerRoute struct {
ID string `json:"id,omitempty"`
Pattern string `json:"pattern"`
ScriptName string `json:"script,omitempty"`
}
WorkerRoute is a Cloudflare Worker route.
type WorkerRoutesResponse ¶
type WorkerRoutesResponse struct{ Routes []WorkerRoute }
WorkerRoutesResponse is a list of Worker routes.