cfapi

package
v1.76.10 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cfapi is the real client of Cloudflare's API for the minter: an account reached with a token, over plain net/http against https://api.cloudflare.com/client/v4. Everything else speaks minter.API.

It is not cloudflare-go. The minter makes five calls on one resource (an account's tokens), and the SDK's root client wires every Cloudflare service at init: importing it put about 64 MB into the Lambda bootstrap, past the 100 MiB unzipped limit deploy/pulumi enforces. The five calls are small enough to speak directly.

A token's policies and condition are carried as the JSON Cloudflare sent, so a clone copies them exactly and depends on no SDK's types.

Index

Constants

View Source
const BaseURL = "https://api.cloudflare.com/client/v4/"

BaseURL is Cloudflare's API.

Variables

This section is empty.

Functions

func Dial

func Dial(opts ...Option) minter.Dialer

Dial opens an account with a token. Options are for tests (a base URL).

Types

type Client

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

Client is one account.

func (*Client) CreateToken

func (c *Client) CreateToken(ctx context.Context, in cloudflare.NewToken) (cloudflare.Created, error)

CreateToken implements minter.API.

func (*Client) DeleteToken

func (c *Client) DeleteToken(ctx context.Context, id string) error

DeleteToken implements minter.API.

func (*Client) GetToken

func (c *Client) GetToken(ctx context.Context, id string) (cloudflare.Token, error)

GetToken implements minter.API.

func (*Client) ListTokens

func (c *Client) ListTokens(ctx context.Context) ([]cloudflare.Token, error)

ListTokens implements minter.API: every page, the recently expired included.

func (*Client) PermissionGroups

func (c *Client) PermissionGroups(ctx context.Context) (map[string]string, error)

PermissionGroups implements minter.API.

type Option

type Option func(*Client)

Option changes how Dial reaches Cloudflare; for tests.

func WithBaseURL

func WithBaseURL(base string) Option

WithBaseURL points the client at another server (a test's).

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient replaces the HTTP client.

Jump to

Keyboard shortcuts

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