components

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: AGPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type And added in v0.4.0

type And struct {
	And []PermissionQuery `json:"and"`
}

func (*And) GetAnd added in v0.4.0

func (o *And) GetAnd() []PermissionQuery

type Authorization

type Authorization struct {
	// A query for which permissions you require
	Permissions *PermissionQuery `json:"permissions,omitempty"`
}

Authorization - Perform RBAC checks

func (*Authorization) GetPermissions

func (o *Authorization) GetPermissions() *PermissionQuery

type Code

type Code string

Code - A machine readable code why the key is not valid. Possible values are: - VALID: the key is valid and you should proceed - NOT_FOUND: the key does not exist or has expired - FORBIDDEN: the key is not allowed to access the api - USAGE_EXCEEDED: the key has exceeded its request limit - RATE_LIMITED: the key has been ratelimited - UNAUTHORIZED: the key is not authorized - DISABLED: the key is disabled - INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action

const (
	CodeValid                   Code = "VALID"
	CodeNotFound                Code = "NOT_FOUND"
	CodeForbidden               Code = "FORBIDDEN"
	CodeUsageExceeded           Code = "USAGE_EXCEEDED"
	CodeRateLimited             Code = "RATE_LIMITED"
	CodeUnauthorized            Code = "UNAUTHORIZED"
	CodeDisabled                Code = "DISABLED"
	CodeInsufficientPermissions Code = "INSUFFICIENT_PERMISSIONS"
)

func (Code) ToPointer

func (e Code) ToPointer() *Code

func (*Code) UnmarshalJSON

func (e *Code) UnmarshalJSON(data []byte) error

type HTTPMetadata added in v0.3.0

type HTTPMetadata struct {
	// Raw HTTP response; suitable for custom response parsing
	Response *http.Response `json:"-"`
	// Raw HTTP request; suitable for debugging
	Request *http.Request `json:"-"`
}

func (*HTTPMetadata) GetRequest added in v0.3.0

func (o *HTTPMetadata) GetRequest() *http.Request

func (*HTTPMetadata) GetResponse added in v0.3.0

func (o *HTTPMetadata) GetResponse() *http.Response

type Interval

type Interval string

Interval - Determines the rate at which verifications will be refilled.

const (
	IntervalDaily   Interval = "daily"
	IntervalMonthly Interval = "monthly"
)

func (Interval) ToPointer

func (e Interval) ToPointer() *Interval

func (*Interval) UnmarshalJSON

func (e *Interval) UnmarshalJSON(data []byte) error

type Key

type Key struct {
	// The id of the key
	ID string `json:"id"`
	// The first few characters of the key to visually identify it
	Start string `json:"start"`
	// The id of the workspace that owns the key
	WorkspaceID string `json:"workspaceId"`
	// The id of the api that this key is for
	APIID *string `json:"apiId,omitempty"`
	// The name of the key, give keys a name to easily identify their purpose
	Name *string `json:"name,omitempty"`
	// The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
	OwnerID *string `json:"ownerId,omitempty"`
	// Any additional metadata you want to store with the key
	Meta map[string]any `json:"meta,omitempty"`
	// The unix timestamp in milliseconds when the key was created
	CreatedAt float64 `json:"createdAt"`
	// The unix timestamp in milliseconds when the key was last updated
	UpdatedAt *float64 `json:"updatedAt,omitempty"`
	// The unix timestamp in milliseconds when the key was deleted. We don't delete the key outright, you can restore it later.
	DeletedAt *float64 `json:"deletedAt,omitempty"`
	// The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
	Expires *float64 `json:"expires,omitempty"`
	// The number of requests that can be made with this key before it becomes invalid. If this field is null or undefined, the key has no request limit.
	Remaining *float64 `json:"remaining,omitempty"`
	// Unkey allows you to refill remaining verifications on a key on a regular interval.
	Refill *Refill `json:"refill,omitempty"`
	// Unkey comes with per-key ratelimiting out of the box.
	Ratelimit *Ratelimit `json:"ratelimit,omitempty"`
	// All roles this key belongs to
	Roles []string `json:"roles,omitempty"`
	// All permissions this key has
	Permissions []string `json:"permissions,omitempty"`
	// Sets if key is enabled or disabled. Disabled keys are not valid.
	Enabled *bool `json:"enabled,omitempty"`
	// The key in plaintext
	Plaintext *string `json:"plaintext,omitempty"`
}

