Documentation ¶
Index ¶
- type And
- type Authorization
- type Code
- type HTTPMetadata
- type Interval
- type Key
- func (o *Key) GetAPIID() *string
- func (o *Key) GetCreatedAt() float64
- func (o *Key) GetDeletedAt() *float64
- func (o *Key) GetEnabled() *bool
- func (o *Key) GetExpires() *float64
- func (o *Key) GetID() string
- func (o *Key) GetMeta() map[string]any
- func (o *Key) GetName() *string
- func (o *Key) GetOwnerID() *string
- func (o *Key) GetPermissions() []string
- func (o *Key) GetPlaintext() *string
- func (o *Key) GetRatelimit() *Ratelimit
- func (o *Key) GetRefill() *Refill
- func (o *Key) GetRemaining() *float64
- func (o *Key) GetRoles() []string
- func (o *Key) GetStart() string
- func (o *Key) GetUpdatedAt() *float64
- func (o *Key) GetWorkspaceID() string
- type Or
- type PermissionQuery
- type PermissionQueryType
- type Ratelimit
- type Refill
- type Security
- type Type
- type V1KeysVerifyKeyRequest
- type V1KeysVerifyKeyRequestRatelimit
- type V1KeysVerifyKeyResponse
- func (o *V1KeysVerifyKeyResponse) GetCode() Code
- func (o *V1KeysVerifyKeyResponse) GetEnabled() *bool
- func (o *V1KeysVerifyKeyResponse) GetEnvironment() *string
- func (o *V1KeysVerifyKeyResponse) GetExpires() *int64
- func (o *V1KeysVerifyKeyResponse) GetKeyID() *string
- func (o *V1KeysVerifyKeyResponse) GetMeta() map[string]any
- func (o *V1KeysVerifyKeyResponse) GetName() *string
- func (o *V1KeysVerifyKeyResponse) GetOwnerID() *string
- func (o *V1KeysVerifyKeyResponse) GetPermissions() []string
- func (o *V1KeysVerifyKeyResponse) GetRatelimit() *V1KeysVerifyKeyResponseRatelimit
- func (o *V1KeysVerifyKeyResponse) GetRemaining() *int64
- func (o *V1KeysVerifyKeyResponse) GetValid() bool
- type V1KeysVerifyKeyResponseRatelimit
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
func (*Code) UnmarshalJSON ¶
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.
func (*Interval) UnmarshalJSON ¶
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) GetCreatedAt ¶
func (*Key) GetDeletedAt ¶
func (*Key) GetEnabled ¶
func (*Key) GetExpires ¶
func (*Key) GetOwnerID ¶
func (*Key) GetPermissions ¶
func (*Key) GetPlaintext ¶ added in v0.3.0
func (*Key) GetRatelimit ¶
func (*Key) GetRemaining ¶
func (*Key) GetUpdatedAt ¶ added in v0.3.0
func (*Key) GetWorkspaceID ¶
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) GetDuration ¶ added in v0.3.0
func (*Ratelimit) GetRefillInterval ¶
func (*Ratelimit) GetRefillRate ¶
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) GetInterval ¶
func (*Refill) GetLastRefillAt ¶
type Security ¶
type Security struct {
BearerAuth *string `security:"scheme,type=http,subtype=bearer,name=Authorization"`
}
func (*Security) GetBearerAuth ¶
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
func (*Type) UnmarshalJSON ¶
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 ¶
func (o *V1KeysVerifyKeyRequest) GetRatelimit() *V1KeysVerifyKeyRequestRatelimit
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 (o *V1KeysVerifyKeyResponse) GetRatelimit() *V1KeysVerifyKeyResponseRatelimit
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 (o *V1KeysVerifyKeyResponseRatelimit) GetLimit() int64
func (*V1KeysVerifyKeyResponseRatelimit) GetRemaining ¶
func (o *V1KeysVerifyKeyResponseRatelimit) GetRemaining() int64
func (*V1KeysVerifyKeyResponseRatelimit) GetReset ¶
func (o *V1KeysVerifyKeyResponseRatelimit) GetReset() int64