Documentation
¶
Index ¶
Constants ¶
View Source
const ( CapabilityReadMETARs bitflag.Flag = 1 << iota CapabilityFeedMETARs )
Variables ¶
View Source
var MaxDescriptionLength = 100
MaxDescriptionLength defines the maximum length an API key description may have
Functions ¶
func SanitizeDescription ¶
SanitizeDescription sanitizes a description by turning it into a valid UTF8 string, trimming leading and trailing spaces, replacing newlines with spaces and stripping it to the maximum length a description may have
Types ¶
type Create ¶
type Create struct {
UserID string
Description string
Quota int64
RateLimit int
Capabilities bitflag.Container
}
Create is used to create a new API key
type Key ¶
type Key struct {
ID uuid.UUID `json:"id"`
Key []byte `json:"-"`
UserID string `json:"user_id"`
Description string `json:"description"`
Quota int64 `json:"quota"`
UsedQuota int64 `json:"used_quota"`
RateLimit int `json:"rate_limit"`
Capabilities bitflag.Container `json:"capabilities"`
}
Key represents an API key used to access the data API
type Repository ¶
type Repository interface {
// Get retrieves multiple API keys
Get(ctx context.Context, offset, limit uint64) ([]*Key, uint64, error)
// GetByUserID retrieves multiple API keys of a specific user
GetByUserID(ctx context.Context, userID string, offset, limit uint64) ([]*Key, uint64, error)
// GetByID retrieves an API key by its ID
GetByID(ctx context.Context, id uuid.UUID) (*Key, error)
// GetByRawKey retrieves an API key by the raw bearer token
GetByRawKey(ctx context.Context, key string) (*Key, error)
// Create creates a new API key
Create(ctx context.Context, create *Create) (*Key, string, error)
// Update updates an API key
Update(ctx context.Context, id uuid.UUID, update *Update) (*Key, error)
// UpdateManyQuotas updates many used API quotas at once
UpdateManyQuotas(ctx context.Context, updates map[uuid.UUID]int64) error
// Delete deletes an API key by its ID
Delete(ctx context.Context, id uuid.UUID) error
}
Repository defines the API key repository API
Click to show internal directories.
Click to hide internal directories.