rate_limits

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin

This is an alias to an internal value.

View Source
const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare

This is an alias to an internal value.

View Source
const AuditLogActorTypeUser = shared.AuditLogActorTypeUser

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector

This is an alias to an internal value.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASN added in v2.1.0

type ASN = shared.ASN

This is an alias to an internal type.

type ASNParam added in v2.1.0

type ASNParam = shared.ASNParam

This is an alias to an internal type.

type Action

type Action string

The action to apply to a matched request. The `log` action is only available on an Enterprise plan.

const (
	ActionBlock            Action = "block"
	ActionChallenge        Action = "challenge"
	ActionJSChallenge      Action = "js_challenge"
	ActionManagedChallenge Action = "managed_challenge"
	ActionAllow            Action = "allow"
	ActionLog              Action = "log"
	ActionBypass           Action = "bypass"
)

func (Action) IsKnown

func (r Action) IsKnown() bool

type AuditLog

type AuditLog = shared.AuditLog

This is an alias to an internal type.

type AuditLogAction

type AuditLogAction = shared.AuditLogAction

This is an alias to an internal type.

type AuditLogActor

type AuditLogActor = shared.AuditLogActor

This is an alias to an internal type.

type AuditLogActorType

type AuditLogActorType = shared.AuditLogActorType

The type of actor, whether a User, Cloudflare Admin, or an Automated System.

This is an alias to an internal type.

type AuditLogOwner

type AuditLogOwner = shared.AuditLogOwner

This is an alias to an internal type.

type AuditLogResource

type AuditLogResource = shared.AuditLogResource

This is an alias to an internal type.

type CloudflareTunnel

type CloudflareTunnel = shared.CloudflareTunnel

A Cloudflare Tunnel that connects your origin to Cloudflare's edge.

This is an alias to an internal type.

type CloudflareTunnelConnection

type CloudflareTunnelConnection = shared.CloudflareTunnelConnection

This is an alias to an internal type.

type CloudflareTunnelTunType

type CloudflareTunnelTunType = shared.CloudflareTunnelTunType

The type of tunnel.

This is an alias to an internal type.

type Error

type Error = apierror.Error

type ErrorData

type ErrorData = shared.ErrorData

This is an alias to an internal type.

type Member added in v2.1.0

type Member = shared.Member

This is an alias to an internal type.

type MemberParam added in v2.1.0

type MemberParam = shared.MemberParam

This is an alias to an internal type.

type MemberRole added in v2.1.0

type MemberRole = shared.MemberRole

This is an alias to an internal type.

type MemberRoleParam added in v2.1.0

type MemberRoleParam = shared.MemberRoleParam

This is an alias to an internal type.

type MemberRolesPermissions added in v2.1.0

type MemberRolesPermissions = shared.MemberRolesPermissions

This is an alias to an internal type.

type MemberRolesPermissionsParam added in v2.1.0

type MemberRolesPermissionsParam = shared.MemberRolesPermissionsParam

This is an alias to an internal type.

type MemberUser added in v2.1.0

type MemberUser = shared.MemberUser

This is an alias to an internal type.

type MemberUserParam added in v2.1.0

type MemberUserParam = shared.MemberUserParam

This is an alias to an internal type.

type Methods

type Methods string

An HTTP method or `_ALL_` to indicate all methods.

const (
	MethodsGet    Methods = "GET"
	MethodsPost   Methods = "POST"
	MethodsPut    Methods = "PUT"
	MethodsDelete Methods = "DELETE"
	MethodsPatch  Methods = "PATCH"
	MethodsHead   Methods = "HEAD"
	Methods_All   Methods = "_ALL_"
)

func (Methods) IsKnown

func (r Methods) IsKnown() bool

type Permission

type Permission = shared.Permission

This is an alias to an internal type.

type PermissionGrant

type PermissionGrant = shared.PermissionGrant

This is an alias to an internal type.

type PermissionGrantParam

type PermissionGrantParam = shared.PermissionGrantParam

