Documentation ¶
Overview ¶
Package models contains generated code for schema 'unkey'.
Index ¶
- func Errorf(s string, v ...interface{})
- func Logf(s string, v ...interface{})
- func SetErrorLogger(logger interface{})
- func SetLogger(logger interface{})
- type API
- func (a *API) Delete(ctx context.Context, db DB) error
- func (a *API) Deleted() bool
- func (a *API) Exists() bool
- func (a *API) Insert(ctx context.Context, db DB) error
- func (a *API) Save(ctx context.Context, db DB) error
- func (a *API) Update(ctx context.Context, db DB) error
- func (a *API) Upsert(ctx context.Context, db DB) error
- type AuthType
- type DB
- type ErrInsertFailed
- type ErrInvalidAuthType
- type ErrInvalidPlan
- type ErrUpdateFailed
- type ErrUpsertFailed
- type Error
- type Key
- func (k *Key) Delete(ctx context.Context, db DB) error
- func (k *Key) Deleted() bool
- func (k *Key) Exists() bool
- func (k *Key) Insert(ctx context.Context, db DB) error
- func (k *Key) Save(ctx context.Context, db DB) error
- func (k *Key) Update(ctx context.Context, db DB) error
- func (k *Key) Upsert(ctx context.Context, db DB) error
- type KeyAuth
- func (ka *KeyAuth) Delete(ctx context.Context, db DB) error
- func (ka *KeyAuth) Deleted() bool
- func (ka *KeyAuth) Exists() bool
- func (ka *KeyAuth) Insert(ctx context.Context, db DB) error
- func (ka *KeyAuth) Save(ctx context.Context, db DB) error
- func (ka *KeyAuth) Update(ctx context.Context, db DB) error
- func (ka *KeyAuth) Upsert(ctx context.Context, db DB) error
- type KeysToPolicy
- type NullAuthType
- type NullPlan
- type Plan
- type Policy
- func (p *Policy) Delete(ctx context.Context, db DB) error
- func (p *Policy) Deleted() bool
- func (p *Policy) Exists() bool
- func (p *Policy) Insert(ctx context.Context, db DB) error
- func (p *Policy) Save(ctx context.Context, db DB) error
- func (p *Policy) Update(ctx context.Context, db DB) error
- func (p *Policy) Upsert(ctx context.Context, db DB) error
- type Workspace
- func (w *Workspace) Delete(ctx context.Context, db DB) error
- func (w *Workspace) Deleted() bool
- func (w *Workspace) Exists() bool
- func (w *Workspace) Insert(ctx context.Context, db DB) error
- func (w *Workspace) Save(ctx context.Context, db DB) error
- func (w *Workspace) Update(ctx context.Context, db DB) error
- func (w *Workspace) Upsert(ctx context.Context, db DB) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
func Errorf(s string, v ...interface{})
Errorf logs an error message using the package error logger.
func SetErrorLogger ¶
func SetErrorLogger(logger interface{})
SetErrorLogger sets the package error logger. Valid logger types:
io.Writer func(string, ...interface{}) (int, error) // fmt.Printf func(string, ...interface{}) // log.Printf
Types ¶
type API ¶
type API struct { ID string `json:"id"` // id Name string `json:"name"` // name WorkspaceID string `json:"workspace_id"` // workspace_id IPWhitelist sql.NullString `json:"ip_whitelist"` // ip_whitelist AuthType NullAuthType `json:"auth_type"` // auth_type KeyAuthID sql.NullString `json:"key_auth_id"` // key_auth_id // contains filtered or unexported fields }
API represents a row from 'unkey.apis'.
func APIByID ¶
APIByID retrieves a row from 'unkey.apis' as a API.
Generated from index 'apis_id_pkey'.
func APIByKeyAuthID ¶
APIByKeyAuthID retrieves a row from 'unkey.apis' as a API.
Generated from index 'key_auth_id_idx'.
func (*API) Deleted ¶
Deleted returns true when the API has been marked for deletion from the database.
type AuthType ¶
type AuthType uint16
AuthType is the 'auth_type' enum type from schema 'unkey'.
const ( // AuthTypeKey is the 'key' auth_type. AuthTypeKey AuthType = 1 // AuthTypeJwt is the 'jwt' auth_type. AuthTypeJwt AuthType = 2 )
AuthType values.
func (AuthType) MarshalText ¶
MarshalText marshals AuthType into text.
func (*AuthType) Scan ¶
Scan satisfies the sql.Scanner interface.
func (AuthType) String ¶
String satisfies the fmt.Stringer interface.
func (*AuthType) UnmarshalText ¶
UnmarshalText unmarshals AuthType from text.
type DB ¶
type DB interface { ExecContext(context.Context, string, ...interface{}) (sql.Result, error) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) QueryRowContext(context.Context, string, ...interface{}) *sql.Row }
DB is the common interface for database operations that can be used with types from schema 'unkey'.
This works with both database/sql.DB and database/sql.Tx.
type ErrInsertFailed ¶
type ErrInsertFailed struct {
Err error
}
ErrInsertFailed is the insert failed error.
func (*ErrInsertFailed) Error ¶
func (err *ErrInsertFailed) Error() string
Error satisfies the error interface.
func (*ErrInsertFailed) Unwrap ¶
func (err *ErrInsertFailed) Unwrap() error
Unwrap satisfies the unwrap interface.
type ErrInvalidAuthType ¶
type ErrInvalidAuthType string
ErrInvalidAuthType is the invalid AuthType error.
func (ErrInvalidAuthType) Error ¶
func (err ErrInvalidAuthType) Error() string
Error satisfies the error interface.
type ErrInvalidPlan ¶
type ErrInvalidPlan string
ErrInvalidPlan is the invalid Plan error.
func (ErrInvalidPlan) Error ¶
func (err ErrInvalidPlan) Error() string
Error satisfies the error interface.
type ErrUpdateFailed ¶
type ErrUpdateFailed struct {
Err error
}
ErrUpdateFailed is the update failed error.
func (*ErrUpdateFailed) Error ¶
func (err *ErrUpdateFailed) Error() string
Error satisfies the error interface.
func (*ErrUpdateFailed) Unwrap ¶
func (err *ErrUpdateFailed) Unwrap() error
Unwrap satisfies the unwrap interface.
type ErrUpsertFailed ¶
type ErrUpsertFailed struct {
Err error
}
ErrUpsertFailed is the upsert failed error.
func (*ErrUpsertFailed) Error ¶
func (err *ErrUpsertFailed) Error() string
Error satisfies the error interface.
func (*ErrUpsertFailed) Unwrap ¶
func (err *ErrUpsertFailed) Unwrap() error
Unwrap satisfies the unwrap interface.
type Error ¶
type Error string
Error is an error.
const ( // ErrAlreadyExists is the already exists error. ErrAlreadyExists Error = "already exists" // ErrDoesNotExist is the does not exist error. ErrDoesNotExist Error = "does not exist" // ErrMarkedForDeletion is the marked for deletion error. ErrMarkedForDeletion Error = "marked for deletion" )
Error values.
type Key ¶
type Key struct { ID string `json:"id"` // id Hash string `json:"hash"` // hash Start string `json:"start"` // start OwnerID sql.NullString `json:"owner_id"` // owner_id Meta sql.NullString `json:"meta"` // meta CreatedAt time.Time `json:"created_at"` // created_at Expires sql.NullTime `json:"expires"` // expires RatelimitType sql.NullString `json:"ratelimit_type"` // ratelimit_type RatelimitLimit sql.NullInt64 `json:"ratelimit_limit"` // ratelimit_limit RatelimitRefillRate sql.NullInt64 `json:"ratelimit_refill_rate"` // ratelimit_refill_rate RatelimitRefillInterval sql.NullInt64 `json:"ratelimit_refill_interval"` // ratelimit_refill_interval WorkspaceID string `json:"workspace_id"` // workspace_id ForWorkspaceID sql.NullString `json:"for_workspace_id"` // for_workspace_id Name sql.NullString `json:"name"` // name RemainingRequests sql.NullInt64 `json:"remaining_requests"` // remaining_requests KeyAuthID sql.NullString `json:"key_auth_id"` // key_auth_id // contains filtered or unexported fields }
Key represents a row from 'unkey.keys'.
func KeyByHash ¶
KeyByHash retrieves a row from 'unkey.keys' as a Key.
Generated from index 'hash_idx'.
func KeyByID ¶
KeyByID retrieves a row from 'unkey.keys' as a Key.
Generated from index 'keys_id_pkey'.
func KeysByKeyAuthID ¶
KeysByKeyAuthID retrieves a row from 'unkey.keys' as a Key.
Generated from index 'key_auth_id_idx'.
func (*Key) Deleted ¶
Deleted returns true when the Key has been marked for deletion from the database.
type KeyAuth ¶
type KeyAuth struct { ID string `json:"id"` // id WorkspaceID string `json:"workspace_id"` // workspace_id // contains filtered or unexported fields }
KeyAuth represents a row from 'unkey.key_auth'.
func KeyAuthByID ¶
KeyAuthByID retrieves a row from 'unkey.key_auth' as a KeyAuth.
Generated from index 'key_auth_id_pkey'.
func (*KeyAuth) Deleted ¶
Deleted returns true when the KeyAuth has been marked for deletion from the database.
type KeysToPolicy ¶
type KeysToPolicy struct { KeyID string `json:"key_id"` // key_id PolicyID string `json:"policy_id"` // policy_id // contains filtered or unexported fields }
KeysToPolicy represents a row from 'unkey.keys_to_policies'.
func KeysToPolicyByKeyIDPolicyID ¶
func KeysToPolicyByKeyIDPolicyID(ctx context.Context, db DB, keyID, policyID string) (*KeysToPolicy, error)
KeysToPolicyByKeyIDPolicyID retrieves a row from 'unkey.keys_to_policies' as a KeysToPolicy.
Generated from index 'keys_to_policies_key_id_policy_id_pkey'.
func (*KeysToPolicy) Delete ¶
func (ktp *KeysToPolicy) Delete(ctx context.Context, db DB) error
Delete deletes the KeysToPolicy from the database.
func (*KeysToPolicy) Deleted ¶
func (ktp *KeysToPolicy) Deleted() bool
Deleted returns true when the KeysToPolicy has been marked for deletion from the database.
func (*KeysToPolicy) Exists ¶
func (ktp *KeysToPolicy) Exists() bool
Exists returns true when the KeysToPolicy exists in the database.
func (*KeysToPolicy) Insert ¶
func (ktp *KeysToPolicy) Insert(ctx context.Context, db DB) error
Insert inserts the KeysToPolicy to the database.
type NullAuthType ¶
type NullAuthType struct { AuthType AuthType // Valid is true if [AuthType] is not null. Valid bool }
NullAuthType represents a null 'auth_type' enum for schema 'unkey'.
func (*NullAuthType) Scan ¶
func (nat *NullAuthType) Scan(v interface{}) error
Scan satisfies the sql.Scanner interface.
func (NullAuthType) Value ¶
func (nat NullAuthType) Value() (driver.Value, error)
Value satisfies the driver.Valuer interface.
type NullPlan ¶
NullPlan represents a null 'plan' enum for schema 'unkey'.
func (*NullPlan) Scan ¶
Scan satisfies the sql.Scanner interface.
type Plan ¶
type Plan uint16
Plan is the 'plan' enum type from schema 'unkey'.
const ( // PlanFree is the 'free' plan. PlanFree Plan = 1 // PlanPro is the 'pro' plan. PlanPro Plan = 2 // PlanEnterprise is the 'enterprise' plan. PlanEnterprise Plan = 3 )
Plan values.
func (Plan) MarshalText ¶
MarshalText marshals Plan into text.
func (*Plan) Scan ¶
Scan satisfies the sql.Scanner interface.
func (*Plan) UnmarshalText ¶
UnmarshalText unmarshals Plan from text.
type Policy ¶
type Policy struct { ID string `json:"id"` // id Name sql.NullString `json:"name"` // name APIID sql.NullString `json:"api_id"` // api_id CreatedAt time.Time `json:"created_at"` // created_at UpdatedAt time.Time `json:"updated_at"` // updated_at Version string `json:"version"` // version Policy json.RawMessage `json:"policy"` // policy // contains filtered or unexported fields }
Policy represents a row from 'unkey.policies'.
func PolicyByID ¶
PolicyByID retrieves a row from 'unkey.policies' as a Policy.
Generated from index 'policies_id_pkey'.
func (*Policy) Deleted ¶
Deleted returns true when the Policy has been marked for deletion from the database.
type Workspace ¶
type Workspace struct { ID string `json:"id"` // id Name string `json:"name"` // name Slug string `json:"slug"` // slug TenantID string `json:"tenant_id"` // tenant_id Internal bool `json:"internal"` // internal StripeCustomerID sql.NullString `json:"stripe_customer_id"` // stripe_customer_id StripeSubscriptionID sql.NullString `json:"stripe_subscription_id"` // stripe_subscription_id Plan NullPlan `json:"plan"` // plan // contains filtered or unexported fields }
Workspace represents a row from 'unkey.workspaces'.
func WorkspaceByID ¶
WorkspaceByID retrieves a row from 'unkey.workspaces' as a Workspace.
Generated from index 'workspaces_id_pkey'.
func WorkspaceBySlug ¶
WorkspaceBySlug retrieves a row from 'unkey.workspaces' as a Workspace.
Generated from index 'slug_idx'.
func WorkspaceByTenantID ¶
WorkspaceByTenantID retrieves a row from 'unkey.workspaces' as a Workspace.
Generated from index 'tenant_id_idx'.
func (*Workspace) Deleted ¶
Deleted returns true when the Workspace has been marked for deletion from the database.