rate_limits

package
v2.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error = apierror.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   []RateLimitDeleteResponseEnvelopeErrors   `json:"errors,required"`
	Messages []RateLimitDeleteResponseEnvelopeMessages `json:"messages,required"`
	Result   RateLimitDeleteResponse                   `json:"result,required,nullable"`
	// 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 RateLimitDeleteResponseEnvelopeErrors

type RateLimitDeleteResponseEnvelopeErrors struct {
	Code    int64                                     `json:"code,required"`
	Message string                                    `json:"message,required"`
	JSON    rateLimitDeleteResponseEnvelopeErrorsJSON `json:"-"`
}

func (*RateLimitDeleteResponseEnvelopeErrors) UnmarshalJSON

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

type RateLimitDeleteResponseEnvelopeMessages

type RateLimitDeleteResponseEnvelopeMessages struct {
	Code    int64                                       `json:"code,required"`
	Message string                                      `json:"message,required"`
	JSON    rateLimitDeleteResponseEnvelopeMessagesJSON `json:"-"`
}

func (*RateLimitDeleteResponseEnvelopeMessages) UnmarshalJSON

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

type RateLimitDeleteResponseEnvelopeSuccess

type RateLimitDeleteResponseEnvelopeSuccess bool

Whether the API call was successful

const (
	RateLimitDeleteResponseEnvelopeSuccessTrue RateLimitDeleteResponseEnvelopeSuccess = true
)

type RateLimitEditParams

type RateLimitEditParams struct {
	Body param.Field[interface{}] `json:"body,required"`
}

func (RateLimitEditParams) MarshalJSON

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

type RateLimitEditResponse

type RateLimitEditResponse interface {
	ImplementsRateLimitsRateLimitEditResponse()
}

Union satisfied by rate_limits.RateLimitEditResponseUnknown or shared.UnionString.

type RateLimitEditResponseEnvelope

