rate

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddRateRuleParams

type AddRateRuleParams struct {
	AccountNumber string
	RateRule      RateRule
}

AddRateRuleParams -

func NewAddRateRuleParams

func NewAddRateRuleParams() AddRateRuleParams

type Client

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

Client is the Rate Rules client.

func (Client) AddRateRule

func (c Client) AddRateRule(
	params AddRateRuleParams,
) (string, error)

AddRateRule creates a rate rule for the provided account number and returns the new rule's system-generated ID

func (Client) DeleteRateRule

func (c Client) DeleteRateRule(
	params DeleteRateRuleParams,
) error

DeleteRateRuleByID deletes a rate rule for the provided account numnber and Rate Rule ID

func (Client) GetAllRateRules

func (c Client) GetAllRateRules(
	params GetAllRateRulesParams,
) (*[]RateRuleGetAllOK, error)

GetAllRateRules retrives all of the Rate Rules for the provided account number.

func (Client) GetRateRule

func (c Client) GetRateRule(
	params GetRateRuleParams,
) (*RateRuleGetOK, error)

GetRateRule retrieves a rate rule for the provided account number and Rate Rule ID

func (Client) UpdateRateRule

func (c Client) UpdateRateRule(
	params UpdateRateRuleParams,
) error

UpdateRateRule updates a rate rule for the provided account number using the provided Rate Rule ID and Rate Rule properties.

type ClientService

type ClientService interface {
	AddRateRule(
		params AddRateRuleParams,
	) (string, error)

	GetRateRule(
		params GetRateRuleParams,
	) (*RateRuleGetOK, error)

	UpdateRateRule(
		params UpdateRateRuleParams,
	) error

	DeleteRateRule(
		params DeleteRateRuleParams,
	) error

	GetAllRateRules(
		params GetAllRateRulesParams,
	) (*[]RateRuleGetAllOK, error)
}

ClientService is the interface for Client methods.

func New

func New(c ecclient.APIClient, baseAPIURL string) ClientService

New creates a new instance of the Rate Rule Client Service

type Condition

type Condition struct {
	/*
		Describes the type for this match condition
	*/
	Target Target `json:"target"`

	/*
		Describes this match condition in detail
	*/
	OP OP `json:"op"`
}

Condition to be associated with a Rate Rule

type ConditionGroup

type ConditionGroup struct {
	/*
		Contains the list of match conditions for this condition group.
	*/
	Conditions []Condition `json:"conditions"`

	/*
		Indicates the system-defined alphanumeric ID of this condition group.

		Note: This is a read-only field that will be ignored by AddRateRule and
		UpdateRateRule

		Example: 12345678-90ab-cdef-ghij-klmnopqrstuvwxyz1
	*/
	ID string `json:"id,omitempty"`

	/*
		Indicates the name of this condition group
	*/
	Name string `json:"name,omitempty"`
}

ConditionGroup describes a set of conditions to be associated with a rule

func (ConditionGroup) MarshalJSON

func (cg ConditionGroup) MarshalJSON() ([]byte, error)

MarshalJSON marshals a ConditionGroup to JSON bytes while excluding read-only fields

type DeleteRateRuleParams

type DeleteRateRuleParams struct {
	AccountNumber string
	RateRuleID    string
}

DeleteRateRuleParams

func NewDeleteRateRuleParams

func NewDeleteRateRuleParams() DeleteRateRuleParams

type GetAllRateRulesParams

type GetAllRateRulesParams struct {
	AccountNumber string
}

GetAllRateRulesParams -

type GetRateRuleParams

type GetRateRuleParams struct {
	AccountNumber string
	RateRuleID    string
}

GetRateRuleParams -

func NewGetRateRuleParams

func NewGetRateRuleParams() GetRateRuleParams

type OP

type OP struct {
	/*
		Indicates whether the comparison between the request
		and the Values property is case-sensitive.
	*/
	IsCaseInsensitive *bool `json:"is_case_insensitive,omitempty"`

	/*
		Indicates whether this match condition will be satisfied when
		the request matches or does not match the value defined by the Values
		property.
	*/
	IsNegated *bool `json:"is_negated,omitempty"`

	/*
		Indicates how the system will interpret the comparison between the
		request and the Values property.

		Valid values are:
			EM | IPMATCH | RX

		EM: Requires that the request attribute be set to one of the value(s)
		defined in the Values property.

		IPMATCH: Requires that the request IP address either be contained by an
		IP block or be an exact match to an IP address defined in the Values
		property.

		RX: Requires that the request attribute be an exact match to the regular
		expression defined in the value property.
	*/
	Type string `json:"type"`

	/*
		Identifies a regular expression used to identify requests that are
		eligible for rate limiting.

		Note: valid only if Type is RX
	*/
	Value string `json:"value,omitempty"`

	/*
		Identifies one or more values used to identify requests that are
		eligible for rate limiting.

		Note: Valid only if Type is EM or IPMATCH
	*/
	Values []string `json:"values,omitempty"`
}