This is an alias to an internal type.

type RateLimit

type RateLimit struct {
	// The unique identifier of the rate limit.
	ID string `json:"id"`
	// The action to perform when the threshold of matched traffic within the
	// configured period is exceeded.
	Action RateLimitAction `json:"action"`
	// Criteria specifying when the current rate limit should be bypassed. You can
	// specify that the rate limit should not apply to one or more URLs.
	Bypass []RateLimitBypass `json:"bypass"`
	// An informative summary of the rate limit. This value is sanitized and any tags
	// will be removed.
	Description string `json:"description"`
	// When true, indicates that the rate limit is currently disabled.
	Disabled bool `json:"disabled"`
	// Determines which traffic the rate limit counts towards the threshold.
	Match RateLimitMatch `json:"match"`
	// The time in seconds (an integer value) to count matching traffic. If the count
	// exceeds the configured threshold within this period, Cloudflare will perform the
	// configured action.
	Period float64 `json:"period"`
	// The threshold that will trigger the configured mitigation action. Configure this
	// value along with the `period` property to establish a threshold per period.
	Threshold float64       `json:"threshold"`
	JSON      rateLimitJSON `json:"-"`
}

func (*RateLimit) UnmarshalJSON

func (r *RateLimit) UnmarshalJSON(data []byte) (err error)

type RateLimitAction

type RateLimitAction struct {
	// The action to perform.
	Mode RateLimitActionMode `json:"mode"`
	// A custom content type and reponse to return when the threshold is exceeded. The
	// custom response configured in this object will override the custom error for the
	// zone. This object is optional. Notes: If you omit this object, Cloudflare will
	// use the default HTML error page. If "mode" is "challenge", "managed_challenge",
	// or "js_challenge", Cloudflare will use the zone challenge pages and you should
	// not provide the "response" object.
	Response RateLimitActionResponse `json:"response"`
	// The time in seconds during which Cloudflare will perform the mitigation action.
	// Must be an integer value greater than or equal to the period. Notes: If "mode"
	// is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the
	// zone's Challenge Passage time and you should not provide this value.
	Timeout float64             `json:"timeout"`
	JSON    rateLimitActionJSON `json:"-"`
}

The action to perform when the threshold of matched traffic within the configured period is exceeded.

func (*RateLimitAction) UnmarshalJSON

func (r *RateLimitAction) UnmarshalJSON(data []byte) (err error)

type RateLimitActionMode

type RateLimitActionMode string

The action to perform.

const (
	RateLimitActionModeSimulate         RateLimitActionMode = "simulate"
	RateLimitActionModeBan              RateLimitActionMode = "ban"
	RateLimitActionModeChallenge        RateLimitActionMode = "challenge"
	RateLimitActionModeJSChallenge      RateLimitActionMode = "js_challenge"
	RateLimitActionModeManagedChallenge RateLimitActionMode = "managed_challenge"
)

func (RateLimitActionMode) IsKnown

func (r RateLimitActionMode) IsKnown() bool

type RateLimitActionResponse

type RateLimitActionResponse struct {
	// The response body to return. The value must conform to the configured content
	// type.
	Body string `json:"body"`
	// The content type of the body. Must be one of the following: `text/plain`,
	// `text/xml`, or `application/json`.
	ContentType string                      `json:"content_type"`
	JSON        rateLimitActionResponseJSON `json:"-"`
}

A custom content type and reponse to return when the threshold is exceeded. The custom response configured in this object will override the custom error for the zone. This object is optional. Notes: If you omit this object, Cloudflare will use the default HTML error page. If "mode" is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the zone challenge pages and you should not provide the "response" object.

func (*RateLimitActionResponse) UnmarshalJSON

func (r *RateLimitActionResponse) UnmarshalJSON(data []byte) (err error)

type RateLimitBypass

type RateLimitBypass struct {
	Name RateLimitBypassName `json:"name"`
	// The URL to bypass.
	Value string              `json:"value"`
	JSON  rateLimitBypassJSON `json:"-"`
}

