throttles

package
v0.0.0-...-e794f14 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(client *golangsdk.ServiceClient, instanceId string, opts ListOptsBuilder) pagination.Pager

List is a method to obtain an array of one or more throttling policies according to the query parameters.

func ListSpecThrottles

func ListSpecThrottles(client *golangsdk.ServiceClient, instanceId, policyId string,
	opts SpecThrottlesListOptsBuilder) pagination.Pager

ListSpecThrottles is a method to obtain an array of one or more special throttling policies according to the query parameters.

func Unbind

func Unbind(c *golangsdk.ServiceClient, instanceId, bindId string) error

Unbind is a method to cancel the relationship between API and throttling policy.

Types

type ApiForThrottle

type ApiForThrottle struct {
	// API authentication method.
	AuthType string `json:"auth_type"`
	// Group name to which the API belongs.
	GroupName string `json:"group_name"`
	// API publish record ID.
	PublishId string `json:"publish_id"`
	// The number of the binding relationship with the throttling policy.
	ThrottleApplyId string `json:"throttle_apply_id"`
	// Binding time of the bound throttling policy.
	ApplyTime string `json:"apply_time"`
	// API description.
	Remark string `json:"remark"`
	// The ID of the environment published by the API.
	RunEnvId string `json:"run_env_id"`
	// API type
	Type int `json:"type"`
	// Binding throttling policy name.
	ThrottleName string `json:"throttle_name"`
	// Request URI of the API.
	ReqUri string `json:"req_uri"`
	// The name of the environment published by the API.
	RunEnvName string `json:"run_env_name"`
	// Group ID to which the API belogns.
	GroupId string `json:"group_id"`
	// API Name.
	Name string `json:"name"`
	// API ID.
	ID string `json:"id"`
}

func ListBind

ListBind is a method to obtain all API to which the throttling policy bound.

type BatchResp

type BatchResp struct {
	// Number of API and throttling policy bindings that have been successfully unbound.
	SuccessCount int `json:"success_count"`
	// Unbinding failed API and throttling policy binding relationship and error information.
	Failure []UnbindResult `json:"failure"`
}

func BatchUnbind

func BatchUnbind(c *golangsdk.ServiceClient, unbindOpt BatchUnbindOpts,
	queryOpt BatchUnbindActionOpts) (*BatchResp, error)

BatchUnbind is an API to unbind all throttling policies associated with the list.

type BatchUnbindActionOpts

type BatchUnbindActionOpts struct {
	// List of API and throttling policy binding relationship IDs that need to be unbound.
	Action string `q:"action"`
}

type BatchUnbindOpts

type BatchUnbindOpts struct {
	// List of API and throttling policy binding relationship IDs that need to be unbound.
	ThrottleBindings string `json:"throttle_bindings,omitempty"`
	// Instance ID.
	InstanceId string `json:"-" required:"true"`
}

type BindOpts

type BindOpts struct {
	// Throttle policy ID. The valid length is range from 1 to 65.
	ThrottleId string `json:"strategy_id" required:"true"`
	// The IDs of the API publish record.
	PublishIds []string `json:"publish_ids" required:"true"`
	// Instnace ID to which the API belongs.
	InstanceId string `json:"-" required:"true"`
}

type BindResp

type BindResp struct {
	// The ID of the binding relationship.
	ID string `json:"id"`
	// The publish ID.
	PublishId string `json:"publish_id"`
	// Policy scope, the values are as follows:
	// 1: The entire API
	// 2: single user
	// 3: Single APP
	// Currently only 1 is supported.
	Scope int `json:"scope"`
	// Throttling policy ID
	StrategyId string `json:"strategy_id"`
	// Apply time.
	ApplyTime string `json:"apply_time"`
}

func Bind

func Bind(c *golangsdk.ServiceClient, opts BindOpts) ([]BindResp, error)

Bind is a method to bind the policy to one or more APIs.

type CreateResult

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

CreateResult represents a result of the Create method.

func Create

func Create(client *golangsdk.ServiceClient, instanceId string, opts ThrottlingPolicyOptsBuilder) (r CreateResult)

Create is a method by which to create function that create a new throttling policy.

func (CreateResult) Extract

func (r CreateResult) Extract() (*ThrottlingPolicy, error)

type CreateSpecThrottleResult

type CreateSpecThrottleResult struct {
	SpecThrottleResult
}

The CreateSpecThrottleResult represents the result of the CreateSpecThrottle method.

