Documentation
¶
Index ¶
- func APIError(err error) error
- func IsNotFound(err error) bool
- func ListAccounts(ctx context.Context, c *cloudflare.Client) ([]accounts.Account, error)
- func Messages(err error) string
- func NewClient(token string) *cloudflare.Client
- func ResolveZone(ctx context.Context, app *App, nameOrID string) (*zones.Zone, error)
- func StatusCode(err error) int
- func ValidateToken(ctx context.Context, token string) (*user.TokenVerifyResponse, error)
- type App
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIError ¶
APIError turns an SDK error into a short "HTTP 403: message" error. Request headers (and so the token) are never included.
func ListAccounts ¶
ListAccounts returns every account the token can see (GET /accounts).
func NewClient ¶
func NewClient(token string) *cloudflare.Client
NewClient builds a Cloudflare SDK client that authenticates with token.
The SDK also reads CLOUDFLARE_API_KEY / CLOUDFLARE_EMAIL from the environment; those headers are stripped so only the bearer token is used.
func ResolveZone ¶
ResolveZone accepts a zone name (example.com) or a 32-char zone ID and returns the zone.
func StatusCode ¶
StatusCode returns the HTTP status of a Cloudflare API error, or 0.
func ValidateToken ¶
ValidateToken checks a token via GET /user/tokens/verify.
Types ¶
type App ¶
type App struct {
Client *cloudflare.Client
AccountID string
}
App holds the authenticated Cloudflare client and resolved account ID.