Documentation
¶
Overview ¶
Package bindist provides a client for the BinDist API.
Index ¶
- Constants
- type Activity
- type AdminClient
- func (c *AdminClient) CompleteLargeUpload(ctx context.Context, uploadID, applicationID, version, fileName string, ...) (*Response[UploadResponse], error)
- func (c *AdminClient) CreateApplication(ctx context.Context, opts CreateApplicationOptions) (*Response[Application], error)
- func (c *AdminClient) CreateCustomer(ctx context.Context, name string, parentCustomerID string, notes string) (*Response[CreateCustomerResponse], error)
- func (c *AdminClient) DeleteApplication(ctx context.Context, applicationID string) (*Response[map[string]interface{}], error)
- func (c *AdminClient) GetLargeUploadURL(ctx context.Context, applicationID, version, fileName string, fileSize int64, ...) (*Response[LargeUploadURLResponse], error)
- func (c *AdminClient) ListActivity(ctx context.Context, activityType, applicationID string, page, pageSize int) (*Response[[]Activity], error)
- func (c *AdminClient) ListCustomers(ctx context.Context, page, pageSize int) (*Response[[]Customer], error)
- func (c *AdminClient) SetHTTPClient(client *http.Client)
- func (c *AdminClient) UpdateCustomer(ctx context.Context, customerID string, name *string, isActive *bool, ...) (*Response[Customer], error)
- func (c *AdminClient) UpdateVersion(ctx context.Context, applicationID, version string, opts UpdateVersionOptions) (*Response[Version], error)
- func (c *AdminClient) UploadLargeFile(ctx context.Context, applicationID, version, fileName string, content []byte, ...) (*Response[UploadResponse], error)
- func (c *AdminClient) UploadSmallFile(ctx context.Context, applicationID, version, fileName string, content []byte, ...) (*Response[UploadResponse], error)
- type ApiError
- type Application
- type Client
- func (c *Client) CreateShareLink(ctx context.Context, applicationID, version, fileID string, expiresMinutes int) (*Response[ShareLink], error)
- func (c *Client) DownloadFile(ctx context.Context, applicationID, version, fileID string, ...) ([]byte, *DownloadInfo, error)
- func (c *Client) DownloadFileToWriter(ctx context.Context, applicationID, version, fileID string, w io.Writer, ...) (*DownloadInfo, error)
- func (c *Client) GetApplication(ctx context.Context, applicationID string) (*Response[Application], error)
- func (c *Client) GetDownloadInfo(ctx context.Context, applicationID, version, fileID string, ...) (*Response[DownloadInfo], error)
- func (c *Client) GetStats(ctx context.Context, applicationID string) (*Response[Stats], error)
- func (c *Client) ListApplications(ctx context.Context, opts *ListApplicationsOptions) (*Response[[]Application], error)
- func (c *Client) ListVersionFiles(ctx context.Context, applicationID, version string) (*Response[[]VersionFile], error)
- func (c *Client) ListVersions(ctx context.Context, applicationID string, opts ...RequestOption) (*Response[[]Version], error)
- func (c *Client) SetHTTPClient(client *http.Client)
- type CreateApplicationOptions
- type CreateCustomerResponse
- type Customer
- type DownloadInfo
- type LargeUploadURLResponse
- type ListApplicationsOptions
- type Meta
- type Pagination
- type RequestOption
- type Response
- type ShareLink
- type Stats
- type UpdateVersionOptions
- type UploadResponse
- type Version
- type VersionFile
Constants ¶
const (
ChannelTest = "Test"
)
Release channel constants. Channels allow access to versions outside the default (production) channel. For example, the "Test" channel exposes disabled versions for pre-release testing.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Activity ¶
type Activity struct {
Type string `json:"type"`
ApplicationID string `json:"applicationId"`
Version string `json:"version"`
CustomerID string `json:"customerId"`
Timestamp time.Time `json:"timestamp"`
}
Activity represents an upload or download activity.
type AdminClient ¶
type AdminClient struct {
// contains filtered or unexported fields
}
AdminClient is the BinDist admin API client.
func NewAdminClient ¶
func NewAdminClient(baseURL, apiKey string) *AdminClient
NewAdminClient creates a new BinDist admin API client.
func (*AdminClient) CompleteLargeUpload ¶
func (c *AdminClient) CompleteLargeUpload(ctx context.Context, uploadID, applicationID, version, fileName string, fileSize int64, checksum, releaseNotes string) (*Response[UploadResponse], error)
CompleteLargeUpload completes a large file upload.
func (*AdminClient) CreateApplication ¶
func (c *AdminClient) CreateApplication(ctx context.Context, opts CreateApplicationOptions) (*Response[Application], error)
CreateApplication creates a new application.
func (*AdminClient) CreateCustomer ¶
func (c *AdminClient) CreateCustomer(ctx context.Context, name string, parentCustomerID string, notes string) (*Response[CreateCustomerResponse], error)
CreateCustomer creates a new customer with an API key.
func (*AdminClient) DeleteApplication ¶
func (c *AdminClient) DeleteApplication(ctx context.Context, applicationID string) (*Response[map[string]interface{}], error)
DeleteApplication soft-deletes an application.
func (*AdminClient) GetLargeUploadURL ¶
func (c *AdminClient) GetLargeUploadURL(ctx context.Context, applicationID, version, fileName string, fileSize int64, contentType string) (*Response[LargeUploadURLResponse], error)
GetLargeUploadURL gets a pre-signed URL for uploading a large file.
func (*AdminClient) ListActivity ¶
func (c *AdminClient) ListActivity(ctx context.Context, activityType, applicationID string, page, pageSize int) (*Response[[]Activity], error)
ListActivity lists upload and download activity.
func (*AdminClient) ListCustomers ¶
func (c *AdminClient) ListCustomers(ctx context.Context, page, pageSize int) (*Response[[]Customer], error)
ListCustomers lists all customers.
func (*AdminClient) SetHTTPClient ¶
func (c *AdminClient) SetHTTPClient(client *http.Client)
SetHTTPClient sets a custom HTTP client.
func (*AdminClient) UpdateCustomer ¶
func (c *AdminClient) UpdateCustomer(ctx context.Context, customerID string, name *string, isActive *bool, notes *string) (*Response[Customer], error)
UpdateCustomer updates customer metadata.
func (*AdminClient) UpdateVersion ¶
func (c *AdminClient) UpdateVersion(ctx context.Context, applicationID, version string, opts UpdateVersionOptions) (*Response[Version], error)
UpdateVersion updates version metadata.
func (*AdminClient) UploadLargeFile ¶
func (c *AdminClient) UploadLargeFile(ctx context.Context, applicationID, version, fileName string, content []byte, releaseNotes string) (*Response[UploadResponse], error)
UploadLargeFile uploads a large file using the multi-step process.
func (*AdminClient) UploadSmallFile ¶
func (c *AdminClient) UploadSmallFile(ctx context.Context, applicationID, version, fileName string, content []byte, releaseNotes string) (*Response[UploadResponse], error)
UploadSmallFile uploads a small file (< 10MB) directly.
type ApiError ¶
type ApiError struct {
Code string `json:"code"`
Message string `json:"message"`
HTTPStatus int `json:"-"`
}
ApiError represents an error returned by the API.
HTTPStatus is set by the client to the HTTP status code of the underlying response when the error was synthesized from a non-2xx response that did not conform to the standard error envelope — for example, errors raised by auth middleware, reverse proxies, load balancers, rate limiters, or gateway timeouts, which never reach the API application's own error renderer. In that case Code is derived from the HTTP status (e.g. "unauthorized", "rate_limited") and is coarser than a code returned by the server's structured error payload. HTTPStatus is zero for errors that came from the server envelope.
type Application ¶
type Application struct {
ApplicationID string `json:"applicationId"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
IsActive bool `json:"isActive"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Tags []string `json:"tags,omitempty"`
}
Application represents an application.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the BinDist API client.
func (*Client) CreateShareLink ¶
func (c *Client) CreateShareLink(ctx context.Context, applicationID, version, fileID string, expiresMinutes int) (*Response[ShareLink], error)
CreateShareLink creates a shareable download link for a file.
func (*Client) DownloadFile ¶
func (c *Client) DownloadFile(ctx context.Context, applicationID, version, fileID string, verifyChecksum bool, opts ...RequestOption) ([]byte, *DownloadInfo, error)
DownloadFile downloads a file and returns its contents along with metadata. If verifyChecksum is true, the checksum is verified against the expected value.
Pass WithChannel to download from a non-default release channel.
func (*Client) DownloadFileToWriter ¶
func (c *Client) DownloadFileToWriter(ctx context.Context, applicationID, version, fileID string, w io.Writer, opts ...RequestOption) (*DownloadInfo, error)
DownloadFileToWriter downloads a file and writes it to the provided writer. Returns the download metadata.
Pass WithChannel to download from a non-default release channel.
func (*Client) GetApplication ¶
func (c *Client) GetApplication(ctx context.Context, applicationID string) (*Response[Application], error)
GetApplication returns details for a specific application.
func (*Client) GetDownloadInfo ¶
func (c *Client) GetDownloadInfo(ctx context.Context, applicationID, version, fileID string, opts ...RequestOption) (*Response[DownloadInfo], error)
GetDownloadInfo returns download URL and metadata for a file.
Pass WithChannel to obtain a download URL for a version that is only accessible on a non-default channel (e.g. WithChannel(ChannelTest) for disabled versions).
func (*Client) ListApplications ¶
func (c *Client) ListApplications(ctx context.Context, opts *ListApplicationsOptions) (*Response[[]Application], error)
ListApplications returns a list of available applications.
func (*Client) ListVersionFiles ¶
func (c *Client) ListVersionFiles(ctx context.Context, applicationID, version string) (*Response[[]VersionFile], error)
ListVersionFiles returns all files for a specific version.
func (*Client) ListVersions ¶
func (c *Client) ListVersions(ctx context.Context, applicationID string, opts ...RequestOption) (*Response[[]Version], error)
ListVersions returns all versions for an application.
Pass WithChannel to access versions outside the default production channel (e.g. WithChannel(ChannelTest) to include disabled versions).
func (*Client) SetHTTPClient ¶
SetHTTPClient sets a custom HTTP client.
type CreateApplicationOptions ¶
type CreateApplicationOptions struct {
ApplicationID string `json:"applicationId"`
Name string `json:"name"`
CustomerIDs []string `json:"customerIds"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
}
CreateApplicationOptions contains options for creating an application.
type CreateCustomerResponse ¶
type CreateCustomerResponse struct {
CustomerID string `json:"customerId"`
APIKey string `json:"apiKey"`
Name string `json:"name"`
CreatedAt string `json:"createdAt"`
}
CreateCustomerResponse is the response from creating a customer.
type Customer ¶
type Customer struct {
CustomerID string `json:"customerId"`
Name string `json:"name"`
APIKey string `json:"apiKey,omitempty"`
IsActive bool `json:"isActive"`
Notes string `json:"notes,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
Customer represents a customer.
type DownloadInfo ¶
type DownloadInfo struct {
DownloadID string `json:"downloadId"`
URL string `json:"url"`
ExpiresAt time.Time `json:"expiresAt"`
FileName string `json:"fileName"`
FileSize int64 `json:"fileSize"`
Checksum string `json:"checksum"`
}
DownloadInfo contains download URL and file metadata.
type LargeUploadURLResponse ¶
type LargeUploadURLResponse struct {
UploadID string `json:"uploadId"`
UploadURL string `json:"uploadUrl"`
}
LargeUploadURLResponse is the response from getting a large upload URL.
type ListApplicationsOptions ¶
ListApplicationsOptions contains options for listing applications.
type Meta ¶
type Meta struct {
RequestID string `json:"requestId"`
Pagination *Pagination `json:"pagination,omitempty"`
}
Meta contains response metadata.
type Pagination ¶
type Pagination struct {
Page int `json:"page"`
Limit int `json:"limit"`
Total int `json:"total"`
HasNext bool `json:"hasNext"`
HasPrevious bool `json:"hasPrevious"`
}
Pagination contains pagination information.
type RequestOption ¶
type RequestOption func(*requestOptions)
RequestOption configures a single API request.
func WithChannel ¶
func WithChannel(channel string) RequestOption
WithChannel sets the release channel for the request. When set, the X-Channel header is sent and versions from that channel become accessible (e.g. ChannelTest to access disabled/pre-release versions).
type Response ¶
Response is a generic response type.
HTTPStatus is the HTTP status code of the underlying response.
type Stats ¶
type Stats struct {
TotalDownloads int `json:"totalDownloads"`
}
Stats contains application statistics.
type UpdateVersionOptions ¶
type UpdateVersionOptions struct {
IsEnabled *bool `json:"isEnabled,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
ReleaseNotes *string `json:"releaseNotes,omitempty"`
}
UpdateVersionOptions contains options for updating a version.
type UploadResponse ¶
type UploadResponse struct {
Message string `json:"message"`
VersionID string `json:"versionId"`
ApplicationID string `json:"applicationId"`
Version string `json:"version"`
FileSize int64 `json:"fileSize"`
Checksum string `json:"checksum"`
}
UploadResponse is the response from uploading a file.
type Version ¶
type Version struct {
VersionID string `json:"versionId"`
ApplicationID string `json:"applicationId"`
Version string `json:"version"`
ReleaseNotes string `json:"releaseNotes,omitempty"`
IsActive bool `json:"isActive"`
IsEnabled bool `json:"isEnabled"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
FileSize int64 `json:"fileSize"`
DownloadCount int `json:"downloadCount"`
}
Version represents a version of an application.
type VersionFile ¶
type VersionFile struct {
FileID string `json:"fileId"`
FileName string `json:"fileName"`
FileType string `json:"fileType"`
FileSize int64 `json:"fileSize"`
Checksum string `json:"checksum"`
Order int `json:"order"`
Description string `json:"description,omitempty"`
}
VersionFile represents a file within a version.