Documentation
¶
Index ¶
- type Auth
- type Backoff
- type BaseResponse
- type Client
- func (c *Client) Get(ctx context.Context, path string, params map[string]string, ...) error
- func (c *Client) GetWithRetry(ctx context.Context, path string, params map[string]string, ...) error
- func (c *Client) Post(ctx context.Context, path string, body any, resp OpenAPIResponse) error
- func (c *Client) PostStream(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *Client) PostWithRetry(ctx context.Context, path string, body any, resp OpenAPIResponse, ...) error
- func (c *Client) UploadFile(ctx context.Context, path string, fileName string, reader io.Reader, ...) error
- type ClientOptions
- type GetJWTAccessTokenReq
- type GrantType
- type HTTPClient
- type JWTOAuthClient
- type NewJWTOAuthClientParam
- type OAuthClient
- type OAuthClientOption
- type OAuthToken
- type OpenAPIResponse
- type Scope
- type ScopeAccountPermission
- type ScopeAttributeConstraint
- type ScopeAttributeConstraintConnectorBotChatAttribute
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
func NewJWTAuth ¶
func NewJWTAuth(client *JWTOAuthClient, opt *GetJWTAccessTokenReq) Auth
func NewTokenAuth ¶
NewTokenAuth creates a new token authentication instance.
type Backoff ¶
type Backoff struct {
// contains filtered or unexported fields
}
func NewBackoff ¶
type BaseResponse ¶
func (*BaseResponse) GetCode ¶
func (b *BaseResponse) GetCode() int
func (*BaseResponse) GetLogID ¶
func (b *BaseResponse) GetLogID() string
func (*BaseResponse) GetMsg ¶
func (b *BaseResponse) GetMsg() string
func (*BaseResponse) SetLogID ¶
func (b *BaseResponse) SetLogID(logID string)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(baseURL string, httpClient HTTPClient, auth Auth, options *ClientOptions) *Client
func (*Client) GetWithRetry ¶
func (*Client) PostStream ¶ added in v0.1.12
func (*Client) PostWithRetry ¶
type ClientOptions ¶
type GetJWTAccessTokenReq ¶
type GetJWTAccessTokenReq struct {
TTL time.Duration `json:"ttl,omitempty"` // Token validity period (in seconds)
Scope *Scope `json:"scope,omitempty"` // Permission scope
SessionName *string `json:"session_name,omitempty"` // Session name
AccountID *int64 `json:"account_id,omitempty"` // Account ID
}
GetJWTAccessTokenReq represents options for getting JWT OAuth token
type HTTPClient ¶
HTTPClient an interface for making HTTP requests
type JWTOAuthClient ¶
type JWTOAuthClient struct {
*OAuthClient
// contains filtered or unexported fields
}
JWTOAuthClient represents the JWT OAuth core
func NewJWTOAuthClient ¶
func NewJWTOAuthClient(param NewJWTOAuthClientParam, opts ...OAuthClientOption) (*JWTOAuthClient, error)
NewJWTOAuthClient creates a new JWT OAuth core
func (*JWTOAuthClient) GetAccessToken ¶
func (c *JWTOAuthClient) GetAccessToken(ctx context.Context, opts *GetJWTAccessTokenReq) (*OAuthToken, error)
GetAccessToken gets the access token, using options pattern
type NewJWTOAuthClientParam ¶
type OAuthClient ¶
type OAuthClient struct {
// contains filtered or unexported fields
}
OAuthClient represents the base OAuth core structure
type OAuthClientOption ¶
type OAuthClientOption func(*oauthOption)
func WithAuthBaseURL ¶
func WithAuthBaseURL(baseURL string) OAuthClientOption
WithAuthBaseURL adds base URL
func WithAuthHttpClient ¶
func WithAuthHttpClient(client HTTPClient) OAuthClientOption
func WithAuthWWWURL ¶
func WithAuthWWWURL(wwwURL string) OAuthClientOption
WithAuthWWWURL adds base URL
type OAuthToken ¶
type OAuthToken struct {
BaseResponse
AccessToken string `json:"access_token"`
ExpiresIn int64 `json:"expires_in"`
RefreshToken string `json:"refresh_token,omitempty"`
}
OAuthToken represents the OAuth token response
type OpenAPIResponse ¶
type Scope ¶
type Scope struct {
AccountPermission *ScopeAccountPermission `json:"account_permission"`
AttributeConstraint *ScopeAttributeConstraint `json:"attribute_constraint,omitempty"`
}
Scope represents the OAuth scope
type ScopeAccountPermission ¶
type ScopeAccountPermission struct {
PermissionList []string `json:"permission_list"`
}
ScopeAccountPermission represents the account permissions in the scope
type ScopeAttributeConstraint ¶
type ScopeAttributeConstraint struct {
ConnectorBotChatAttribute *ScopeAttributeConstraintConnectorBotChatAttribute `json:"connector_bot_chat_attribute"`
}
ScopeAttributeConstraint represents the attribute constraints in the scope
type ScopeAttributeConstraintConnectorBotChatAttribute ¶
type ScopeAttributeConstraintConnectorBotChatAttribute struct {
BotIDList []string `json:"bot_id_list"`
}
ScopeAttributeConstraintConnectorBotChatAttribute represents the bot chat attributes