common

package
v0.2.22 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 19 Imported by: 9

Documentation

Index

Constants

View Source
const (
	JsonParseError         = "JSON_PARSE_FAILED"
	NetworkError           = "NETWORK_ERROR"
	CredentialMissingError = "CREDENTIAL_VALUE_MISSING"
	IoError                = "IO_ERROR"
)
View Source
const (
	POST = "POST"
	GET  = "GET"

	HTTP   = "http"
	HTTPS  = "https"
	DOMAIN = "console.zenlayer.com"
)
View Source
const SdkLang = "go"

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

func Float64

func Float64(v float64) *float64

func GetUrlQueriesEncoded

func GetUrlQueriesEncoded(params map[string]string) string

func InitStructWithDefaultTag

func InitStructWithDefaultTag(bean interface{})

func Int64

func Int64(v int64) *int64

func Integer

func Integer(v int) *int

func NewZenlayerCloudSdkError

func NewZenlayerCloudSdkError(code, message, requestId string) error

func ParseFromHttpResponse

func ParseFromHttpResponse(hr *http.Response, response Response) (err error)

func String

func String(v string) *string

func ToBool added in v0.2.4

func ToBool(v *bool) bool

func ToFloat64 added in v0.2.4

func ToFloat64(v *float64) float64

func ToInt64 added in v0.2.4

func ToInt64(v *int64) int64

func ToInteger added in v0.2.4

func ToInteger(v *int) int

func ToString added in v0.2.4

func ToString(v *string) string

func ToUint added in v0.2.4

func ToUint(v *uint) uint

func ToUint64 added in v0.2.4

func ToUint64(v *uint64) uint64

func Uint

func Uint(v uint) *uint

func Uint64

func Uint64(v uint64) *uint64

Types

type BaseRequest

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

func (*BaseRequest) GetAction

func (br *BaseRequest) GetAction() string

func (*BaseRequest) GetApiVersion

func (br *BaseRequest) GetApiVersion() string

func (*BaseRequest) GetAutoRetries

func (br *BaseRequest) GetAutoRetries() bool

func (*BaseRequest) GetBody

func (br *BaseRequest) GetBody() []byte

func (*BaseRequest) GetBodyReader

func (br *BaseRequest) GetBodyReader() io.Reader

func (*BaseRequest) GetBodyStr

func (br *BaseRequest) GetBodyStr() string

func (*BaseRequest) GetContentType

func (br *BaseRequest) GetContentType() string

func (*BaseRequest) GetDomain

func (br *BaseRequest) GetDomain() string

func (*BaseRequest) GetFormParams

func (br *BaseRequest) GetFormParams() map[string]string

func (*BaseRequest) GetHeaders

func (br *BaseRequest) GetHeaders() map[string]string

func (*BaseRequest) GetHttpMethod

func (br *BaseRequest) GetHttpMethod() string

func (*BaseRequest) GetMaxAttempts

func (br *BaseRequest) GetMaxAttempts() int

func (*BaseRequest) GetParams

func (br *BaseRequest) GetParams() map[string]string

func (*BaseRequest) GetPath

func (br *BaseRequest) GetPath() string

func (*BaseRequest) GetScheme

func (br *BaseRequest) GetScheme() string

func (*BaseRequest) GetServiceName

func (br *BaseRequest) GetServiceName() string

func (*BaseRequest) GetUrl

func (br *BaseRequest) GetUrl() string

func (*BaseRequest) Init

func (br *BaseRequest) Init() *BaseRequest

func (*BaseRequest) InitWithApiInfo

func (br *BaseRequest) InitWithApiInfo(serviceName, apiVersion, action string)

func (*BaseRequest) SetAutoRetries

func (br *BaseRequest) SetAutoRetries(autoRetires bool)

func (*BaseRequest) SetBody

func (br *BaseRequest) SetBody(body []byte)

func (*BaseRequest) SetContentType

func (br *BaseRequest) SetContentType(contentType string)

func (*BaseRequest) SetDomain

func (br *BaseRequest) SetDomain(domain string)

func (*BaseRequest) SetHeaders

func (br *BaseRequest) SetHeaders(headers map[string]string)

func (*BaseRequest) SetMaxAttempts

