dto

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveHealthcheckDto

type ActiveHealthcheckDto struct {
	// 默认是1
	Timeout int `json:"timeout,omitempty"`
	// 默认是10
	Concurrency int          `json:"concurrency,omitempty"`
	HttpPath    string       `json:"http_path,omitempty"`
	Healthy     HealthyDto   `json:"healthy,omitempty"`
	Unhealthy   UnhealthyDto `json:"unhealthy,omitempty"`
}

type ConsumerReqDto

type ConsumerReqDto struct {
	// 用户名,必填
	Username string `json:"username"`
	// 第三方唯一id,选填
	CustomId string `json:"custom_id,omitempty"`
}

func NewKongConsumerReqDto

func NewKongConsumerReqDto(name string, customId string) *ConsumerReqDto

func (ConsumerReqDto) IsEmpty

func (dto ConsumerReqDto) IsEmpty() bool

type ConsumerRespDto

type ConsumerRespDto struct {
	CustomId  string `json:"custom_id"`
	CreatedAt int64  `json:"created_at"`
	// consumerId
	Id string `json:"id"`
}

type CredentialDto

type CredentialDto struct {
	ConsumerId string `json:"consumer_id,omitempty"`
	CreatedAt  int64  `json:"created_at,omitempty"`
	Id         string `json:"id,omitempty"`
	// key-auth, sign-auth
	Key string `json:"key,omitempty"`
	// oauth2
	RedirectUrl interface{} `json:"redirect_uri,omitempty"`
	// v2
	RedirectUrls []string `json:"redirect_uris,omitempty"`
	Name         string   `json:"name,omitempty"`
	ClientId     string   `json:"client_id,omitempty"`
	ClientSecret string   `json:"client_secret,omitempty"`
	// sign-auth, hmac-auth
	Secret string `json:"secret,omitempty"`
	// hmac-auth
	Username string `json:"username,omitempty"`
}

func FromCredential

func FromCredential(cred *pb.Credential) CredentialDto

func (*CredentialDto) AdjustCreatedAt

func (dto *CredentialDto) AdjustCreatedAt()

func (*CredentialDto) Compatiable

func (dto *CredentialDto) Compatiable()

func (CredentialDto) ToCredential

func (dto CredentialDto) ToCredential() *pb.Credential

func (*CredentialDto) ToHmacReq

func (dto *CredentialDto) ToHmacReq()

func (*CredentialDto) ToHmacResp

func (dto *CredentialDto) ToHmacResp()

func (*CredentialDto) ToV2

func (dto *CredentialDto) ToV2()

type CredentialListDto

type CredentialListDto struct {
	Total int64           `json:"total"`
	Data  []CredentialDto `json:"data"`
}

type CredentialReqDto

type CredentialReqDto struct {
	// 消费者id,必填
	ConsumerId string `json:"consumer_id"`
	// 插件名称
	PluginName string `json:"plugin_name,omitempty"`
	// 其余选填配置
	Config *CredentialDto `json:"config,omitempty"`
}

func (CredentialReqDto) IsEmpty

func (dto CredentialReqDto) IsEmpty() bool

IsEmpty

type HealthchecksDto

type HealthchecksDto struct {
	Active  ActiveHealthcheckDto  `json:"active,omitempty"`
	Passive PassiveHealthcheckDto `json:"passive,omitempty"`
}

func NewHealthchecks

func NewHealthchecks(checkPath string) HealthchecksDto

type HealthyDto

type HealthyDto struct {
	// 默认是0 active下关闭探测
	Interval int `json:"interval,omitempty"`
	// active默认是[200, 302] passive默认是2xx,3xx
	HttpStatuses []int `json:"http_statuses,omitempty"`
	// 默认是0
	Successes int `json:"successes,omitempty"`
}

type KongObj

type KongObj struct {
	Id string `json:"id"`
}

type KongPluginsDto

type KongPluginsDto struct {
	Total int64           `json:"total"`
	Data  []PluginRespDto `json:"data"`
}

type KongRoutesRespDto

type KongRoutesRespDto struct {
	Routes []RouteRespDto `json:"data"`
}

type Option

type Option func(dto *RouteReqDto)