type DeleteResult

type DeleteResult struct {
	golangsdk.ErrResult
}

func Delete

func Delete(client *golangsdk.ServiceClient, instanceId, policyId string) (r DeleteResult)

Delete is a method to delete an existing throttling policy.

func DeleteSpecThrottle

func DeleteSpecThrottle(client *golangsdk.ServiceClient, instanceId, policyId, strategyId string) (r DeleteResult)

DeleteSpecThrottle is a method to delete an existing special throttling policy.

type GetResult

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

GetResult represents a result of the Get method.

func Get

func Get(client *golangsdk.ServiceClient, instanceId, policyId string) (r GetResult)

Get is a method to obtain an existing APIG throttling policy by policy ID.

func (GetResult) Extract

func (r GetResult) Extract() (*ThrottlingPolicy, error)

type ListBindOpts

type ListBindOpts struct {
	// Offset from which the query starts.
	// If the offset is less than 0, the value is automatically converted to 0. Default to 0.
	Offset int `q:"offset"`
	// Number of items displayed on each page. The valid values are range form 1 to 500, default to 20.
	Limit int `q:"limit"`
	// throttling policy ID.
	ThrottleId string `q:"throttle_id"`
	// Environment ID.
	EnvId string `q:"env_id"`
	// API group ID.
	GroupId string `q:"group_id"`
	// API ID.
	ApiId string `q:"api_id"`
	// API name.
	ApiName string `q:"api_name"`
	// Instnace ID to which the API belongs.
	InstanceId string `json:"-"`
}

type ListOpts

type ListOpts struct {
	// Request throttling policy ID.
	Id string `q:"id"`
	// Request throttling policy name.
	Name string `q:"name"`
	// Offset from which the query starts.
	// If the offset is less than 0, the value is automatically converted to 0. Default to 0.
	Offset int `q:"offset"`
	// Number of items displayed on each page. The valid values are range form 1 to 500, default to 20.
	Limit int `q:"limit"`
	// Parameter name (name) for exact matching.
	PreciseSearch string `q:"precise_search"`
}

func (ListOpts) ToListQuery

func (opts ListOpts) ToListQuery() (string, error)

type ListOptsBuilder

type ListOptsBuilder interface {
	ToListQuery() (string, error)
}

type SpecThrottle

type SpecThrottle struct {
	// Maximum number of times the excluded object can access an API within the throttling period.
	CallLimits int `json:"call_limits"`
	// Name of the app to which the excluded request throttling configuration applies.
	AppName string `json:"app_name"`
	// Name of an app or a tenant to which the excluded request throttling configuration applies.
	ObjectName string `json:"object_name"`
	// ID of an object specified in the excluded request throttling configuration.
	ObjectId string `json:"object_id"`
	// Request throttling policy ID.
	ThrottleId string `json:"throttle_id"`
	// Time when the excluded request throttling configuration is created.
	ApplyTime string `json:"apply_time"`
	// Excluded request throttling configuration ID.
	ID string `json:"id"`
	// ID of the app to which the excluded request throttling configuration applies.
	AppId string `json:"app_id"`
	// Excluded object type, which can be APP or USER.
	ObjectType string `json:"object_type"`
}

SpecThrottle is a struct that represents the result of CreateSpecThrottle, UpdateSpecThrottle and ListSpecThrottles methods.

func ExtractSpecThrottles

func ExtractSpecThrottles(r pagination.Page) ([]SpecThrottle, error)

ExtractSpecThrottles its Extract method to interpret it as a special throttling policy array.

type SpecThrottleCreateOpts

type SpecThrottleCreateOpts struct {
	// Maximum number of times the excluded object can access an API within the throttling period.
	CallLimits int `json:"call_limits" required:"true"`
	// Excluded app ID or excluded account ID.
	ObjectId string `json:"object_id" required:"true"`
	// Excluded object type, which supports APP and USER.
	ObjectType string `json:"object_type" required:"true"`
}

SpecThrottleCreateOpts is a struct which will be used to create a new special throttling policy.

func (SpecThrottleCreateOpts) ToSpecThrottleCreateOptsMap

func (opts SpecThrottleCreateOpts) ToSpecThrottleCreateOptsMap() (map[string]interface{}, error)

ToSpecThrottleCreateOptsMap is a method which to build a request body by the SpecThrottleCreateOpts.

type SpecThrottleCreateOptsBuilder