func (*RateLimitBypass) UnmarshalJSON

func (r *RateLimitBypass) UnmarshalJSON(data []byte) (err error)

type RateLimitBypassName

type RateLimitBypassName string
const (
	RateLimitBypassNameURL RateLimitBypassName = "url"
)

func (RateLimitBypassName) IsKnown

func (r RateLimitBypassName) IsKnown() bool

type RateLimitDeleteParams

type RateLimitDeleteParams struct {
	Body interface{} `json:"body,required"`
}

func (RateLimitDeleteParams) MarshalJSON

func (r RateLimitDeleteParams) MarshalJSON() (data []byte, err error)

type RateLimitDeleteResponse

type RateLimitDeleteResponse struct {
	// The unique identifier of the rate limit.
	ID   string                      `json:"id"`
	JSON rateLimitDeleteResponseJSON `json:"-"`
}

func (*RateLimitDeleteResponse) UnmarshalJSON

func (r *RateLimitDeleteResponse) UnmarshalJSON(data []byte) (err error)

type RateLimitDeleteResponseEnvelope

type RateLimitDeleteResponseEnvelope struct {
	Errors   []shared.ResponseInfo   `json:"errors,required"`
	Messages []shared.ResponseInfo   `json:"messages,required"`
	Result   RateLimitDeleteResponse `json:"result,required"`
	// Whether the API call was successful
	Success RateLimitDeleteResponseEnvelopeSuccess `json:"success,required"`
	JSON    rateLimitDeleteResponseEnvelopeJSON    `json:"-"`
}

func (*RateLimitDeleteResponseEnvelope) UnmarshalJSON

func (r *RateLimitDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error)

type RateLimitDeleteResponseEnvelopeSuccess

type RateLimitDeleteResponseEnvelopeSuccess bool

Whether the API call was successful

const (
	RateLimitDeleteResponseEnvelopeSuccessTrue RateLimitDeleteResponseEnvelopeSuccess = true
)

func (RateLimitDeleteResponseEnvelopeSuccess) IsKnown

type RateLimitEditParams

type RateLimitEditParams struct {
	Body interface{} `json:"body,required"`
}

func (RateLimitEditParams) MarshalJSON

func (r RateLimitEditParams) MarshalJSON() (data []byte, err error)

type RateLimitEditResponseEnvelope

type RateLimitEditResponseEnvelope struct {
	Errors   []shared.ResponseInfo      `json:"errors,required"`
	Messages []shared.ResponseInfo      `json:"messages,required"`
	Result   RateLimitEditResponseUnion `json:"result,required"`
	// Whether the API call was successful
	Success RateLimitEditResponseEnvelopeSuccess `json:"success,required"`
	JSON    rateLimitEditResponseEnvelopeJSON    `json:"-"`
}

func (*RateLimitEditResponseEnvelope) UnmarshalJSON

func (r *RateLimitEditResponseEnvelope) UnmarshalJSON(data []byte) (err error)

type RateLimitEditResponseEnvelopeSuccess

type RateLimitEditResponseEnvelopeSuccess bool

Whether the API call was successful

const (
	RateLimitEditResponseEnvelopeSuccessTrue RateLimitEditResponseEnvelopeSuccess = true
)

func (RateLimitEditResponseEnvelopeSuccess) IsKnown

type RateLimitEditResponseUnion

type RateLimitEditResponseUnion interface {
	ImplementsRateLimitsRateLimitEditResponseUnion()
}

Union satisfied by rate_limits.RateLimitEditResponseUnknown or shared.UnionString.

type RateLimitGetResponseEnvelope

type RateLimitGetResponseEnvelope struct {
	Errors   []shared.ResponseInfo     `json:"errors,required"`
	Messages []shared.ResponseInfo     `json:"messages,required"`
	Result   RateLimitGetResponseUnion `json:"result,required"`
	// Whether the API call was successful
	Success RateLimitGetResponseEnvelopeSuccess `json:"success,required"`
	JSON    rateLimitGetResponseEnvelopeJSON    `json:"-"`
}

