base

package
v0.0.0-...-2d37aee Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RegionCnNorth1    = "cn-north-1"
	RegionUsEast1     = "us-east-1"
	RegionApSingapore = "ap-singapore-1"
)
View Source
const (
	StatementEffectAllow = "Allow"
	StatementEffectDeny  = "Deny"
)
View Source
const SDKName = "volc-sdk-golang"
View Source
const SDKVersion = "v1.0.82"

Variables

This section is empty.

Functions

func ToUrlValues

func ToUrlValues(i interface{}) (values url.Values)

func UnmarshalResultInto

func UnmarshalResultInto(data []byte, result interface{}) error

Types

type ApiInfo

type ApiInfo struct {
	Method  string
	Path    string
	Query   url.Values
	Form    url.Values
	Timeout time.Duration
	Header  http.Header
	Retry   RetrySettings
}

type BaseResp

type BaseResp struct {
	Status      string
	CreatedTime int64
	UpdatedTime int64
}

type Client

type Client struct {
	Client      *http.Client
	ServiceInfo *ServiceInfo
	ApiInfoList map[string]*ApiInfo
}

Client

func NewClient

func NewClient(info *ServiceInfo, apiInfoList map[string]*ApiInfo) *Client

NewClient

func (*Client) CtxJson

func (client *Client) CtxJson(ctx context.Context, api string, query url.Values, body string) ([]byte, int, error)

func (*Client) CtxPost

func (client *Client) CtxPost(ctx context.Context, api string, query url.Values, form url.Values) ([]byte, int, error)

CtxPost Initiate a Post request

func (*Client) CtxPostWithContentType

func (client *Client) CtxPostWithContentType(ctx context.Context, api string, query url.Values, body string, ct string) ([]byte, int, error)

CtxPostWithContentType Initiate a post request with a custom Content-Type, Content-Type cannot be empty

func (*Client) CtxQuery

func (client *Client) CtxQuery(ctx context.Context, api string, query url.Values) ([]byte, int, error)

func (*Client) GetSignUrl

func (client *Client) GetSignUrl(api string, query url.Values) (string, error)

GetSignUrl

func (*Client) Json

func (client *Client) Json(api string, query url.Values, body string) ([]byte, int, error)

Json Initiate a Json post request

func (*Client) Post

func (client *Client) Post(api string, query url.Values, form url.Values) ([]byte, int, error)

func (*Client) PostWithContentType

func (client *Client) PostWithContentType(api string, query url.Values, body string, ct string) ([]byte, int, error)

func (*Client) Query

func (client *Client) Query(api string, query url.Values) ([]byte, int, error)

Query Initiate a Get query request

func (*Client) SetAccessKey

func (client *Client) SetAccessKey(ak string)

SetAccessKey

func (*Client) SetCredential

func (client *Client) SetCredential(c Credentials)

SetCredential

func (*Client) SetHost

func (client *Client) SetHost(host string)

SetHost

func (*Client) SetRetrySettings

func (client *Client) SetRetrySettings(retrySettings *RetrySettings)

SetRetrySettings

func (*Client) SetScheme

func (client *Client) SetScheme(scheme string)

func (*Client) SetSecretKey

func (client *Client) SetSecretKey(sk string)

SetSecretKey

func (*Client) SetSessionToken

func (client *Client) SetSessionToken(token string)

SetSessionToken

func (*Client) SetTimeout

func (client *Client) SetTimeout(timeout time.Duration)

func (*Client) SignSts2

func (client *Client) SignSts2(inlinePolicy *Policy, expire time.Duration) (*SecurityToken2, error)

SignSts2

type CommonResponse

type CommonResponse struct {
	ResponseMetadata ResponseMetadata
	Result           interface{} `json:"Result,omitempty"`
}

Unified JSON return results

type Credentials

type Credentials struct {
	AccessKeyID     string
	SecretAccessKey string
	Service         string
	Region          string
	SessionToken    string
}

func (Credentials) Clone

func (cred Credentials) Clone() Credentials

func (Credentials) Sign

func (c Credentials) Sign(request *http.Request) *http.Request

func (Credentials) SignUrl

func (c Credentials) SignUrl(request *http.Request) string

type ErrorObj

type ErrorObj struct {
	CodeN   int
	Code    string
	Message string
}

type InnerToken

type InnerToken struct {
	LTAccessKeyId         string
	AccessKeyId           string
	SignedSecretAccessKey string
	ExpiredTime           int64
	PolicyString          string
	Signature             string
}

type Policy

type Policy struct {
	Statement []*Statement
}

type RequestParam

type RequestParam struct {
	IsSignUrl bool
	Body      []byte
	Method    string
	Date      time.Time
	Path      string
	Host      string
	QueryList url.Values
	Headers   http.Header
}

type ResponseMetadata

type ResponseMetadata struct {
	RequestId string
	Service   string    `json:",omitempty"`
	Region    string    `json:",omitempty"`
	Action    string    `json:",omitempty"`
	Version   string    `json:",omitempty"`
	Error     *ErrorObj `json:",omitempty"`
}

type RetrySettings

type RetrySettings struct {
	AutoRetry     bool
	RetryTimes    *uint64
	RetryInterval *time.Duration
}

type SecurityToken2

type SecurityToken2 struct {
	AccessKeyID     string
	SecretAccessKey string
	SessionToken    string
	ExpiredTime     string
	CurrentTime     string
}

type ServiceInfo

type ServiceInfo struct {
	Timeout     time.Duration
	Scheme      string
	Host        string
	Header      http.Header
	Credentials Credentials
	Retry       RetrySettings
}

func (*ServiceInfo) Clone

func (serviceInfo *ServiceInfo) Clone() *ServiceInfo

type SignRequest

type SignRequest struct {
	XDate          string
	XNotSignBody   string
	XCredential    string
	XAlgorithm     string
	XSignedHeaders string
	XSignedQueries string
	XSignature     string
	XSecurityToken string

	Host           string
	ContentType    string
	XContentSha256 string
	Authorization  string
}

func GetSignRequest

func GetSignRequest(requestParam RequestParam, credentials Credentials) SignRequest

type Statement

type Statement struct {
	Effect    string
	Action    []string
	Resource  []string
	Condition string `json:",omitempty"`
}

func NewAllowStatement

func NewAllowStatement(actions, resources []string) *Statement

func NewDenyStatement

func NewDenyStatement(actions, resources []string) *Statement

Jump to

Keyboard shortcuts

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