OP describes a match condition in detail

type RateRule

type RateRule struct {
	/*
		Contains the set of condition groups for this rate rule
	*/
	ConditionGroups []ConditionGroup `json:"condition_groups"`

	/*
		Identifies your account by its customer account number.
	*/
	CustomerID string `json:"customer_id"`

	/*
		Indicates whether this rate rule will be enforced.
	*/
	Disabled bool `json:"disabled"`

	/*
		Indicates the length, in seconds, of the rolling window that
		tracks the number of requests eligible for rate limiting.

		The rate limit formula is calculated through the Num and DurationSec
		properties as indicated below.
			Num requests per DurationSec
		Valid values are:
			1 | 5 | 10 | 30 | 60 | 120 | 300
	*/
	DurationSec int `json:"duration_sec"`

	/*
		Indicates the method by requests will be grouped for the purposes of
		this rate rule.

		Valid values are:
			[empty array] | IP | USER_AGENT

		Missing / Empty Array: If the keys property is not defined or set to an
		empty array, all requests will be treated as a single group for the
		purpose of rate limiting.

		IP: Indicates that requests will be grouped by IP address.
		Each unique IP address is considered a separate group.

		USER_AGENT: Indicates that requests will be grouped by a client's user
		agent. Each unique combination of IP address and user agent is
		considered a separate group.
	*/
	Keys []string `json:"keys,omitempty"`

	// Indicates the name of the rate rule.
	Name string `json:"name,omitempty"`

	/*
		Indicates the rate limit value. This value identifies the number of
		requests that will trigger rate limiting.

		The rate limit formula is calculated through the Num and DurationSec
		properties as indicated below.
			Num requests per DurationSec
	*/
	Num int `json:"num"`
}

RateRule contains the rules properties for the Create, Get, Update models for a single Rate Rule

type RateRuleAddOK

type RateRuleAddOK struct {
	rules.AddRuleResponse
}

RateRuleAddOK -

type RateRuleGetAllOK

type RateRuleGetAllOK struct {
	RateRule

	/*
	   Indicates the system-defined ID for the rate rule.
	*/
	ID string `json:"id"`

	/*
		Indicates the timestamp at which the rate rule was last modified.

		Syntax:
			YYYY-MM-DDThh:mm:ss:ffffffZ
	*/
	LastModifiedDate string `json:"last_modified_date"`

	// Indicates the name of the rate rule.
	Name string `json:"name,omitempty"`
}

RateRuleGetAllOK is a lightweight representation of a Rate Rule used specifically by GetAllRateRules

type RateRuleGetOK

type RateRuleGetOK struct {
	RateRule

	/*
	   Indicates the system-defined ID for the rate rule.
	*/
	ID string `json:"id"`

	/*
		Indicates the timestamp at which the rate rule was last modified.

		Syntax:
			YYYY-MM-DDThh:mm:ss:ffffffZ
	*/
	LastModifiedDate string `json:"last_modified_date"`

	/*
		A string value that is reserved for future use.
	*/
	LastModifiedBy string `json:"last_modified_by,omitempty"`

	/*
		A string value that is reserved for future use.
	*/
	Version string `json:"version,omitempty"`
}

RateRuleGetOK -

type Target

type Target struct {
	/*
		Determines how requests will be identified.

		Valid values are:
			FILE_EXT | REMOTE_ADDR |  REQUEST_HEADERS | REQUEST_METHOD |
			REQUEST_URI
	*/
	Type string `json:"type"`

	/*
		Indicates the name of the request header through which requests will be
		identified.

		Valid values are:
			Host | Referer | User-Agent

		Note: Required if Type is REQUEST_HEADERS
	*/
	Value string `json:"value,omitempty"`
}

Target describes the type of a match condition

type UpdateRateRuleParams

type UpdateRateRuleParams struct {
	AccountNumber string
	RateRuleID    string
	RateRule      RateRule
}

UpdateRateRuleParams -

func NewUpdateRateRuleParams

func NewUpdateRateRuleParams() UpdateRateRuleParams

Jump to

Keyboard shortcuts

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