func (*RateLimitGetResponseEnvelope) UnmarshalJSON

func (r *RateLimitGetResponseEnvelope) UnmarshalJSON(data []byte) (err error)

type RateLimitGetResponseEnvelopeSuccess

type RateLimitGetResponseEnvelopeSuccess bool

Whether the API call was successful

const (
	RateLimitGetResponseEnvelopeSuccessTrue RateLimitGetResponseEnvelopeSuccess = true
)

func (RateLimitGetResponseEnvelopeSuccess) IsKnown

type RateLimitGetResponseUnion

type RateLimitGetResponseUnion interface {
	ImplementsRateLimitsRateLimitGetResponseUnion()
}

Union satisfied by rate_limits.RateLimitGetResponseUnknown or shared.UnionString.

type RateLimitListParams

type RateLimitListParams struct {
	// The page number of paginated results.
	Page param.Field[float64] `query:"page"`
	// The maximum number of results per page. You can only set the value to `1` or to
	// a multiple of 5 such as `5`, `10`, `15`, or `20`.
	PerPage param.Field[float64] `query:"per_page"`
}

func (RateLimitListParams) URLQuery

func (r RateLimitListParams) URLQuery() (v url.Values)

URLQuery serializes RateLimitListParams's query parameters as `url.Values`.

type RateLimitMatch

type RateLimitMatch struct {
	Headers  []RateLimitMatchHeader `json:"headers"`
	Request  RateLimitMatchRequest  `json:"request"`
	Response RateLimitMatchResponse `json:"response"`
	JSON     rateLimitMatchJSON     `json:"-"`
}

Determines which traffic the rate limit counts towards the threshold.

func (*RateLimitMatch) UnmarshalJSON

func (r *RateLimitMatch) UnmarshalJSON(data []byte) (err error)

type RateLimitMatchHeader

type RateLimitMatchHeader struct {
	// The name of the response header to match.
	Name string `json:"name"`
	// The operator used when matching: `eq` means "equal" and `ne` means "not equal".
	Op RateLimitMatchHeadersOp `json:"op"`
	// The value of the response header, which must match exactly.
	Value string                   `json:"value"`
	JSON  rateLimitMatchHeaderJSON `json:"-"`
}

func (*RateLimitMatchHeader) UnmarshalJSON

func (r *RateLimitMatchHeader) UnmarshalJSON(data []byte) (err error)

type RateLimitMatchHeadersOp

type RateLimitMatchHeadersOp string

The operator used when matching: `eq` means "equal" and `ne` means "not equal".

const (
	RateLimitMatchHeadersOpEq RateLimitMatchHeadersOp = "eq"
	RateLimitMatchHeadersOpNe RateLimitMatchHeadersOp = "ne"
)

func (RateLimitMatchHeadersOp) IsKnown

func (r RateLimitMatchHeadersOp) IsKnown() bool

type RateLimitMatchRequest

type RateLimitMatchRequest struct {
	// The HTTP methods to match. You can specify a subset (for example,
	// `['POST','PUT']`) or all methods (`['_ALL_']`). This field is optional when
	// creating a rate limit.
	Methods []Methods `json:"methods"`
	// The HTTP schemes to match. You can specify one scheme (`['HTTPS']`), both
	// schemes (`['HTTP','HTTPS']`), or all schemes (`['_ALL_']`). This field is
	// optional.
	Schemes []string `json:"schemes"`
	// The URL pattern to match, composed of a host and a path such as
	// `example.org/path*`. Normalization is applied before the pattern is matched. `*`
	// wildcards are expanded to match applicable traffic. Query strings are not
	// matched. Set the value to `*` to match all traffic to your zone.
	URL  string                    `json:"url"`
	JSON rateLimitMatchRequestJSON `json:"-"`
}

func (*RateLimitMatchRequest) UnmarshalJSON