func Versioning

func Versioning(i interface{ GetVersion() (string, error) }) Option

type PassiveHealthcheckDto

type PassiveHealthcheckDto struct {
	Healthy   HealthyDto   `json:"healthy,omitempty"`
	Unhealthy UnhealthyDto `json:"unhealthy,omitempty"`
}

type PluginConfigsDto

type PluginConfigsDto struct {
	Configuration PluginNameConfiguration `json:"configuration"`
	Version       string                  `json:"version"`
}

type PluginNameConfiguration

type PluginNameConfiguration struct {
	Plugins []string `json:"plugins"`
}

type PluginReqDto

type PluginReqDto struct {
	// 插件名称,必填
	Name string `json:"name"`
	// 1、服务id
	ServiceId string `json:"service_id,omitempty"`
	// 2、路由id
	RouteId string `json:"route_id,omitempty"`
	// 3、消费者id
	ConsumerId string   `json:"consumer_id,omitempty"`
	Route      *KongObj `json:"route,omitempty"`
	Service    *KongObj `json:"service,omitempty"`
	Consumer   *KongObj `json:"consumer,omitempty"`
	// 是否开启,默认true
	Enabled *bool `json:"enabled,omitempty"`
	// 其余配置
	Config    map[string]interface{} `json:"config,omitempty"`
	Id        string                 `json:"id,omitempty"`
	CreatedAt int64                  `json:"created_at,omitempty"`
	// 插件id,删除或更新时使用
	PluginId string `json:"-"`

	ZoneName     string `json:"zone_name,omitempty"`
	MSERouteName string `json:"mse_route_name,omitempty"`
}

func (PluginReqDto) IsEmpty

func (dto PluginReqDto) IsEmpty() bool

IsEmpty

func (*PluginReqDto) ToV2

func (dto *PluginReqDto) ToV2()

ToV2

type PluginRespDto

type PluginRespDto struct {
	Id         string                 `json:"id"`
	ServiceId  string                 `json:"service_id"`
	RouteId    string                 `json:"route_id"`
	ConsumerId string                 `json:"consumer_id"`
	Route      *KongObj               `json:"route"`
	Service    *KongObj               `json:"service"`
	Consumer   *KongObj               `json:"consumer"`
	Name       string                 `json:"name"`
	Config     map[string]interface{} `json:"config"`
	Enabled    bool                   `json:"enabled"`
	CreatedAt  int64                  `json:"created_at"`
	PolicyId   string                 `json:"-"`
}

func (*PluginRespDto) Compatiable

func (dto *PluginRespDto) Compatiable()

type RouteReqDto

type RouteReqDto struct {
	// 协议列表,默认["http", "https"]
	Protocols []string `json:"protocols,omitempty"`
	// 以下三个参数至少需要填一个
	// 1、方法列表
	Methods []string `json:"methods,omitempty"`
	// 2、主机列表
	Hosts []string `json:"hosts,omitempty"`
	// 3、路径列表
	Paths []string `json:"paths,omitempty"`
	// 选填,当通过路径之一匹配路由时,从上游请求URL中去除匹配的前缀。
	StripPath *bool `json:"strip_path,omitempty"`
	// 选填,当通过主机域名中的一个匹配路由时,在上游请求报头中使用请求主机头。
	// 默认情况下设置为false,上游主机头将设置为服务的主机。
	PreserveHost *bool `json:"preserve_host,omitempty"`
	// 绑定服务,必填
	Service *Service `json:"service,omitempty"`
	// 正则匹配优先级,当前使用路径中/的个数
	RegexPriority int `json:"regex_priority,omitempty"`
	// 真正的路由id,更新时使用
	RouteId string `json:"-"`

	// Path handling algorithms.
	// "v0" is the behavior used in Kong 0.x and 2.x. It treats service.path,
	// route.path and request path as segments of a url. It will always join
	// them via slashes. Given a service path /s, route path /r and request
	// path /re, the concatenated path will be /s/re. If the resulting path
	// is a single slash, no further transformation is done to it. If it’s
	// longer, then the trailing slash is removed.
	//
	// "v1" is the behavior used in Kong 1.x. It treats service.path as a prefix,
	// and ignores the initial slashes of the request and route paths. Given service
	// path /s, route path /r and request path /re, the concatenated path will be /sre.
	//
	// See more https://docs.konghq.com/enterprise/2.2.x/admin-api/#path-handling-algorithms
	PathHandling *string `json:"path_handling,omitempty"`

	Tags []string `json:"tags,omitempty"`
	// contains filtered or unexported fields
}