func (*Key) GetAPIID

func (o *Key) GetAPIID() *string

func (*Key) GetCreatedAt

func (o *Key) GetCreatedAt() float64

func (*Key) GetDeletedAt

func (o *Key) GetDeletedAt() *float64

func (*Key) GetEnabled

func (o *Key) GetEnabled() *bool

func (*Key) GetExpires

func (o *Key) GetExpires() *float64

func (*Key) GetID

func (o *Key) GetID() string

func (*Key) GetMeta

func (o *Key) GetMeta() map[string]any

func (*Key) GetName

func (o *Key) GetName() *string

func (*Key) GetOwnerID

func (o *Key) GetOwnerID() *string

func (*Key) GetPermissions

func (o *Key) GetPermissions() []string

func (*Key) GetPlaintext added in v0.3.0

func (o *Key) GetPlaintext() *string

func (*Key) GetRatelimit

func (o *Key) GetRatelimit() *Ratelimit

func (*Key) GetRefill

func (o *Key) GetRefill() *Refill

func (*Key) GetRemaining

func (o *Key) GetRemaining() *float64

func (*Key) GetRoles

func (o *Key) GetRoles() []string

func (*Key) GetStart

func (o *Key) GetStart() string

func (*Key) GetUpdatedAt added in v0.3.0

func (o *Key) GetUpdatedAt() *float64

func (*Key) GetWorkspaceID

func (o *Key) GetWorkspaceID() string

type Or added in v0.4.0

type Or struct {
	Or []PermissionQuery `json:"or"`
}

func (*Or) GetOr added in v0.4.0

func (o *Or) GetOr() []PermissionQuery

type PermissionQuery added in v0.4.0

type PermissionQuery struct {
	Str *string
	And *And
	Or  *Or

	Type PermissionQueryType
}

PermissionQuery - A query for which permissions you require

func CreatePermissionQueryAnd added in v0.4.0

func CreatePermissionQueryAnd(and And) PermissionQuery

func CreatePermissionQueryOr added in v0.4.0

func CreatePermissionQueryOr(or Or) PermissionQuery

func CreatePermissionQueryStr added in v0.4.0

func CreatePermissionQueryStr(str string) PermissionQuery

func (PermissionQuery) MarshalJSON added in v0.4.0

func (u PermissionQuery) MarshalJSON() ([]byte, error)

func (*PermissionQuery) UnmarshalJSON added in v0.4.0

func (u *PermissionQuery) UnmarshalJSON(data []byte) error

type PermissionQueryType added in v0.4.0

type PermissionQueryType string
const (
	PermissionQueryTypeStr PermissionQueryType = "str"
	PermissionQueryTypeAnd PermissionQueryType = "And"
	PermissionQueryTypeOr  PermissionQueryType = "Or"
)

type Ratelimit

type Ratelimit struct {
	Async bool `json:"async"`
	// Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.
	Type *Type `json:"type,omitempty"`
	// The total amount of burstable requests.
	Limit int64 `json:"limit"`
	// How many tokens to refill during each refillInterval.
	RefillRate *int64 `json:"refillRate,omitempty"`
	// Determines the speed at which tokens are refilled, in milliseconds.
	RefillInterval *int64 `json:"refillInterval,omitempty"`
	// The duration of the ratelimit window, in milliseconds.
	Duration int64 `json:"duration"`
}

Ratelimit - Unkey comes with per-key ratelimiting out of the box.

func (*Ratelimit) GetAsync added in v0.3.0