type RateLimitEditResponseEnvelope struct {
	Errors   []RateLimitEditResponseEnvelopeErrors   `json:"errors,required"`
	Messages []RateLimitEditResponseEnvelopeMessages `json:"messages,required"`
	Result   RateLimitEditResponse                   `json:"result,required,nullable"`
	// 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 RateLimitEditResponseEnvelopeErrors

type RateLimitEditResponseEnvelopeErrors struct {
	Code    int64                                   `json:"code,required"`
	Message string                                  `json:"message,required"`
	JSON    rateLimitEditResponseEnvelopeErrorsJSON `json:"-"`
}

func (*RateLimitEditResponseEnvelopeErrors) UnmarshalJSON

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

type RateLimitEditResponseEnvelopeMessages

type RateLimitEditResponseEnvelopeMessages struct {
	Code    int64                                     `json:"code,required"`
	Message string                                    `json:"message,required"`
	JSON    rateLimitEditResponseEnvelopeMessagesJSON `json:"-"`
}

func (*RateLimitEditResponseEnvelopeMessages) UnmarshalJSON

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

type RateLimitEditResponseEnvelopeSuccess

type RateLimitEditResponseEnvelopeSuccess bool

Whether the API call was successful

const (
	RateLimitEditResponseEnvelopeSuccessTrue RateLimitEditResponseEnvelopeSuccess = true
)

type RateLimitGetResponse

type RateLimitGetResponse interface {
	ImplementsRateLimitsRateLimitGetResponse()
}

Union satisfied by rate_limits.RateLimitGetResponseUnknown or shared.UnionString.

type RateLimitGetResponseEnvelope

type RateLimitGetResponseEnvelope struct {
	Errors   []RateLimitGetResponseEnvelopeErrors   `json:"errors,required"`
	Messages []RateLimitGetResponseEnvelopeMessages `json:"messages,required"`
	Result   RateLimitGetResponse                   `json:"result,required,nullable"`
	// 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 RateLimitGetResponseEnvelopeErrors

type RateLimitGetResponseEnvelopeErrors struct {
	Code    int64                                  `json:"code,required"`
	Message string                                 `json:"message,required"`
	JSON    rateLimitGetResponseEnvelopeErrorsJSON `json:"-"`
}

func (*RateLimitGetResponseEnvelopeErrors) UnmarshalJSON

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

type RateLimitGetResponseEnvelopeMessages

type RateLimitGetResponseEnvelopeMessages struct {
	Code    int64                                    `json:"code,required"`
	Message string                                   `json:"message,required"`
	JSON    rateLimitGetResponseEnvelopeMessagesJSON `json:"-"`
}

func (*RateLimitGetResponseEnvelopeMessages) UnmarshalJSON

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

type RateLimitGetResponseEnvelopeSuccess

type RateLimitGetResponseEnvelopeSuccess bool

Whether the API call was successful

const (
	RateLimitGetResponseEnvelopeSuccessTrue RateLimitGetResponseEnvelopeSuccess = true
)

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 RateLimitListResponse

type RateLimitListResponse 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 RateLimitListResponseAction `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 []RateLimitListResponseBypass `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 RateLimitListResponseMatch `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      rateLimitListResponseJSON `json:"-"`
}

func (*RateLimitListResponse) UnmarshalJSON

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

type RateLimitListResponseAction

type RateLimitListResponseAction struct {
	// The action to perform.
	Mode RateLimitListResponseActionMode `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 RateLimitListResponseActionResponse `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    rateLimitListResponseActionJSON `json:"-"`
}

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

func (*RateLimitListResponseAction) UnmarshalJSON

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

type RateLimitListResponseActionMode

type RateLimitListResponseActionMode string

The action to perform.

const (
	RateLimitListResponseActionModeSimulate         RateLimitListResponseActionMode = "simulate"
	RateLimitListResponseActionModeBan              RateLimitListResponseActionMode = "ban"
	RateLimitListResponseActionModeChallenge        RateLimitListResponseActionMode = "challenge"
	RateLimitListResponseActionModeJsChallenge      RateLimitListResponseActionMode = "js_challenge"
	RateLimitListResponseActionModeManagedChallenge RateLimitListResponseActionMode = "managed_challenge"
)

type RateLimitListResponseActionResponse

type RateLimitListResponseActionResponse 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        rateLimitListResponseActionResponseJSON `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 (*RateLimitListResponseActionResponse) UnmarshalJSON

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

type RateLimitListResponseBypass

type RateLimitListResponseBypass struct {
	Name RateLimitListResponseBypassName `json:"name"`
	// The URL to bypass.
	Value string                          `json:"value"`
	JSON  rateLimitListResponseBypassJSON `json:"-"`
}

func (*RateLimitListResponseBypass) UnmarshalJSON

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

type RateLimitListResponseBypassName

type RateLimitListResponseBypassName string
const (
	RateLimitListResponseBypassNameURL RateLimitListResponseBypassName = "url"
)

type RateLimitListResponseMatch

type RateLimitListResponseMatch struct {
	Headers  []RateLimitListResponseMatchHeader `json:"headers"`
	Request  RateLimitListResponseMatchRequest  `json:"request"`
	Response RateLimitListResponseMatchResponse `json:"response"`
	JSON     rateLimitListResponseMatchJSON     `json:"-"`
}

Determines which traffic the rate limit counts towards the threshold.

func (*RateLimitListResponseMatch) UnmarshalJSON

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

type RateLimitListResponseMatchHeader

type RateLimitListResponseMatchHeader 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 RateLimitListResponseMatchHeadersOp `json:"op"`
	// The value of the response header, which must match exactly.
	Value string                               `json:"value"`
	JSON  rateLimitListResponseMatchHeaderJSON `json:"-"`
}

func (*RateLimitListResponseMatchHeader) UnmarshalJSON

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

type RateLimitListResponseMatchHeadersOp

type RateLimitListResponseMatchHeadersOp string

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

const (
	RateLimitListResponseMatchHeadersOpEq RateLimitListResponseMatchHeadersOp = "eq"
	RateLimitListResponseMatchHeadersOpNe RateLimitListResponseMatchHeadersOp = "ne"
)

type RateLimitListResponseMatchRequest

type RateLimitListResponseMatchRequest 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 []RateLimitListResponseMatchRequestMethod `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 rateLimitListResponseMatchRequestJSON `json:"-"`
}

func (*RateLimitListResponseMatchRequest) UnmarshalJSON

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

type RateLimitListResponseMatchRequestMethod

type RateLimitListResponseMatchRequestMethod string

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

const (
	RateLimitListResponseMatchRequestMethodGet    RateLimitListResponseMatchRequestMethod = "GET"
	RateLimitListResponseMatchRequestMethodPost   RateLimitListResponseMatchRequestMethod = "POST"
	RateLimitListResponseMatchRequestMethodPut    RateLimitListResponseMatchRequestMethod = "PUT"
	RateLimitListResponseMatchRequestMethodDelete RateLimitListResponseMatchRequestMethod = "DELETE"
	RateLimitListResponseMatchRequestMethodPatch  RateLimitListResponseMatchRequestMethod = "PATCH"
	RateLimitListResponseMatchRequestMethodHead   RateLimitListResponseMatchRequestMethod = "HEAD"
	RateLimitListResponseMatchRequestMethod_All   RateLimitListResponseMatchRequestMethod = "_ALL_"
)

type RateLimitListResponseMatchResponse

type RateLimitListResponseMatchResponse 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          rateLimitListResponseMatchResponseJSON `json:"-"`
}

func (*RateLimitListResponseMatchResponse) UnmarshalJSON

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

type RateLimitNewParams

type RateLimitNewParams struct {
	Body param.Field[interface{}] `json:"body,required"`
}

func (RateLimitNewParams) MarshalJSON

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

type RateLimitNewResponse

type RateLimitNewResponse interface {
	ImplementsRateLimitsRateLimitNewResponse()
}

Union satisfied by rate_limits.RateLimitNewResponseUnknown or shared.UnionString.

type RateLimitNewResponseEnvelope

type RateLimitNewResponseEnvelope struct {
	Errors   []RateLimitNewResponseEnvelopeErrors   `json:"errors,required"`
	Messages []RateLimitNewResponseEnvelopeMessages `json:"messages,required"`
	Result   RateLimitNewResponse                   `json:"result,required,nullable"`
	// 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 RateLimitNewResponseEnvelopeErrors

type RateLimitNewResponseEnvelopeErrors struct {
	Code    int64                                  `json:"code,required"`
	Message string                                 `json:"message,required"`
	JSON    rateLimitNewResponseEnvelopeErrorsJSON `json:"-"`
}

func (*RateLimitNewResponseEnvelopeErrors) UnmarshalJSON

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

type RateLimitNewResponseEnvelopeMessages

type RateLimitNewResponseEnvelopeMessages struct {
	Code    int64                                    `json:"code,required"`
	Message string                                   `json:"message,required"`
	JSON    rateLimitNewResponseEnvelopeMessagesJSON `json:"-"`
}

func (*RateLimitNewResponseEnvelopeMessages) UnmarshalJSON

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

type RateLimitNewResponseEnvelopeSuccess

type RateLimitNewResponseEnvelopeSuccess bool

Whether the API call was successful

const (
	RateLimitNewResponseEnvelopeSuccessTrue RateLimitNewResponseEnvelopeSuccess = true
)

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, 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 *RateLimitEditResponse, 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 *RateLimitGetResponse, 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 *RateLimitNewResponse, err error)

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

Jump to

Keyboard shortcuts

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