type SpecThrottleCreateOptsBuilder interface {
	ToSpecThrottleCreateOptsMap() (map[string]interface{}, error)
}

SpecThrottleCreateOptsBuilder is an interface which to support request body build of the special throttling policy creation.

type SpecThrottlePage

type SpecThrottlePage struct {
	pagination.SinglePageBase
}

The SpecThrottlePage represents the result of a List operation.

type SpecThrottleResult

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

The SpecThrottleResult represents the base result of the each special throttling polciy methods.

func CreateSpecThrottle

func CreateSpecThrottle(client *golangsdk.ServiceClient, instanceId, policyId string,
	opts SpecThrottleCreateOptsBuilder) (r SpecThrottleResult)

CreateSpecThrottle is a method by which to create a new special throttling policy.

func UpdateSpecThrottle

func UpdateSpecThrottle(client *golangsdk.ServiceClient, instanceId, policyId, strategyId string,
	opts SpecThrottleUpdateOptsBuilder) (r SpecThrottleResult)

UpdateSpecThrottle is a method by which to update an existing special throttle policy.

func (SpecThrottleResult) Extract

func (r SpecThrottleResult) Extract() (*SpecThrottle, error)

Extract is a method which to extract the response to a special throttling policy.

type SpecThrottleUpdateOpts

type SpecThrottleUpdateOpts struct {
	// Maximum number of times the excluded object can access an API within the throttling period.
	CallLimits int `json:"call_limits" required:"true"`
}

SpecThrottleUpdateOpts is a struct which will be used to update an existing special throttling policy.

func (SpecThrottleUpdateOpts) ToSpecThrottleUpdateOptsMap

func (opts SpecThrottleUpdateOpts) ToSpecThrottleUpdateOptsMap() (map[string]interface{}, error)

ToSpecThrottleUpdateOptsMap is a method which to build a request body by the SpecThrottleUpdateOpts.

type SpecThrottleUpdateOptsBuilder

type SpecThrottleUpdateOptsBuilder interface {
	ToSpecThrottleUpdateOptsMap() (map[string]interface{}, error)
}

SpecThrottleUpdateOptsBuilder is an interface which to support request body build of the special throttling policy updation.

type SpecThrottlesListOpts

type SpecThrottlesListOpts struct {
	// Object type, which can be APP or USER.
	ObjectType string `q:"object_type"`
	// Name of an excluded app.
	AppName string `q:"app_name"`
	// Offset from which the query starts.
	// If the offset is less than 0, the value is automatically converted to 0. Default to 0.
	Offset int `q:"offset"`
	// Number of items displayed on each page. The valid values are range form 1 to 500, default to 20.
	Limit int `q:"limit"`
}

SpecThrottlesListOpts allows to filter list data using given parameters.

func (SpecThrottlesListOpts) ToSpecThrottlesListQuery

func (opts SpecThrottlesListOpts) ToSpecThrottlesListQuery() (string, error)

ToSpecThrottlesListQuery is a method which to build a request query by the SpecThrottlesListOpts.

type SpecThrottlesListOptsBuilder

type SpecThrottlesListOptsBuilder interface {
	ToSpecThrottlesListQuery() (string, error)
}

SpecThrottlesListOptsBuilder is an interface which to support request query build of the special throttling policies search.

type ThorttlePage

type ThorttlePage struct {
	pagination.SinglePageBase
}

The ThorttlePage represents the result of a List operation.

type ThrottlingPolicy

type ThrottlingPolicy struct {
	// Number of APIs to which the request throttling policy has been bound.
	BindNum int `json:"bind_num"`
	// Indicates whether an excluded request throttling configuration has been created.
	// 1: yes
	// 2: no
	IsIncludeSpecialThrottle int `json:"is_inclu_special_throttle"`
	// Creation time.
	CreateTime string `json:"create_time"`
	// Description.
	Description string `json:"remark"`
	// Type of the request throttling policy.
	// 1: exclusive, limiting the maximum number of times a single API bound to the policy can be called within
	// the specified period.
	// 2: shared, limiting the maximum number of times all APIs bound to the policy can be called within the
	// specified period.
	Type int `json:"type"`
	// Period of time for limiting the number of API calls.
	TimeInterval int `json:"time_interval"`
	// Maximum number of times the API can be accessed by an IP address within the same period.
	IpCallLimits int `json:"ip_call_limits"`
	// Maximum number of times the API can be accessed by an app within the same period.
	AppCallLimits int `json:"app_call_limits"`
	// Request throttling policy name.
	Name string `json:"name"`
	// Time unit for limiting the number of API calls.
	// The valid values are as following:
	//     SECOND
	//     MINUTE
	//     HOUR
	//     DAY
	TimeUnit string `json:"time_unit"`
	// Maximum number of times an API can be accessed within a specified period.
	ApiCallLimits int `json:"api_call_limits"`
	// Request throttling policy ID.
	Id string `json:"id"`
	// Maximum number of times the API can be accessed by a user within the same period.
	UserCallLimits int `json:"user_call_limits"`
}

