Documentation
¶
Index ¶
- Constants
- func InitCacheDB(ctx context.Context, db *sql.DB) error
- func Login(ctx context.Context, w io.Writer) (string, error)
- func SaveRateLimitState(state *RateLimitState) error
- type CacheReader
- func (r *CacheReader) Close() error
- func (r *CacheReader) GetNexusFileInfo(gameDomain string, modID int64, fileID int64) (*dbc.GetNexusFileInfoRow, error)
- func (r *CacheReader) GetNexusFileInfoFetchedAt(gameDomain string, modID int64) (string, error)
- func (r *CacheReader) GetNexusFileUpdateChain(gameDomain string, modID int64) ([]dbc.GetNexusFileUpdateChainRow, error)
- func (r *CacheReader) GetNexusModInfo(gameDomain string, modID int64) (*dbc.NexusModInfo, error)
- type Client
- func (c *Client) GetMod(gameDomain string, modID int64) (*ModInfo, error)
- func (c *Client) GetModCached(gameDomain string, modID int64) (*ModInfo, error)
- func (c *Client) GetModFiles(gameDomain string, modID int64) (*ModFilesResponse, error)
- func (c *Client) GetModFilesCached(gameDomain string, modID int64) (*ModFilesResponse, error)
- func (c *Client) RateLimitState() (*RateLimitState, error)
- func (c *Client) ValidateUser() (*UserInfo, error)
- type FileUpdateInfo
- type ModFileInfo
- type ModFilesResponse
- type ModInfo
- type RateLimitState
- type UserInfo
Constants ¶
const ( ModInfoTTL = 7 * 24 * time.Hour ModFilesTTL = 24 * time.Hour )
const ( AppSlug = "modctl-modctl" DefaultSSOTimeout = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func InitCacheDB ¶ added in v0.7.0
InitCacheDB initializes or resets the nexus cache database schema. It is exported for use by the exporter when constructing scoped cache databases for export bundles.
func Login ¶ added in v0.3.0
Login runs the Nexus Mods SSO flow and returns the API key. Progress messages are written to w. The caller should wrap ctx with a timeout before calling (DefaultSSOTimeout is the recommended value)
func SaveRateLimitState ¶
func SaveRateLimitState(state *RateLimitState) error
Types ¶
type CacheReader ¶
type CacheReader struct {
// contains filtered or unexported fields
}
CacheReader provides read-only access to the Nexus cache DB. Use this when you need cache data but don't need to make API calls.
func NewCacheReader ¶
func (*CacheReader) Close ¶
func (r *CacheReader) Close() error
func (*CacheReader) GetNexusFileInfo ¶
func (r *CacheReader) GetNexusFileInfo(gameDomain string, modID int64, fileID int64) (*dbc.GetNexusFileInfoRow, error)
func (*CacheReader) GetNexusFileInfoFetchedAt ¶
func (r *CacheReader) GetNexusFileInfoFetchedAt(gameDomain string, modID int64) (string, error)
func (*CacheReader) GetNexusFileUpdateChain ¶
func (r *CacheReader) GetNexusFileUpdateChain(gameDomain string, modID int64) ([]dbc.GetNexusFileUpdateChainRow, error)
func (*CacheReader) GetNexusModInfo ¶
func (r *CacheReader) GetNexusModInfo(gameDomain string, modID int64) (*dbc.NexusModInfo, error)
type Client ¶
type Client struct {
CacheReader
// contains filtered or unexported fields
}
func (*Client) GetModCached ¶
func (*Client) GetModFiles ¶
func (c *Client) GetModFiles(gameDomain string, modID int64) (*ModFilesResponse, error)
func (*Client) GetModFilesCached ¶
func (c *Client) GetModFilesCached(gameDomain string, modID int64) (*ModFilesResponse, error)
func (*Client) RateLimitState ¶
func (c *Client) RateLimitState() (*RateLimitState, error)
func (*Client) ValidateUser ¶ added in v0.3.0
ValidateUser calls /v1/users/validate.json to confirm the configured API key is valid and returns basic user info. Rate limit headers from this response are persisted as a side effect via doRequest. This endpoint does not count against the Nexus rate limit quota.
type FileUpdateInfo ¶
type ModFileInfo ¶
type ModFileInfo struct {
FileID int64 `json:"file_id"`
Name string `json:"name"`
Version string `json:"version"`
CategoryName string `json:"category_name"`
IsPrimary bool `json:"is_primary"`
FileName string `json:"file_name"`
SizeInBytes int64 `json:"size_in_bytes"`
UploadedTimestamp int64 `json:"uploaded_timestamp"`
}
type ModFilesResponse ¶
type ModFilesResponse struct {
Files []ModFileInfo `json:"files"`
FileUpdates []FileUpdateInfo `json:"file_updates"`
RawJSON []byte `json:"-"`
}
ModFilesResponse represents the fields we care about from /v1/games/{domain}/mods/{id}/files.json
type ModInfo ¶
type ModInfo struct {
ModID int64 `json:"mod_id"`
Name string `json:"name"`
Summary string `json:"summary"`
Author string `json:"author"`
DomainName string `json:"domain_name"`
Version string `json:"version"`
IsAvailable bool `json:"available"`
RawJSON []byte `json:"-"`
}
ModInfo represents the fields we care about from /v1/games/{domain}/mods/{id}.json
type RateLimitState ¶
type RateLimitState struct {
HourlyLimit int `json:"hourly_limit"`
HourlyRemaining int `json:"hourly_remaining"`
HourlyReset time.Time `json:"hourly_reset"`
DailyLimit int `json:"daily_limit"`
DailyRemaining int `json:"daily_remaining"`
DailyReset time.Time `json:"daily_reset"`
}
func LoadRateLimitState ¶
func LoadRateLimitState() (*RateLimitState, error)
func (*RateLimitState) EffectiveRemaining ¶
func (r *RateLimitState) EffectiveRemaining() (hourly, daily int)
EffectiveRemaining returns the remaining counts, treating expired windows as fully refreshed
type UserInfo ¶ added in v0.3.0
type UserInfo struct {
UserID int64 `json:"user_id"`
Name string `json:"name"`
// IsPremium and IsSupporter are present in two forms in the API response
// ("is_premium?" and "is_premium"). We decode both and prefer the
// non-punctuated form.
IsPremium bool `json:"is_premium"`
IsSupporter bool `json:"is_supporter"`
// Punctuated variants (decoded but not used directly)
IsPremiumAlt bool `json:"is_premium?"`
IsSupporterAlt bool `json:"is_supporter?"`
}
UserInfo contains the fields from /v1/users/validate.json that we surface. The validate endpoint does not count against the Nexus rate limit.