func (r *RateLimitMatchRequest) UnmarshalJSON(data []byte) (err error)

type RateLimitMatchResponse

type RateLimitMatchResponse struct {
	// When true, only the uncached traffic served from your origin servers will count
	// towards rate limiting. In this case, any cached traffic served by Cloudflare
	// will not count towards rate limiting. This field is optional. Notes: This field
	// is deprecated. Instead, use response headers and set "origin_traffic" to "false"
	// to avoid legacy behaviour interacting with the "response_headers" property.
	OriginTraffic bool                       `json:"origin_traffic"`
	JSON          rateLimitMatchResponseJSON `json:"-"`
}

func (*RateLimitMatchResponse) UnmarshalJSON

func (r *RateLimitMatchResponse) UnmarshalJSON(data []byte) (err error)

type RateLimitNewParams

type RateLimitNewParams struct {
	Body interface{} `json:"body,required"`
}

func (RateLimitNewParams) MarshalJSON

func (r RateLimitNewParams) MarshalJSON() (data []byte, err error)

type RateLimitNewResponseEnvelope

type RateLimitNewResponseEnvelope struct {
	Errors   []shared.ResponseInfo     `json:"errors,required"`
	Messages []shared.ResponseInfo     `json:"messages,required"`
	Result   RateLimitNewResponseUnion `json:"result,required"`
	// Whether the API call was successful
	Success RateLimitNewResponseEnvelopeSuccess `json:"success,required"`
	JSON    rateLimitNewResponseEnvelopeJSON    `json:"-"`
}

func (*RateLimitNewResponseEnvelope) UnmarshalJSON

func (r *RateLimitNewResponseEnvelope) UnmarshalJSON(data []byte) (err error)

type RateLimitNewResponseEnvelopeSuccess

type RateLimitNewResponseEnvelopeSuccess bool

Whether the API call was successful

const (
	RateLimitNewResponseEnvelopeSuccessTrue RateLimitNewResponseEnvelopeSuccess = true
)

func (RateLimitNewResponseEnvelopeSuccess) IsKnown

type RateLimitNewResponseUnion

type RateLimitNewResponseUnion interface {
	ImplementsRateLimitsRateLimitNewResponseUnion()
}

Union satisfied by rate_limits.RateLimitNewResponseUnknown or shared.UnionString.

type RateLimitService

type RateLimitService struct {
	Options []option.RequestOption
}

RateLimitService contains methods and other services that help with interacting with the cloudflare API. Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewRateLimitService method instead.

func NewRateLimitService

func NewRateLimitService(opts ...option.RequestOption) (r *RateLimitService)

NewRateLimitService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*RateLimitService) Delete

func (r *RateLimitService) Delete(ctx context.Context, zoneIdentifier string, id string, body RateLimitDeleteParams, opts ...option.RequestOption) (res *RateLimitDeleteResponse, err error)

Deletes an existing rate limit.

func (*RateLimitService) Edit

func (r *RateLimitService) Edit(ctx context.Context, zoneIdentifier string, id string, body RateLimitEditParams, opts ...option.RequestOption) (res *RateLimitEditResponseUnion, err error)

Updates an existing rate limit.

func (*RateLimitService) Get

func (r *RateLimitService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *RateLimitGetResponseUnion, err error)

Fetches the details of a rate limit.

func (*RateLimitService) List

Fetches the rate limits for a zone.

func (*RateLimitService) ListAutoPaging

Fetches the rate limits for a zone.

func (*RateLimitService) New

func (r *RateLimitService) New(ctx context.Context, zoneIdentifier string, body RateLimitNewParams, opts ...option.RequestOption) (res *RateLimitNewResponseUnion, err error)

Creates a new rate limit for a zone. Refer to the object definition for a list of required attributes.

type ResponseInfo

type ResponseInfo = shared.ResponseInfo

This is an alias to an internal type.

type Role

type Role = shared.Role

This is an alias to an internal type.

Jump to

Keyboard shortcuts

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