func (o *Ratelimit) GetAsync() bool

func (*Ratelimit) GetDuration added in v0.3.0

func (o *Ratelimit) GetDuration() int64

func (*Ratelimit) GetLimit

func (o *Ratelimit) GetLimit() int64

func (*Ratelimit) GetRefillInterval

func (o *Ratelimit) GetRefillInterval() *int64

func (*Ratelimit) GetRefillRate

func (o *Ratelimit) GetRefillRate() *int64

func (*Ratelimit) GetType

func (o *Ratelimit) GetType() *Type

type Refill

type Refill struct {
	// Determines the rate at which verifications will be refilled.
	Interval Interval `json:"interval"`
	// Resets `remaining` to this value every interval.
	Amount int64 `json:"amount"`
	// The unix timestamp in miliseconds when the key was last refilled.
	LastRefillAt *float64 `json:"lastRefillAt,omitempty"`
}

Refill - Unkey allows you to refill remaining verifications on a key on a regular interval.

func (*Refill) GetAmount

func (o *Refill) GetAmount() int64

func (*Refill) GetInterval

func (o *Refill) GetInterval() Interval

func (*Refill) GetLastRefillAt

func (o *Refill) GetLastRefillAt() *float64

type Security

type Security struct {
	BearerAuth *string `security:"scheme,type=http,subtype=bearer,name=Authorization"`
}

func (*Security) GetBearerAuth

func (o *Security) GetBearerAuth() *string

type Type

type Type string

Type - Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.

https://unkey.dev/docs/features/ratelimiting - Learn more

const (
	TypeFast       Type = "fast"
	TypeConsistent Type = "consistent"
)

func (Type) ToPointer

func (e Type) ToPointer() *Type

func (*Type) UnmarshalJSON

func (e *Type) UnmarshalJSON(data []byte) error

type V1KeysVerifyKeyRequest

type V1KeysVerifyKeyRequest struct {
	// The id of the api where the key belongs to. This is optional for now but will be required soon.
	// The key will be verified against the api's configuration. If the key does not belong to the api, the verification will fail.
	APIID *string `json:"apiId,omitempty"`
	// The key to verify
	Key string `json:"key"`
	// Perform RBAC checks
	Authorization *Authorization                   `json:"authorization,omitempty"`
	Ratelimit     *V1KeysVerifyKeyRequestRatelimit `json:"ratelimit,omitempty"`
}

func (*V1KeysVerifyKeyRequest) GetAPIID

func (o *V1KeysVerifyKeyRequest) GetAPIID() *string

func (*V1KeysVerifyKeyRequest) GetAuthorization

func (o *V1KeysVerifyKeyRequest) GetAuthorization() *Authorization

func (*V1KeysVerifyKeyRequest) GetKey

func (o *V1KeysVerifyKeyRequest) GetKey() string

func (*V1KeysVerifyKeyRequest) GetRatelimit

type V1KeysVerifyKeyRequestRatelimit

type V1KeysVerifyKeyRequestRatelimit struct {
	// Override how many tokens are deducted during the ratelimit operation.
	Cost *int64 `default:"1" json:"cost"`
}

func (*V1KeysVerifyKeyRequestRatelimit) GetCost

func (o *V1KeysVerifyKeyRequestRatelimit) GetCost() *int64

func (V1KeysVerifyKeyRequestRatelimit) MarshalJSON

func (v V1KeysVerifyKeyRequestRatelimit) MarshalJSON() ([]byte, error)

func (*V1KeysVerifyKeyRequestRatelimit) UnmarshalJSON

func (v *V1KeysVerifyKeyRequestRatelimit) UnmarshalJSON(data []byte) error

type V1KeysVerifyKeyResponse

