Documentation
¶
Overview ¶
Package ucloud is a package of utilities to setup ucloud sdk and improve using experience
Index ¶
- Constants
- func Bool(val bool) *bool
- func BoolValue(ptr *bool) bool
- func Float64(val float64) *float64
- func Float64Value(ptr *float64) float64
- func Int(val int) *int
- func IntValue(ptr *int) int
- func String(val string) *string
- func StringValue(ptr *string) string
- func TimeDuration(val time.Duration) *time.Duration
- func TimeDurationValue(ptr *time.Duration) time.Duration
- type Client
- func (c *Client) GetConfig() *Config
- func (c *Client) GetCredential() *auth.Credential
- func (c *Client) InvokeAction(action string, req request.Common, resp response.Common) error
- func (c *Client) InvokeActionWithPatcher(action string, req request.Common, resp response.Common, ...) error
- func (c *Client) SetupRequest(req request.Common) request.Common
- type Config
- type HttpReponseHandler
- type ReponseHandler
Constants ¶
View Source
const Version = version.Version
Version is the version of sdk
Variables ¶
This section is empty.
Functions ¶
func Float64Value ¶
Float64Value will return a float64 from float64 pointer
func StringValue ¶
StringValue will return a string from string pointer
func TimeDuration ¶
TimeDuration will return a pointer to time.Duration
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 客户端
func NewClient ¶
func NewClient(config *Config, credential *auth.Credential) *Client
NewClient will create an client of ucloud sdk
func (*Client) GetCredential ¶
func (c *Client) GetCredential() *auth.Credential
GetCredential will return the creadential config of client.
func (*Client) InvokeAction ¶
InvokeAction will do an action request from a request struct and set response value into res struct pointer
type Config ¶
type Config struct {
// Region is the region of backend service
// See also <https://docs.ucloud.cn/api/summary/regionlist> ...
Region string `default:""`
// Zone is the zone of backend service
// See also <https://docs.ucloud.cn/api/summary/regionlist> ...
Zone string `default:""`
// ProjectId is the unique identify of project, used for organize resources,
// Most of resources should belong to a project.
// Sub-Account must have an project id.
// See also <https://docs.ucloud.cn/api/summary/get_project_list> ...
ProjectId string `default:""`
// BaseUrl is the url of backend api
// See also <doc link> ...
BaseUrl string `default:"https://api.ucloud.cn"`
// UserAgent is an attribute for sdk client, used for distinguish who is using sdk.
// See also https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
// It will be appended to the end of sdk user-agent.
// eg. "Terraform/0.10.1" -> "GO/1.9.1 GO-SDK/0.1.0 Terraform/0.10.1"
// NOTE: it will conflict with the User-Agent of HTTPHeaders
UserAgent string `default:""`
// Timeout is timeout for every request.
Timeout time.Duration `default:"30s"`
// MaxRetries is the number of max retry times.
// Set MaxRetries more than 0 to enable auto-retry for network and service availability problem
// if auto-retry is enabled, it will enable default retry policy using exponential backoff.
MaxRetries int `default:"0"`
// LogLevel is equal to logrus level,
// if logLevel not be set, use INFO level as default.
LogLevel log.Level `default:"log.InfoLevel"`
}
Config is the config of ucloud sdk, use for setting up client
type HttpReponseHandler ¶
type HttpReponseHandler func(c *Client, req *http.HttpRequest, resp *http.HttpResponse, err error) (*http.HttpResponse, error)
HttpReponseHandler receive http response and return a new http response
Directories
¶
| Path | Synopsis |
|---|---|
|
Package auth is the credential utilities of sdk
|
Package auth is the credential utilities of sdk |
|
Package uerr is the error definition of service and sdk
|
Package uerr is the error definition of service and sdk |
|
helpers
|
|
|
waiter
Package waiter is a helper package use for waiting remote state is transformed into target state.
|
Package waiter is a helper package use for waiting remote state is transformed into target state. |
|
Package log is the log utilities of sdk
|
Package log is the log utilities of sdk |
|
Package request is the request of service
|
Package request is the request of service |
|
Package response is the response of service
|
Package response is the response of service |
|
Package version is the version of sdk
|
Package version is the version of sdk |
Click to show internal directories.
Click to hide internal directories.