api

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Algorithm            = "HMAC-SHA256"
	DateFormat           = "20060102T150405Z"
	HeaderAuthorization  = "Authorization"
	HeaderXDate          = "X-Date"
	HeaderXContentSHA256 = "X-Content-Sha256"
	HeaderXSecurityToken = "X-Security-Token"
)
View Source
const (
	DefaultRegion = "cn-beijing"
)
View Source
const (
	DefaultTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func DecodeError

func DecodeError(statusCode int, body []byte) error

func ErrorCode

func ErrorCode(err error) string

func NewHTTPClient

func NewHTTPClient() *http.Client

func NewTransport

func NewTransport() *http.Transport

func ResolveEndpoint

func ResolveEndpoint(service, region, siteStack string) string

ResolveEndpoint returns the HTTPS base URL for a Volcengine OpenAPI service.

Types

type APIError

type APIError struct {
	HTTPStatus int
	Code       string
	Message    string
	Service    string
	Action     string
	RequestID  string
}

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cred auth.Credential, opts ...Option) *Client

func (*Client) DescribeInstances

func (c *Client) DescribeInstances(ctx context.Context, region string, maxResults int32, nextToken string) (DescribeInstancesResponse, error)

func (*Client) DescribeRegions

func (c *Client) DescribeRegions(ctx context.Context, region string, maxResults int32) (DescribeRegionsResponse, error)

func (*Client) DoOpenAPI

func (c *Client) DoOpenAPI(ctx context.Context, req Request, out any) error

func (*Client) GetLoginProfile

func (c *Client) GetLoginProfile(ctx context.Context, region, userName string) (GetLoginProfileResponse, error)

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context, region string) (ListProjectsResponse, error)

func (*Client) ListUsers

func (c *Client) ListUsers(ctx context.Context, region string, limit, offset int32) (ListUsersResponse, error)

func (*Client) QueryBalanceAcct

func (c *Client) QueryBalanceAcct(ctx context.Context, region string) (QueryBalanceAcctResponse, error)

type DescribeInstancesResponse

type DescribeInstancesResponse struct {
	ResponseMetadata ResponseMetadata `json:"ResponseMetadata"`
	Result           struct {
		NextToken string        `json:"NextToken"`
		Instances []ECSInstance `json:"Instances"`
	} `json:"Result"`
}

type DescribeRegionsResponse

type DescribeRegionsResponse struct {
	ResponseMetadata ResponseMetadata `json:"ResponseMetadata"`
	Result           struct {
		NextToken string      `json:"NextToken"`
		Regions   []ECSRegion `json:"Regions"`
	} `json:"Result"`
}

type ECSEipAddress

type ECSEipAddress struct {
	IPAddress string `json:"IpAddress"`
}

type ECSInstance

type ECSInstance struct {
	InstanceID        string                `json:"InstanceId"`
	Hostname          string                `json:"Hostname"`
	Status            string                `json:"Status"`
	OSType            string                `json:"OsType"`
	EipAddress        ECSEipAddress         `json:"EipAddress"`
	NetworkInterfaces []ECSNetworkInterface `json:"NetworkInterfaces"`
}

type ECSNetworkInterface

type ECSNetworkInterface struct {
	PrimaryIPAddress string `json:"PrimaryIpAddress"`
}

type ECSRegion

type ECSRegion struct {
	RegionID string `json:"RegionId"`
}

type ErrorBody

type ErrorBody struct {
	Code    string `json:"Code"`
	Message string `json:"Message"`
	CodeN   int    `json:"CodeN"`
}

type GetLoginProfileResponse

type GetLoginProfileResponse struct {
	ResponseMetadata ResponseMetadata `json:"ResponseMetadata"`
	Result           struct {
		LoginProfile IAMLoginProfile `json:"LoginProfile"`
	} `json:"Result"`
}

type IAMLoginProfile

type IAMLoginProfile struct {
	UserName      string `json:"UserName"`
	LastLoginDate string `json:"LastLoginDate"`
}

type IAMProject

type IAMProject struct {
	ProjectName string `json:"ProjectName"`
	AccountID   int64  `json:"AccountID"`
}

type IAMUserMetadata

type IAMUserMetadata struct {
	UserName   string `json:"UserName"`
	AccountID  int64  `json:"AccountId"`
	CreateDate string `json:"CreateDate"`
}

type ListProjectsResponse

type ListProjectsResponse struct {
	ResponseMetadata ResponseMetadata `json:"ResponseMetadata"`
	Result           struct {
		Projects []IAMProject `json:"Projects"`
		Total    int32        `json:"Total"`
	} `json:"Result"`
}

type ListUsersResponse

type ListUsersResponse struct {
	ResponseMetadata ResponseMetadata `json:"ResponseMetadata"`
	Result           struct {
		UserMetadata []IAMUserMetadata `json:"UserMetadata"`
		Total        int32             `json:"Total"`
		Limit        int32             `json:"Limit"`
		Offset       int32             `json:"Offset"`
	} `json:"Result"`
}

type Option

type Option func(*Client)

func WithBaseURL

func WithBaseURL(rawURL string) Option

func WithClock

func WithClock(now func() time.Time) Option

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

func WithRetryPolicy

func WithRetryPolicy(p RetryPolicy) Option

func WithSiteStack

func WithSiteStack(siteStack string) Option

type QueryBalanceAcctResponse

type QueryBalanceAcctResponse struct {
	ResponseMetadata ResponseMetadata `json:"ResponseMetadata"`
	Result           struct {
		AvailableBalance string `json:"AvailableBalance"`
	} `json:"Result"`
}

type Request

type Request struct {
	Service    string
	Version    string
	Action     string
	Method     string
	Region     string
	Path       string
	Query      url.Values
	Body       []byte
	Headers    http.Header
	Idempotent bool
}

type ResponseMetadata

type ResponseMetadata struct {
	RequestID string     `json:"RequestId"`
	Error     *ErrorBody `json:"Error,omitempty"`
}

type RetryPolicy

type RetryPolicy struct {
	MaxAttempts int
	BaseDelay   time.Duration
	MaxDelay    time.Duration
	Sleep       func(context.Context, time.Duration) error
}

func DefaultRetryPolicy

func DefaultRetryPolicy() RetryPolicy

func (RetryPolicy) Do

func (p RetryPolicy) Do(ctx context.Context, idempotent bool, fn func() (*http.Response, error)) (*http.Response, error)

type SignInput

type SignInput struct {
	Method       string
	Host         string
	Path         string
	Query        url.Values
	Body         []byte
	ContentType  string
	Service      string
	Region       string
	AccessKey    string
	SecretKey    string
	SessionToken string
	Headers      http.Header
	Timestamp    time.Time
}

type Signature

type Signature struct {
	Authorization    string
	SignedHeaders    string
	CredentialScope  string
	CanonicalRequest string
	StringToSign     string
	XDate            string
	XContentSHA256   string
}

func Sign

func Sign(input SignInput) (Signature, error)

Jump to

Keyboard shortcuts

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