type V1KeysVerifyKeyResponse struct {
	// The id of the key
	KeyID *string `json:"keyId,omitempty"`
	// Whether the key is valid or not.
	// A key could be invalid for a number of reasons, for example if it has expired, has no more verifications left or if it has been deleted.
	Valid bool `json:"valid"`
	// The name of the key, give keys a name to easily identifiy their purpose
	Name *string `json:"name,omitempty"`
	// The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
	OwnerID *string `json:"ownerId,omitempty"`
	// Any additional metadata you want to store with the key
	Meta map[string]any `json:"meta,omitempty"`
	// The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
	Expires *int64 `json:"expires,omitempty"`
	// The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit.
	Ratelimit *V1KeysVerifyKeyResponseRatelimit `json:"ratelimit,omitempty"`
	// The number of requests that can be made with this key before it becomes invalid. If this field is null or undefined, the key has no request limit.
	Remaining *int64 `json:"remaining,omitempty"`
	// A machine readable code why the key is not valid.
	// Possible values are:
	// - VALID: the key is valid and you should proceed
	// - NOT_FOUND: the key does not exist or has expired
	// - FORBIDDEN: the key is not allowed to access the api
	// - USAGE_EXCEEDED: the key has exceeded its request limit
	// - RATE_LIMITED: the key has been ratelimited
	// - UNAUTHORIZED: the key is not authorized
	// - DISABLED: the key is disabled
	// - INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action
	//
	Code Code `json:"code"`
	// Sets the key to be enabled or disabled. Disabled keys will not verify.
	Enabled *bool `json:"enabled,omitempty"`
	// A list of all the permissions this key is connected to.
	Permissions []string `json:"permissions,omitempty"`
	// The environment of the key, this is what what you set when you crated the key
	Environment *string `json:"environment,omitempty"`
}

func (*V1KeysVerifyKeyResponse) GetCode

func (o *V1KeysVerifyKeyResponse) GetCode() Code

func (*V1KeysVerifyKeyResponse) GetEnabled

func (o *V1KeysVerifyKeyResponse) GetEnabled() *bool

func (*V1KeysVerifyKeyResponse) GetEnvironment

func (o *V1KeysVerifyKeyResponse) GetEnvironment() *string

func (*V1KeysVerifyKeyResponse) GetExpires

func (o *V1KeysVerifyKeyResponse) GetExpires() *int64

func (*V1KeysVerifyKeyResponse) GetKeyID

func (o *V1KeysVerifyKeyResponse) GetKeyID() *string

func (*V1KeysVerifyKeyResponse) GetMeta

func (o *V1KeysVerifyKeyResponse) GetMeta() map[string]any

func (*V1KeysVerifyKeyResponse) GetName

func (o *V1KeysVerifyKeyResponse) GetName() *string

func (*V1KeysVerifyKeyResponse) GetOwnerID

func (o *V1KeysVerifyKeyResponse) GetOwnerID() *string

func (*V1KeysVerifyKeyResponse) GetPermissions

func (o *V1KeysVerifyKeyResponse) GetPermissions() []string

func (*V1KeysVerifyKeyResponse) GetRatelimit

func (*V1KeysVerifyKeyResponse) GetRemaining

func (o *V1KeysVerifyKeyResponse) GetRemaining() *int64

func (*V1KeysVerifyKeyResponse) GetValid

func (o *V1KeysVerifyKeyResponse) GetValid() bool

type V1KeysVerifyKeyResponseRatelimit

type V1KeysVerifyKeyResponseRatelimit struct {
	// Maximum number of requests that can be made inside a window
	Limit int64 `json:"limit"`
	// Remaining requests after this verification
	Remaining int64 `json:"remaining"`
	// Unix timestamp in milliseconds when the ratelimit will reset
	Reset int64 `json:"reset"`
}

V1KeysVerifyKeyResponseRatelimit - The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit.

func (*V1KeysVerifyKeyResponseRatelimit) GetLimit

func (*V1KeysVerifyKeyResponseRatelimit) GetRemaining

func (o *V1KeysVerifyKeyResponseRatelimit) GetRemaining() int64

func (*V1KeysVerifyKeyResponseRatelimit) GetReset

Jump to

Keyboard shortcuts

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