models

package
v0.0.0-...-eb082ec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package models contains generated code for schema 'unkey'.

Index

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 Logf

func Logf(s string, v ...interface{})

Logf logs a message using the package 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

func SetLogger

func SetLogger(logger interface{})

SetLogger sets the package 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

func APIByID(ctx context.Context, db DB, id string) (*API, error)

APIByID retrieves a row from 'unkey.apis' as a API.

Generated from index 'apis_id_pkey'.

func APIByKeyAuthID

func APIByKeyAuthID(ctx context.Context, db DB, keyAuthID sql.NullString) (*API, error)

APIByKeyAuthID retrieves a row from 'unkey.apis' as a API.

Generated from index 'key_auth_id_idx'.

func (*API) Delete

func (a *API) Delete(ctx context.Context, db DB) error

Delete deletes the API from the database.

func (*API) Deleted

func (a *API) Deleted() bool

Deleted returns true when the API has been marked for deletion from the database.

func (*API) Exists

func (a *API) Exists() bool

Exists returns true when the API exists in the database.

func (*API) Insert

func (a *API) Insert(ctx context.Context, db DB) error

Insert inserts the API to the database.

func (*API) Save

func (a *API) Save(ctx context.Context, db DB) error

Save saves the API to the database.

func (*API) Update

func (a *API) Update(ctx context.Context, db DB) error

Update updates a API in the database.

func (*API) Upsert

func (a *API) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for API.

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

func (at AuthType) MarshalText() ([]byte, error)

MarshalText marshals AuthType into text.

func (*AuthType) Scan

func (at *AuthType) Scan(v interface{}) error

Scan satisfies the sql.Scanner interface.

func (AuthType) String

func (at AuthType) String() string

String satisfies the fmt.Stringer interface.

func (*AuthType) UnmarshalText

func (at *AuthType) UnmarshalText(buf []byte) error

UnmarshalText unmarshals AuthType from text.

func (AuthType) Value

func (at AuthType) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

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.

func (Error) Error

func (err Error) Error() string

Error satisfies the error interface.

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

func KeyByHash(ctx context.Context, db DB, hash string) (*Key, error)

KeyByHash retrieves a row from 'unkey.keys' as a Key.

Generated from index 'hash_idx'.

func KeyByID

func KeyByID(ctx context.Context, db DB, id string) (*Key, error)

KeyByID retrieves a row from 'unkey.keys' as a Key.

Generated from index 'keys_id_pkey'.

func KeysByKeyAuthID

func KeysByKeyAuthID(ctx context.Context, db DB, keyAuthID sql.NullString) ([]*Key, error)

KeysByKeyAuthID retrieves a row from 'unkey.keys' as a Key.

Generated from index 'key_auth_id_idx'.

func (*Key) Delete

func (k *Key) Delete(ctx context.Context, db DB) error

Delete deletes the Key from the database.

func (*Key) Deleted

func (k *Key) Deleted() bool

Deleted returns true when the Key has been marked for deletion from the database.

func (*Key) Exists

func (k *Key) Exists() bool

Exists returns true when the Key exists in the database.

func (*Key) Insert

func (k *Key) Insert(ctx context.Context, db DB) error

Insert inserts the Key to the database.

func (*Key) Save

func (k *Key) Save(ctx context.Context, db DB) error

Save saves the Key to the database.

func (*Key) Update

func (k *Key) Update(ctx context.Context, db DB) error

Update updates a Key in the database.

func (*Key) Upsert

func (k *Key) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for Key.

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

func KeyAuthByID(ctx context.Context, db DB, id string) (*KeyAuth, error)

KeyAuthByID retrieves a row from 'unkey.key_auth' as a KeyAuth.

Generated from index 'key_auth_id_pkey'.

func (*KeyAuth) Delete

func (ka *KeyAuth) Delete(ctx context.Context, db DB) error

Delete deletes the KeyAuth from the database.

func (*KeyAuth) Deleted

func (ka *KeyAuth) Deleted() bool

Deleted returns true when the KeyAuth has been marked for deletion from the database.

func (*KeyAuth) Exists

func (ka *KeyAuth) Exists() bool

Exists returns true when the KeyAuth exists in the database.

