hpsdk

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Unlicense Imports: 19 Imported by: 0

README

hpsdk

hp sdk

Documentation

Index

Constants

View Source
const (
	URI_ROOT = `/`
	URI_LIST = `/list`
	URI_INFO = `/info`
)
View Source
const (
	OpenApiAccessKey = "accessKey"
	OpenApiTimestamp = "timestamp"
	OpenApiSign      = "sign"
)

Variables

This section is empty.

Functions

func GenerateHMACSHA256Digest

func GenerateHMACSHA256Digest(appID, secretKey string, timestamp int64) string

GenerateHMACSHA256Digest 用于生成摘要

Types

type Client

type Client struct {
	// 客户端ID
	AccessKey string `json:"accessKey"`
	// 客户端密钥
	Secret string `json:"secret"`
	// 接入点
	Endpoint string `json:"endpoint"`

	// 请求超时时间 单位秒
	RequestTimeout int `json:"requestTimeout"`
	// contains filtered or unexported fields
}

func NewClient

func NewClient(accessKey, secret string, endpoint string, requestTimeout int) (*Client, error)

func (*Client) DoRequest

func (c *Client) DoRequest(options ...ClientRequestOption) (*httputil.Response, error)

type ClientRequestOption

type ClientRequestOption func(*ClientRequestOptions)

func WithAuthReqired

func WithAuthReqired(auth bool) ClientRequestOption

func WithBody

func WithBody(body io.Reader) ClientRequestOption

func WithHeaders

func WithHeaders(headers map[string]string) ClientRequestOption

func WithMethod

func WithMethod(method string) ClientRequestOption

func WithQueryParams

func WithQueryParams(params map[string]string) ClientRequestOption

func WithURI

func WithURI(uri string) ClientRequestOption

type ClientRequestOptions

type ClientRequestOptions struct {
	// 请求方法
	Method string `json:"method"`
	// 请求 API URI
	URI string `json:"uri"`
	// 是否需要鉴权
	AuthReqired bool `json:"authReqired"`
	// 请求参数
	QueryParams map[string]string `json:"queryParams"`
	// 请求头
	Headers map[string]string `json:"headers"`
	// 请求体
	Body io.Reader `json:"body"`
}

func NewClientRequestOptions

func NewClientRequestOptions(options ...ClientRequestOption) *ClientRequestOptions

type FileServiceClient

type FileServiceClient struct {
	Client
}

func NewFileServiceClient

func NewFileServiceClient(accessKey, secret string, endpoint string, requestTimeout int) (*FileServiceClient, error)

func (*FileServiceClient) DeleteFile

func (c *FileServiceClient) DeleteFile(filename string) (*httputil.Response, error)

DeleteFile 删除文件

func (*FileServiceClient) GetFile

func (c *FileServiceClient) GetFile(filename string) (*httputil.Response, error)

GetFile 获取文件

func (*FileServiceClient) GetFiles

func (c *FileServiceClient) GetFiles(prefix string) (*httputil.Response, error)

GetFiles 获取文件列表

func (*FileServiceClient) InfoFile

func (c *FileServiceClient) InfoFile(filename string) (*httputil.Response, error)

InfoFile 获取文件信息

func (*FileServiceClient) PostFile

func (c *FileServiceClient) PostFile(filename string, reader io.Reader) (*httputil.Response, error)

PostFile 上传文件

type OpenApiArgs

type OpenApiArgs struct {
	AccessKey string
	Timestamp int64
	Sign      string
}

func GetOpenApiArgs

func GetOpenApiArgs(c *gin.Context) (*OpenApiArgs, error)

type OpenApiMiddleware

type OpenApiMiddleware struct {
	ApiKeys map[string]string
	SignTtl int
}

func NewOpenApiMiddleware

func NewOpenApiMiddleware(apiKeys map[string]string, signTtl int) *OpenApiMiddleware

func (*OpenApiMiddleware) GetSecretByAccessKey

func (mw *OpenApiMiddleware) GetSecretByAccessKey(accessKey string) (string, error)

func (*OpenApiMiddleware) OpenApiAuth

func (mw *OpenApiMiddleware) OpenApiAuth(c *gin.Context)

type SdkConfig

type SdkConfig struct {
	AccessKey      string `yaml:"access_key"`
	Secret         string `yaml:"secret"`
	EndPoint       string `yaml:"endpoint"`
	RequestTimeout int    `yaml:"request_timeout"`
}

func LoadSdkConfig

func LoadSdkConfig() (*SdkConfig, error)

Jump to

Keyboard shortcuts

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