func ExtractPolicies

func ExtractPolicies(r pagination.Page) ([]ThrottlingPolicy, error)

ExtractPolicies its Extract method to interpret it as a throttling policy array.

type ThrottlingPolicyOpts

type ThrottlingPolicyOpts struct {
	// Maximum number of times an API can be accessed within a specified period.
	// The value of this parameter cannot exceed the default limit 200 TPS.
	// This value must be a positive integer and cannot exceed 2,147,483,647.
	ApiCallLimits int `json:"api_call_limits" required:"true"`
	// Request throttling policy name, which can contain 3 to 64 characters, starting with a letter.
	// Only letters, digits, and underscores (_) are allowed.
	// Chinese characters must be in UTF-8 or Unicode format.
	Name string `json:"name" required:"true"`
	// Period of time for limiting the number of API calls.
	// This parameter applies with each of the preceding three API call limits.
	// This value must be a positive integer and cannot exceed 2,147,483,647.
	TimeInterval int `json:"time_interval" required:"true"`
	// Time unit for limiting the number of API calls.
	// The valid values are as following:
	//     SECOND
	//     MINUTE
	//     HOUR
	//     DAY
	TimeUnit string `json:"time_unit" required:"true"`
	// Maximum number of times the API can be accessed by an app within the same period.
	// The value of this parameter must be less than that of user_call_limits.
	// This value must be a positive integer and cannot exceed 2,147,483,647.
	AppCallLimits int `json:"app_call_limits,omitempty"`
	// Description of the request throttling policy, which can contain a maximum of 255 characters.
	// Chinese characters must be in UTF-8 or Unicode format.
	Description string `json:"remark,omitempty"`
	// Type of the request throttling policy.
	// 1: exclusive, limiting the maximum number of times a single API bound to the policy can be called within
	// the specified period.
	// 2: shared, limiting the maximum number of times all APIs bound to the policy can be called within the
	// specified period.
	Type int `json:"type,omitempty"`
	// Maximum number of times the API can be accessed by a user within the same period.
	// The value of this parameter must be less than that of api_call_limits.
	// This value must be a positive integer and cannot exceed 2,147,483,647.
	UserCallLimits int `json:"user_call_limits,omitempty"`
	// Maximum number of times the API can be accessed by an IP address within the same period.
	// The value of this parameter must be less than that of api_call_limits.
	// This value must be a positive integer and cannot exceed 2,147,483,647.
	IpCallLimits int `json:"ip_call_limits,omitempty"`
}

func (ThrottlingPolicyOpts) ToThrottlingPolicyOptsMap

func (opts ThrottlingPolicyOpts) ToThrottlingPolicyOptsMap() (map[string]interface{}, error)

type ThrottlingPolicyOptsBuilder

type ThrottlingPolicyOptsBuilder interface {
	ToThrottlingPolicyOptsMap() (map[string]interface{}, error)
}

type UnbindResult

type UnbindResult struct {
	// API and throttling policy binding relationship ID that failed to unbind.
	BindId string `json:"bind_id"`
	// Unbind failed error code
	ErrorCode string `json:"error_code"`
	// Unbind failed error message
	ErrorMsg string `json:"error_msg"`
	// ID of the API that failed to unbind
	ApiId string `json:"api_id"`
	// The name of the API that failed to unbind
	ApiName string `json:"api_name"`
}

type UpdateResult

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

UpdateResult represents a result of the Update method.

func Update

func Update(client *golangsdk.ServiceClient, instanceId, policyId string,
	opts ThrottlingPolicyOptsBuilder) (r UpdateResult)

Update is a method by which to udpate an existing throttle policy.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*ThrottlingPolicy, error)

type UpdateSpecThrottleResult

type UpdateSpecThrottleResult struct {
	SpecThrottleResult
}

The UpdateSpecThrottleResult represents the result of the UpdateSpecThrottle method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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