func (*KeyAuth) Insert

func (ka *KeyAuth) Insert(ctx context.Context, db DB) error

Insert inserts the KeyAuth to the database.

func (*KeyAuth) Save

func (ka *KeyAuth) Save(ctx context.Context, db DB) error

Save saves the KeyAuth to the database.

func (*KeyAuth) Update

func (ka *KeyAuth) Update(ctx context.Context, db DB) error

Update updates a KeyAuth in the database.

func (*KeyAuth) Upsert

func (ka *KeyAuth) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for KeyAuth.

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

type NullPlan struct {
	Plan Plan
	// Valid is true if [Plan] is not null.
	Valid bool
}

NullPlan represents a null 'plan' enum for schema 'unkey'.

func (*NullPlan) Scan

func (np *NullPlan) Scan(v interface{}) error

Scan satisfies the sql.Scanner interface.

func (NullPlan) Value

func (np NullPlan) Value() (driver.Value, error)

Value satisfies the driver.Valuer 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

func (p Plan) MarshalText() ([]byte, error)

MarshalText marshals Plan into text.

func (*Plan) Scan

func (p *Plan) Scan(v interface{}) error

Scan satisfies the sql.Scanner interface.

func (Plan) String

func (p Plan) String() string

String satisfies the fmt.Stringer interface.

func (*Plan) UnmarshalText

func (p *Plan) UnmarshalText(buf []byte) error

UnmarshalText unmarshals Plan from text.

func (Plan) Value

func (p Plan) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

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

func PolicyByID(ctx context.Context, db DB, id string) (*Policy, error)

PolicyByID retrieves a row from 'unkey.policies' as a Policy.

Generated from index 'policies_id_pkey'.

func (*Policy) Delete

func (p *Policy) Delete(ctx context.Context, db DB) error

Delete deletes the Policy from the database.

func (*Policy) Deleted

func (p *Policy) Deleted() bool

Deleted returns true when the Policy has been marked for deletion from the database.

func (*Policy) Exists

func (p *Policy) Exists() bool

Exists returns true when the Policy exists in the database.

func (*Policy) Insert

func (p *Policy) Insert(ctx context.Context, db DB) error

Insert inserts the Policy to the database.

func (*Policy) Save

func (p *Policy) Save(ctx context.Context, db DB) error

Save saves the Policy to the database.

func (*Policy) Update

func (p *Policy) Update(ctx context.Context, db DB) error

Update updates a Policy in the database.

func (*Policy) Upsert

func (p *Policy) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for Policy.

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

func WorkspaceByID(ctx context.Context, db DB, id string) (*Workspace, error)

WorkspaceByID retrieves a row from 'unkey.workspaces' as a Workspace.

Generated from index 'workspaces_id_pkey'.

func WorkspaceBySlug

func WorkspaceBySlug(ctx context.Context, db DB, slug string) (*Workspace, error)

WorkspaceBySlug retrieves a row from 'unkey.workspaces' as a Workspace.

Generated from index 'slug_idx'.

func WorkspaceByTenantID

func WorkspaceByTenantID(ctx context.Context, db DB, tenantID string) (*Workspace, error)

WorkspaceByTenantID retrieves a row from 'unkey.workspaces' as a Workspace.

Generated from index 'tenant_id_idx'.

func (*Workspace) Delete

func (w *Workspace) Delete(ctx context.Context, db DB) error

Delete deletes the Workspace from the database.

func (*Workspace) Deleted

func (w *Workspace) Deleted() bool

Deleted returns true when the Workspace has been marked for deletion from the database.

func (*Workspace) Exists

func (w *Workspace) Exists() bool

Exists returns true when the Workspace exists in the database.

func (*Workspace) Insert

func (w *Workspace) Insert(ctx context.Context, db DB) error

Insert inserts the Workspace to the database.

func (*Workspace) Save

func (w *Workspace) Save(ctx context.Context, db DB) error

Save saves the Workspace to the database.

func (*Workspace) Update

func (w *Workspace) Update(ctx context.Context, db DB) error

Update updates a Workspace in the database.

func (*Workspace) Upsert

func (w *Workspace) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for Workspace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL