Documentation
¶
Overview ¶
Package convention implements Qoder authentication, transport, request options, errors and download conventions. Its param, pagination, respjson and ssestream subpackages provide the shared data structures for Managed and Forward modes.
Index ¶
- func DefaultHTTPClient() *http.Client
- func DownloadAPITo(ctx context.Context, client *http.Client, baseURL string, path string, ...) error
- func DownloadBytes(ctx context.Context, client *http.Client, url string) ([]byte, error)
- func DownloadFile(ctx context.Context, path string, opts ...RequestOption) (*http.Response, error)
- func DownloadTo(ctx context.Context, client *http.Client, url string, destination io.Writer) error
- func ExecuteNewRequest(ctx context.Context, method string, u string, body any, dst any, ...) error
- func ExecuteNewSessionRequest(ctx context.Context, method string, u string, body any, dst any, ...) error
- func NewCredentialTransport(credential Credential, next http.RoundTripper) http.RoundTripper
- type APIResponse
- type Credential
- type Error
- type FileContentLink
- type HTTPDoer
- type Metadata
- type NoCredentialsError
- type PATCredential
- type PreRequestOptionFunc
- type RequestConfig
- func (cfg *RequestConfig) Apply(opts ...RequestOption) error
- func (cfg *RequestConfig) Clone(ctx context.Context) *RequestConfig
- func (cfg *RequestConfig) Execute() (err error)
- func (r *RequestConfig) MarkAuthorizationDeleted()
- func (cfg *RequestConfig) WebSocketHandshake() (*http.Client, *http.Request, error)
- type RequestOption
- type RequestOptionFunc
- type ServiceAccountCredential
- type ServiceAccountCredentialConfig
- type UploadFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHTTPClient ¶ added in v0.2.0
DefaultHTTPClient returns a client with a ten-minute response-header timeout. Response bodies, including event streams, have no default total deadline. A custom http.DefaultTransport wrapper is preserved without modification.
func DownloadAPITo ¶
func DownloadBytes ¶
func DownloadFile ¶
DownloadFile obtains a temporary link and returns its streaming HTTP response. The caller closes Body. API authorization and middleware are never forwarded to the storage host; the signed URL provides the storage authorization.
func DownloadTo ¶
func ExecuteNewRequest ¶
func ExecuteNewSessionRequest ¶ added in v0.13.0
func ExecuteNewSessionRequest(ctx context.Context, method string, u string, body any, dst any, opts ...RequestOption) error
ExecuteNewSessionRequest adds SDK provenance to a Session creation request after request options have been applied. Conflicting reserved metadata fails before transport; caller-owned params and metadata are never modified.
func NewCredentialTransport ¶
func NewCredentialTransport(credential Credential, next http.RoundTripper) http.RoundTripper
NewCredentialTransport adds Bearer authentication without mutating the caller's request. An explicit Authorization header takes precedence. Tokens are fetched per attempt.
Types ¶
type APIResponse ¶
type APIResponse struct {
*http.Response `json:"-"`
Message string `json:"message,omitempty"`
// Operation is the name of the OpenAPI operation.
Operation string `json:"operation,omitempty"`
// RequestURL is the request URL. This value is always available, even if the
// embedded *http.Response is nil.
RequestURL string `json:"url,omitempty"`
// Method is the HTTP method used for the request. This value is always
// available, even if the embedded *http.Response is nil.
Method string `json:"method,omitempty"`
// Payload holds the contents of the response body (which may be nil or empty).
// This is provided here as the raw response.Body() reader will have already
// been drained.
Payload []byte `json:"-"`
}
APIResponse stores the API response returned by the server.
func NewAPIResponse ¶
func NewAPIResponse(r *http.Response) *APIResponse
NewAPIResponse returns a new APIResponse object.
func NewAPIResponseWithError ¶
func NewAPIResponseWithError(errorMessage string) *APIResponse
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
type FileContentLink ¶
FileContentLink is Qoder's temporary download grant.
type HTTPDoer ¶
This interface is primarily used to describe an *http.Client, but also supports custom HTTP implementations.
type NoCredentialsError ¶
type NoCredentialsError struct{}
NoCredentialsError is returned before a request is sent when no authentication could be resolved. It mirrors the request-time validation in the Python and TypeScript SDKs and is matchable with errors.As.
func (NoCredentialsError) Error ¶
func (NoCredentialsError) Error() string
type PATCredential ¶
type PATCredential struct {
// contains filtered or unexported fields
}
func NewPATCredential ¶
func NewPATCredential(token string) (*PATCredential, error)
func PATCredentialFromEnv ¶
func PATCredentialFromEnv(name string) (*PATCredential, error)
type PreRequestOptionFunc ¶
type PreRequestOptionFunc func(*RequestConfig) error
func (PreRequestOptionFunc) Apply ¶
func (s PreRequestOptionFunc) Apply(r *RequestConfig) error
type RequestConfig ¶
type RequestConfig struct {
MaxRetries int
RequestTimeout time.Duration
Context context.Context
Request *http.Request
BaseURL *url.URL
// DefaultBaseURL will be used if BaseURL is not explicitly overridden using
// WithBaseURL.
DefaultBaseURL *url.URL
CustomHTTPDoer HTTPDoer
HTTPClient *http.Client
Middlewares []middleware
APIKey string
AuthToken string
AuthMode string
Credential Credential
WebhookKey string
// If ResponseBodyInto not nil, then we will attempt to deserialize into
// ResponseBodyInto. If Destination is a []byte, then it will return the body as
// is.
ResponseBodyInto any
// ResponseInto copies the \*http.Response of the corresponding request into the
// given address
ResponseInto **http.Response
Body io.Reader
// contains filtered or unexported fields
}
RequestConfig represents all the state related to one request.
Editing the variables inside RequestConfig directly is unstable api. Prefer composing the RequestOption instead if possible.
func NewRequestConfig ¶
func NewRequestConfig(ctx context.Context, method string, u string, body any, dst any, opts ...RequestOption) (*RequestConfig, error)
func PreRequestOptions ¶
func PreRequestOptions(opts ...RequestOption) (RequestConfig, error)
PreRequestOptions is used to collect all the options which need to be known before a call to [RequestConfig.ExecuteNewRequest], such as path parameters or global defaults. PreRequestOptions will return a RequestConfig with the options applied.
Only request option functions of type PreRequestOptionFunc are applied.
func (*RequestConfig) Apply ¶
func (cfg *RequestConfig) Apply(opts ...RequestOption) error
func (*RequestConfig) Clone ¶
func (cfg *RequestConfig) Clone(ctx context.Context) *RequestConfig
func (*RequestConfig) Execute ¶
func (cfg *RequestConfig) Execute() (err error)
func (*RequestConfig) MarkAuthorizationDeleted ¶ added in v0.4.0
func (r *RequestConfig) MarkAuthorizationDeleted()
MarkAuthorizationDeleted suppresses static/environment header restoration; dynamic credentials retain their existing header-deletion behavior.
func (*RequestConfig) WebSocketHandshake ¶ added in v0.5.0
WebSocketHandshake prepares a single upgrade using the same headers, authentication and middleware as HTTP requests. RequestTimeout and the HTTP client's Timeout do not limit the lifetime of the upgraded connection. Custom HTTP doers cannot guarantee WebSocket upgrades; use a native http.Client.
type RequestOption ¶
type RequestOption interface {
Apply(*RequestConfig) error
}
func EnvironmentAuthentication ¶ added in v0.4.0
func EnvironmentAuthentication() RequestOption
EnvironmentAuthentication captures defaults in the common layer. Explicit credentials win; SA mode never falls back to the personal PAT.
func RequireCredential ¶
func RequireCredential() RequestOption
RequireCredential resolves the selected mode per attempt. Explicit headers override injection; custom authentication middleware remains supported.
func WithDefaultBaseURL ¶
func WithDefaultBaseURL(baseURL string) RequestOption
WithDefaultBaseURL returns a RequestOption that sets the client's default Base URL. This is always overridden by setting a base URL with WithBaseURL. WithBaseURL should be used instead of WithDefaultBaseURL except in internal code.
type RequestOptionFunc ¶
type RequestOptionFunc func(*RequestConfig) error
func (RequestOptionFunc) Apply ¶
func (s RequestOptionFunc) Apply(r *RequestConfig) error
type ServiceAccountCredential ¶ added in v0.4.0
type ServiceAccountCredential struct {
// contains filtered or unexported fields
}
ServiceAccountCredential shares an instance-owned SAT cache across clients. Key rotation uses a new instance; no refresh runs while idle.
func NewServiceAccountCredential ¶ added in v0.4.0
func NewServiceAccountCredential(config ServiceAccountCredentialConfig) (*ServiceAccountCredential, error)
func ServiceAccountCredentialFromEnv ¶ added in v0.4.0
func ServiceAccountCredentialFromEnv(config ServiceAccountCredentialConfig) (*ServiceAccountCredential, error)
func (*ServiceAccountCredential) GoString ¶ added in v0.4.0
func (c *ServiceAccountCredential) GoString() string
func (*ServiceAccountCredential) String ¶ added in v0.4.0
func (c *ServiceAccountCredential) String() string
type ServiceAccountCredentialConfig ¶ added in v0.4.0
type ServiceAccountCredentialConfig struct {
SAKey string
Region string
Scopes []string
TTLSeconds int
Timeout time.Duration
HTTPClient *http.Client
}
ServiceAccountCredentialConfig configures lazy SA Key exchange. Region and scopes must be explicit. The supplied HTTP client is copied, not owned.
type UploadFile ¶
UploadFile supplies a filename (including relative paths for skill file trees) and media type to the multipart serializer. Reader is consumed by the call.
func (UploadFile) ContentType ¶
func (f UploadFile) ContentType() string
func (UploadFile) Filename ¶
func (f UploadFile) Filename() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apierror describes Qoder's standard error envelope.
|
Package apierror describes Qoder's standard error envelope. |
|
encoding
|
|
|
json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
|
Package json implements encoding and decoding of JSON as defined in RFC 7159. |
|
json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
|
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package. |
|
Package resumablestream reconnects resource-level SSE streams after retryable failures.
|
Package resumablestream reconnects resource-level SSE streams after retryable failures. |
|
Package ssestream incrementally decodes Qoder server-sent events.
|
Package ssestream incrementally decodes Qoder server-sent events. |
|
thirdparty
|
|
|
gjson
Package gjson provides searching for json strings.
|
Package gjson provides searching for json strings. |
|
match
Package match provides a simple pattern matcher with unicode support.
|
Package match provides a simple pattern matcher with unicode support. |
|
sjson
Package sjson provides setting json values.
|
Package sjson provides setting json values. |