Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- type ClientOption
- type Error
- type Request
- func (r *Request) AccountPrefix(account string) *Request
- func (r *Request) Body(body interface{}) *Request
- func (r *Request) Do(ctx context.Context) RequestResult
- func (r *Request) Header(key string, values ...string) *Request
- func (r *Request) Param(params interface{}) *Request
- func (r *Request) PathPrefix(prefix string) *Request
- func (r *Request) Resource(resource string) *Request
- func (r *Request) ResourceID(id string) *Request
- func (r *Request) SubPath(path string) *Request
- func (r *Request) URL() *url.URL
- func (r *Request) Verb(verb string) *Request
- func (r *Request) ZonePrefix(zone string) *Request
- type RequestResult
- type Response
- type ResultInfo
- type ResultInfoCursors
- type ServiceKeyTransport
- type Tunnel
- type TunnelClient
- type TunnelCredentials
- type TunnelDNSRoute
- type TunnelLBRoute
- type TunnelListOptions
- type TunnelRoute
- type Zone
- type ZoneClient
Constants ¶
View Source
const ( DefaultBaseURL = "https://api.cloudflare.com/client/v4" APITokenEnv = "CF_API_TOKEN" )
Variables ¶
View Source
var ( ErrNotFound = errors.New("not found") ErrUnexpectedMultipleTunnel = errors.New("unexpected have multiple tunnel with same name") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { AccountID() string ZoneID() string Tunnels() TunnelClient Zones() ZoneClient }
func NewClient ¶
func NewClient(opts ...ClientOption) (Client, error)
type ClientOption ¶
type ClientOption func(c *client) error
func WithAPIToken ¶
func WithAPIToken(token string) ClientOption
WithAPIToken use oauth2 client with given token as static token source
NOTE: When used, this option should be called before any options to avoid overwrite existing http.Client
func WithLogger ¶
func WithLogger(logger logr.Logger) ClientOption
func WithOriginCert ¶
func WithOriginCert(origincert []byte) ClientOption
WithOriginCert use origincert to populate accountID and zoneID. This options also wrap the http.DefaultTransport to inject X-Auth-User-Service-Key header
type Error ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
func NewRequest(c *client) *Request
func (*Request) AccountPrefix ¶
func (*Request) PathPrefix ¶
func (*Request) ResourceID ¶
func (*Request) URL ¶
URL build url from given r. url.Path will constructed as following:
/{basePath}/{pathPrefix}/{resourceName}/{resourceID}/{subPath}
where are:
- basePath = `/client/v4`
- pathPrefix = could be `/accounts/{account_id}` or `/zones/{zone_id}` (optional)
- resourceName = cloudflare resources endpoint name eg: `/tunnels`
- resourceID = cloudflare resource id `/:uuid` (optional)
- subPath = cloudflare sub resource endpoint eg: `/routes`
beside path, this function also construct url.Query from given r.params
func (*Request) ZonePrefix ¶
type RequestResult ¶
type RequestResult struct {
// contains filtered or unexported fields
}
func (RequestResult) Error ¶
func (r RequestResult) Error() error
func (RequestResult) Into ¶
func (r RequestResult) Into(o interface{}) error
func (RequestResult) Raw ¶
func (r RequestResult) Raw() ([]byte, error)
func (RequestResult) StatusCode ¶
func (r RequestResult) StatusCode() int
type Response ¶
type Response struct { Success bool `json:"success,omitempty"` Errors []Error `json:"errors,omitempty"` Messages []string `json:"messages,omitempty"` Result json.RawMessage `json:"result,omitempty"` ResultInfo ResultInfo `json:"result_info,omitempty"` }
type ResultInfo ¶
type ResultInfoCursors ¶
type ServiceKeyTransport ¶
type ServiceKeyTransport struct { Base http.RoundTripper ServiceKey string }
type TunnelClient ¶
type TunnelClient interface { Get(ctx context.Context, tunnelID uuid.UUID) (*Tunnel, error) GetByName(ctx context.Context, name string) (*Tunnel, error) List(ctx context.Context, opts *TunnelListOptions) ([]*Tunnel, error) Create(ctx context.Context, name string) (*Tunnel, error) Delete(ctx context.Context, tunnelID uuid.UUID) error Route(ctx context.Context, tunnelID uuid.UUID, route TunnelRoute) error }
type TunnelCredentials ¶
type TunnelDNSRoute ¶
func (*TunnelDNSRoute) MarshalJSON ¶
func (r *TunnelDNSRoute) MarshalJSON() ([]byte, error)
func (*TunnelDNSRoute) Type ¶
func (r *TunnelDNSRoute) Type() string
type TunnelLBRoute ¶
func (*TunnelLBRoute) MarshalJSON ¶
func (r *TunnelLBRoute) MarshalJSON() ([]byte, error)
func (*TunnelLBRoute) Type ¶
func (r *TunnelLBRoute) Type() string
type TunnelListOptions ¶
type TunnelRoute ¶
Click to show internal directories.
Click to hide internal directories.