base

package
v1.0.27 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	RegionUsEast1     = "us-east-1"
	RegionApSingapore = "ap-singapore-1"
)
View Source
const (
	StatementEffectAllow = "Allow"
	StatementEffectDeny  = "Deny"
)

Variables

This section is empty.

Functions

func Sign4

func Sign4(request *http.Request, credential Credentials) *http.Request

Sign4 signs a request with Signed Signature Version 4.

Types

type ApiInfo

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

type BaseResp

type BaseResp struct {
	Status      string
	CreatedTime int64
	UpdatedTime int64
}

type Client

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

Client 基础客户端

func NewClient

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

NewClient 生成一个客户端

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 发起Json的post请求

func (*Client) Post

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

Post 发起Post请求

func (*Client) PostWithContentType

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

PostWithContentType 发起自定义 Content-Type 的 post 请求,Content-Type 不可以为空

func (*Client) Query

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

Query 发起Get的query请求

func (*Client) SetAccessKey

func (client *Client) SetAccessKey(ak string)

SetAccessKey 设置AK

func (*Client) SetCredential

func (client *Client) SetCredential(c Credentials)

SetCredential 设置Credentials

func (*Client) SetHost

func (client *Client) SetHost(host string)

SetHost 设置Host

func (*Client) SetScheme

func (client *Client) SetScheme(scheme string)

func (*Client) SetSecretKey

func (client *Client) SetSecretKey(sk string)

SetSecretKey 设置SK

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 生成sts信息

type CommonResponse

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

统一的JSON返回结果

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 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 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
}

func (*ServiceInfo) Clone

func (serviceInfo *ServiceInfo) Clone() *ServiceInfo

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