func (br *BaseRequest) SetMaxAttempts(maxAttempts int)

func (*BaseRequest) SetPath

func (br *BaseRequest) SetPath(path string)

func (*BaseRequest) SetScheme

func (br *BaseRequest) SetScheme(scheme string)

func (*BaseRequest) SetServiceName

func (br *BaseRequest) SetServiceName(serviceName string)

type BaseResponse

type BaseResponse struct {
}

func (*BaseResponse) ParseErrorResponse

func (r *BaseResponse) ParseErrorResponse(body []byte) (err error)

type Client

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

func (*Client) ApiCall

func (c *Client) ApiCall(request Request, response Response) (err error)

func (*Client) InitWithCredential

func (c *Client) InitWithCredential(credential *Credential) (err error)

func (*Client) WithConfig

func (c *Client) WithConfig(config *Config) error

func (*Client) WithRequestClient added in v0.1.3

func (c *Client) WithRequestClient(rc string) *Client

type Config

type Config struct {
	AutoRetry     bool `default:"false"`
	MaxRetryTime  int  `default:"3"`
	RetryDuration time.Duration
	HttpTransport *http.Transport   `default:""`
	Transport     http.RoundTripper `default:""`
	Proxy         string            `default:""`
	Scheme        string            `default:"HTTPS"`
	Domain        string            `default:""`
	// timeout in seconds
	Timeout int `default:"300"`
	Debug   *bool
}

func NewConfig

func NewConfig() (config *Config)

func (*Config) WithAutoRetry

func (c *Config) WithAutoRetry(isAutoRetry bool) *Config

func (*Config) WithHttpTransport

func (c *Config) WithHttpTransport(httpTransport *http.Transport) *Config

func (*Config) WithMaxRetryTime

func (c *Config) WithMaxRetryTime(maxRetryTime int) *Config

func (*Config) WithScheme

func (c *Config) WithScheme(scheme string) *Config

func (*Config) WithTimeout

func (c *Config) WithTimeout(timeout int) *Config

type Credential

type Credential struct {
	SecretKeyId       string
	SecretKeyPassword string
}

func NewCredential

func NewCredential(secretKeyId, secretKeyPassword string) *Credential

func (*Credential) GetSecretKeyId

func (c *Credential) GetSecretKeyId() string

func (*Credential) GetSecretKeyPassword

func (c *Credential) GetSecretKeyPassword() string

type CredentialIface

type CredentialIface interface {
	GetSecretId() string
	GetToken() string
	GetSecretKey() string
}

type ErrorResponse

type ErrorResponse struct {
	RequestId string `json:"requestId"`
	Code      string `json:"code"`
	Message   string `json:"message"`
}

type Request

type Request interface {
	GetScheme() string
	GetHttpMethod() string
	GetDomain() string
	GetAction() string
	GetBodyReader() io.Reader
	GetParams() map[string]string
	GetFormParams() map[string]string
	GetBody() []byte
	GetPath() string
	GetUrl() string
	GetContentType() string
	GetHeaders() map[string]string
	GetApiVersion() string
	GetServiceName() string
	GetMaxAttempts() int
	GetAutoRetries() bool
	GetBodyStr() string
	SetScheme(string)
	SetDomain(string)
	SetPath(string)
	SetContentType(string)
	SetHeaders(headers map[string]string)
	SetServiceName(string)
	SetBody([]byte)
	SetAutoRetries(bool)
	SetMaxAttempts(int)
}

type Response

type Response interface {
	ParseErrorResponse(body []byte) error
}

type ZenlayerCloudSdkError

type ZenlayerCloudSdkError struct {
	Code      string
	Message   string
	RequestId string
}

func (*ZenlayerCloudSdkError) Error

func (e *ZenlayerCloudSdkError) Error() string

func (*ZenlayerCloudSdkError) GetCode

func (e *ZenlayerCloudSdkError) GetCode() string

func (*ZenlayerCloudSdkError) GetMessage

func (e *ZenlayerCloudSdkError) GetMessage() string

func (*ZenlayerCloudSdkError) GetRequestId

func (e *ZenlayerCloudSdkError) GetRequestId() string

Jump to

Keyboard shortcuts

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