Documentation ¶
Index ¶
- Constants
- Variables
- func BoolPtr(v bool) *bool
- func BoolPtrs(vals []bool) []*bool
- func Float64Ptr(v float64) *float64
- func Float64Ptrs(vals []float64) []*float64
- func Int64Ptr(v int64) *int64
- func Int64Ptrs(vals []int64) []*int64
- func IntPtr(v int) *int
- func IntPtrs(vals []int) []*int
- func Sign(s, secretKey, method string) string
- func StringPtr(v string) *string
- func StringPtrs(vals []string) []*string
- func StringValues(ptrs []*string) []string
- func Uint64Ptr(v uint64) *uint64
- func Uint64Ptrs(vals []uint64) []*uint64
- func UintPtr(v uint) *uint
- func UintPtrs(vals []uint) []*uint
- type Client
- func (c *Client) GetCredential() CredentialIface
- func (c *Client) GetRegion() string
- func (c *Client) Init(region string) *Client
- func (c *Client) Send(request tchttp.Request, response tchttp.Response) (err error)
- func (c *Client) SendOctetStream(request tchttp.Request, response tchttp.Response) (err error)
- func (c *Client) WithCredential(cred CredentialIface) *Client
- func (c *Client) WithDebug(flag bool) *Client
- func (c *Client) WithHttpTransport(transport http.RoundTripper) *Client
- func (c *Client) WithLogger(logger Logger) *Client
- func (c *Client) WithProfile(clientProfile *profile.ClientProfile) *Client
- func (c *Client) WithProvider(provider Provider) (*Client, error)
- func (c *Client) WithRequestClient(rc string) *Client
- func (c *Client) WithSecretId(secretId, secretKey string) *Client
- func (c *Client) WithSignatureMethod(method string) *Client
- type Credential
- type CredentialIface
- type CvmRoleCredential
- type CvmRoleProvider
- type EnvProvider
- type Logger
- type OIDCRoleArnProvider
- type ProfileProvider
- type Provider
- type ProviderChain
- type RoleArnCredential
- type RoleArnProvider
Constants ¶
const ( StateClosed state = iota StateHalfOpen StateOpen )
These constants are states of CircuitBreaker.
const ( SHA256 = "HmacSHA256" SHA1 = "HmacSHA1" )
const (
EnvCredentialFile = "TENCENTCLOUD_CREDENTIALS_FILE"
)
const ExpiredTimeout = 300
Variables ¶
var DefaultHttpClient *http.Client
Functions ¶
func Float64Ptr ¶
func Float64Ptrs ¶
func StringPtrs ¶
func StringValues ¶
func Uint64Ptrs ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithProviders ¶
NewClientWithProviders build client with your custom providers; If you don't specify the providers, it will use the DefaultProviderChain to find credential
func NewClientWithSecretId ¶
func NewCommonClient ¶
func NewCommonClient(cred CredentialIface, region string, clientProfile *profile.ClientProfile) (c *Client)
func (*Client) GetCredential ¶
func (c *Client) GetCredential() CredentialIface
func (*Client) SendOctetStream ¶
SendOctetStream Invoke API with application/octet-stream content-type.
Note:
- only specific API can be invoked in such manner.
- only TC3-HMAC-SHA256 signature method can be specified.
- only POST request method can be specified
- the request Must be a CommonRequest and called SetOctetStreamParameters
func (*Client) WithCredential ¶
func (c *Client) WithCredential(cred CredentialIface) *Client
func (*Client) WithHttpTransport ¶
func (c *Client) WithHttpTransport(transport http.RoundTripper) *Client
func (*Client) WithLogger ¶
func (*Client) WithProfile ¶
func (c *Client) WithProfile(clientProfile *profile.ClientProfile) *Client
func (*Client) WithProvider ¶
WithProvider use specify provider to get a credential and use it to build a client
func (*Client) WithRequestClient ¶
func (*Client) WithSecretId ¶
func (*Client) WithSignatureMethod ¶
type Credential ¶
func NewCredential ¶
func NewCredential(secretId, secretKey string) *Credential
func NewTokenCredential ¶
func NewTokenCredential(secretId, secretKey, token string) *Credential
func (*Credential) GetSecretId ¶
func (c *Credential) GetSecretId() string
func (*Credential) GetSecretKey ¶
func (c *Credential) GetSecretKey() string
func (*Credential) GetToken ¶
func (c *Credential) GetToken() string
type CredentialIface ¶
type CvmRoleCredential ¶
type CvmRoleCredential struct {
// contains filtered or unexported fields
}
func (*CvmRoleCredential) GetSecretId ¶
func (c *CvmRoleCredential) GetSecretId() string
func (*CvmRoleCredential) GetSecretKey ¶
func (c *CvmRoleCredential) GetSecretKey() string
func (*CvmRoleCredential) GetToken ¶
func (c *CvmRoleCredential) GetToken() string
type CvmRoleProvider ¶
type CvmRoleProvider struct {
// contains filtered or unexported fields
}
func DefaultCvmRoleProvider ¶
func DefaultCvmRoleProvider() *CvmRoleProvider
DefaultCvmRoleProvider will auto get the cvm role name by accessing the metadata api more info please lookup: https://cloud.tencent.com/document/product/213/4934
func NewCvmRoleProvider ¶
func NewCvmRoleProvider(roleName string) *CvmRoleProvider
NewCvmRoleProvider need you to specify the roleName of the cvm currently in use
func (*CvmRoleProvider) GetCredential ¶
func (r *CvmRoleProvider) GetCredential() (CredentialIface, error)
type EnvProvider ¶
type EnvProvider struct {
// contains filtered or unexported fields
}
func DefaultEnvProvider ¶
func DefaultEnvProvider() *EnvProvider
DefaultEnvProvider return a default provider The default environment variable name are TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY
func NewEnvProvider ¶
func NewEnvProvider(secretIdEnvName, secretKeyEnvName string) *EnvProvider
NewEnvProvider uses the name of the environment variable you specified to get the credentials
func (*EnvProvider) GetCredential ¶
func (p *EnvProvider) GetCredential() (CredentialIface, error)
type OIDCRoleArnProvider ¶
type OIDCRoleArnProvider struct {
// contains filtered or unexported fields
}
func DefaultTkeOIDCRoleArnProvider ¶
func DefaultTkeOIDCRoleArnProvider() (*OIDCRoleArnProvider, error)
DefaultTkeOIDCRoleArnProvider returns a OIDCRoleArnProvider with some default options:
- providerId will be environment var TKE_PROVIDER_ID
- webIdentityToken will be the content of file specified by env TKE_WEB_IDENTITY_TOKEN_FILE
- roleArn will be env TKE_ROLE_ARN
- roleSessionName will be "tencentcloud-go-sdk-" + timestamp
- durationSeconds will be 7200s
func NewOIDCRoleArnProvider ¶
func NewOIDCRoleArnProvider(region, providerId, webIdentityToken, roleArn, roleSessionName string, durationSeconds int64) *OIDCRoleArnProvider
func (*OIDCRoleArnProvider) GetCredential ¶
func (r *OIDCRoleArnProvider) GetCredential() (CredentialIface, error)
type ProfileProvider ¶
type ProfileProvider struct { }
func DefaultProfileProvider ¶
func DefaultProfileProvider() *ProfileProvider
DefaultProfileProvider return a default Profile provider profile path :
- The value of the environment variable TENCENTCLOUD_CREDENTIALS_FILE
- linux: ~/.tencentcloud/credentials windows: \c:\Users\NAME\.tencentcloud\credentials
func (*ProfileProvider) GetCredential ¶
func (p *ProfileProvider) GetCredential() (CredentialIface, error)
type Provider ¶
type Provider interface { // GetCredential get the credential interface GetCredential() (CredentialIface, error) }
Provider provide credential to build client.
Now there are four kinds provider:
EnvProvider : get credential from your Variable environment ProfileProvider : get credential from your profile CvmRoleProvider : get credential from your cvm role RoleArnProvider : get credential from your role arn
func DefaultProviderChain ¶
func DefaultProviderChain() Provider
DefaultProviderChain returns a default provider chain and try to get credentials in the following order:
- Environment variable
- Profile
- CvmRole
If you want to customize the search order, please use the function NewProviderChain
func NewProviderChain ¶
NewProviderChain returns a provider chain in your custom order
type ProviderChain ¶
type ProviderChain struct {
Providers []Provider
}
func (*ProviderChain) GetCredential ¶
func (c *ProviderChain) GetCredential() (CredentialIface, error)
type RoleArnCredential ¶
type RoleArnCredential struct {
// contains filtered or unexported fields
}
func (*RoleArnCredential) GetSecretId ¶
func (c *RoleArnCredential) GetSecretId() string
func (*RoleArnCredential) GetSecretKey ¶
func (c *RoleArnCredential) GetSecretKey() string
func (*RoleArnCredential) GetToken ¶
func (c *RoleArnCredential) GetToken() string
type RoleArnProvider ¶
type RoleArnProvider struct {
// contains filtered or unexported fields
}
func DefaultRoleArnProvider ¶
func DefaultRoleArnProvider(secretId, secretKey, roleArn string) *RoleArnProvider
DefaultRoleArnProvider returns a RoleArnProvider that use some default options:
- roleSessionName will be "tencentcloud-go-sdk-" + timestamp
- durationSeconds will be 7200s
func NewRoleArnProvider ¶
func NewRoleArnProvider(secretId, secretKey, roleArn, sessionName string, duration int64) *RoleArnProvider
func (*RoleArnProvider) GetCredential ¶
func (r *RoleArnProvider) GetCredential() (CredentialIface, error)
Source Files ¶
- circuit_breaker.go
- client.go
- clienttoken.go
- common_client.go
- credentials.go
- cvm_role_credential.go
- cvm_role_provider.go
- env_provider.go
- ini.go
- log.go
- netretry.go
- oidc_role_arn_provider.go
- profile_provider.go
- provider.go
- provider_chain.go
- ratelimitretry.go
- role_arn_credential.go
- role_arn_provider.go
- section.go
- sign.go
- types.go
- value.go