func NewKongRouteReqDto

func NewKongRouteReqDto() *RouteReqDto

func (*RouteReqDto) AddTag

func (dto *RouteReqDto) AddTag(key, value string)

func (*RouteReqDto) Adjust

func (dto *RouteReqDto) Adjust(opts ...Option)

func (RouteReqDto) IsEmpty

func (dto RouteReqDto) IsEmpty() bool

IsEmpty

type RouteRespDto

type RouteRespDto struct {
	Id        string   `json:"id"`
	CreatedAt int64    `json:"created_at"`
	UpdatedAt int64    `json:"updated_at"`
	Protocols []string `json:"protocols"`
	Methods   []string `json:"methods"`
	Hosts     []string `json:"hosts"`
	Paths     []string `json:"paths"`
	Service   Service  `json:"service"`
}

type Service

type Service struct {
	// 绑定服务id,必填
	Id string `json:"id"`
}

type ServiceReqDto

type ServiceReqDto struct {
	// 服务名称,选填
	Name string `json:"name,omitempty"`
	// 具体路径,如果设置了这个可以不设下面4个
	Url string `json:"url,omitempty"`
	// 1、协议,默认http
	Protocol string `json:"protocol,omitempty"`
	// 2、主机,没设url则必传
	Host string `json:"host,omitempty"`
	// 3、端口,默认80
	Port int `json:"port,omitempty"`
	// 4、路径,默认null
	Path string `json:"path,omitempty"`
	// 选填,重试次数
	Retries *int `json:"retries,omitempty"`
	// 选填,连接超时时间
	ConnectTimeout int `json:"connect_timeout,omitempty"`
	// 选填,写超时时间
	WriteTimeout int `json:"write_timeout,omitempty"`
	// 选填,读超时时间
	ReadTimeout int `json:"read_timeout,omitempty"`
	// 真正的服务id,更新时使用
	ServiceId string `json:"-"`
}

func (ServiceReqDto) IsEmpty

func (dto ServiceReqDto) IsEmpty() bool

IsEmpty

type ServiceRespDto

type ServiceRespDto struct {
	Id        string `json:"id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
	Name      string `json:"name"`
	Protocol  string `json:"protocol"`
	Host      string `json:"host"`
	Port      int    `json:"port"`
	Path      string `json:"path"`
}

type TargetDto

type TargetDto struct {
	Id     string `json:"id,omitempty"`
	Target string `json:"target"`
	// 默认是100
	Weight     int64       `json:"weight,omitempty"`
	UpstreamId string      `json:"upstream_id,omitempty"`
	CreatedAt  json.Number `json:"created_at,omitempty"`
	Health     string      `json:"health,omitempty"`
}

func (TargetDto) GetCreatedAt

func (dto TargetDto) GetCreatedAt() int64

type UnhealthyDto

type UnhealthyDto struct {
	// 默认是0 active下关闭探测
	Interval int `json:"interval,omitempty"`
	// active默认是[429, 404, 500, 501, 502, 503, 504, 505] passive默认是[429, 500, 503]
	HttpStatuses []int `json:"http_statuses,omitempty"`
	// 默认是0
	HttpFailures int `json:"http_failures,omitempty"`
	// 默认是0
	TcpFailures int `json:"tcp_failures,omitempty"`
	// 默认是0
	Timeouts int `json:"timeouts,omitempty"`
}

type UpstreamDto

type UpstreamDto struct {
	Id           string          `json:"id,omitempty"`
	Name         string          `json:"name"`
	Healthchecks HealthchecksDto `json:"healthchecks"`
}

type UpstreamStatusRespDto

type UpstreamStatusRespDto struct {
	Data []TargetDto `json:"data"`
}

Jump to

Keyboard shortcuts

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