store

package
v3.33.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package store defines the interfaces implemented by Identity Server store implementations.

Index

Constants

View Source
const (
	// EntityApplication is the entity type for applications.
	EntityApplication = "application"
	// EntityClient is the entity type for OAuth clients.
	EntityClient = "client"
	// EntityGateway is the entity type for gateways.
	EntityGateway = "gateway"
	// EntityOrganization is the entity type for organizations.
	EntityOrganization = "organization"
	// EntityUser is the entity type for users.
	EntityUser = "user"
	// EntityEndDevice is the entity type for end devices.
	EntityEndDevice = "end device"
)

Variables

View Source
var (
	ErrEntityNotFound = errors.DefineNotFound(
		"entity_not_found", "{entity_type} entity with id `{entity_id}` not found",
	)
	ErrAccountNotFound = errors.DefineNotFound(
		"account_not_found", "{account_type} account with id `{account_id}` not found",
	)
	ErrMembershipNotFound = errors.DefineNotFound(
		"membership_not_found", "membership of {account_type} account with id `{account_id}` on {entity_type} entity with id `{entity_id}` not found",
	)

	ErrApplicationNotFound = errors.DefineNotFound(
		"application_not_found", "application with id `{application_id}` not found",
	)
	ErrClientNotFound = errors.DefineNotFound(
		"client_not_found", "client with id `{client_id}` not found",
	)
	ErrEndDeviceNotFound = errors.DefineNotFound(
		"end_device_not_found", "end device with id `{device_id}` not found in application with id `{application_id}`",
	)
	ErrGatewayNotFound = errors.DefineNotFound(
		"gateway_not_found", "gateway with id `{gateway_id}` not found",
	)
	ErrGatewayNotFoundByEUI = errors.DefineNotFound(
		"gateway_not_found_by_eui", "gateway with eui `{gateway_eui}` not found",
	)
	ErrOrganizationNotFound = errors.DefineNotFound(
		"organization_not_found", "organization with id `{organization_id}` not found",
	)
	ErrUserNotFound = errors.DefineNotFound(
		"user_not_found", "user with id `{user_id}` not found",
	)
	ErrUserNotFoundByPrimaryEmailAddress = errors.DefineNotFound(
		"user_not_found_by_primary_email_address", "user not found by primary email address",
	)

	ErrUserSessionNotFound = errors.DefineNotFound(
		"user_session_not_found", "user session with id `{session_id}` not found", "user_id",
	)
	ErrLastAdmin = errors.DefineFailedPrecondition(
		"last_admin", "user `{user_id}` is the last admin",
	)

	ErrInvalidEntityType = errors.DefineInvalidArgument(
		"invalid_entity_type", "invalid entity type `{entity_type}`",
	)
	ErrUserBookmarkNotFound = errors.DefineNotFound(
		"user_bookmark_not_found", "user's bookmark not found",
	)

	ErrAPIKeyNotFound = errors.DefineNotFound(
		"api_key_not_found", "api key with id `{api_key_id}` not found", "entity_type", "entity_id",
	)

	ErrInvitationAlreadySent = errors.DefineAlreadyExists(
		"invitation_already_sent", "invitation already sent",
	)
	ErrInvitationNotFound = errors.DefineNotFound(
		"invitation_not_found", "invitation not found", "invitation_token",
	)
	ErrInvitationExpired = errors.DefineFailedPrecondition(
		"invitation_expired", "invitation expired", "invitation_token",
	)
	ErrInvitationAlreadyUsed = errors.DefineFailedPrecondition(
		"invitation_already_used", "invitation already used", "invitation_token",
	)

	ErrValidationAlreadySent = errors.DefineAlreadyExists(
		"validation_already_sent", "validation already sent",
	)
	ErrValidationTokenNotFound = errors.DefineNotFound(
		"validation_token_not_found", "validation token not found", "validation_id",
	)
	ErrValidationTokenExpired = errors.DefineFailedPrecondition(
		"validation_token_expired", "validation token expired", "validation_id",
	)
	ErrValidationTokenAlreadyUsed = errors.DefineFailedPrecondition(
		"validation_token_already_used", "validation token already used", "validation_id",
	)
	ErrValidationWithoutContactInfo = errors.DefineFailedPrecondition(
		"validation_without_contact_info", "validation does not reference any valid contact information",
	)
	ErrContactInfoNotFound = errors.DefineNotFound(
		"contact_info_not_found", "contact information with id `{contact_info_id}` not found",
	)

	ErrLoginTokenNotFound = errors.DefineNotFound(
		"login_token_not_found", "login token not found",
	)
	ErrLoginTokenExpired = errors.DefineFailedPrecondition(
		"login_token_expired", "login token expired",
	)
	ErrLoginTokenAlreadyUsed = errors.DefineFailedPrecondition(
		"login_token_already_used", "login token already used",
	)

	ErrAuthorizationNotFound = errors.DefineNotFound(
		"authorization_not_found", "authorization of user with id `{user_id}` on client with id `{client_id}` not found",
	)
	ErrAuthorizationCodeNotFound = errors.DefineNotFound(
		"authorization_code_not_found", "authorization code not found",
	)
	ErrAccessTokenNotFound = errors.DefineNotFound(
		"access_token_not_found", "access token with id `{access_token_id}` not found",
	)

	ErrNoEUIBlockAvailable = errors.DefineFailedPrecondition(
		"no_eui_or_block_available",
		"no EUI or EUI block available",
	)
	ErrApplicationDevEUILimitReached = errors.DefineFailedPrecondition(
		"application_dev_eui_limit_reached",
		"application issued DevEUI limit ({dev_eui_limit}) reached",
	)

	ErrContactInfoRestricted = errors.DefinePermissionDenied(
		"contact_info_restricted", "contact information can only reference the caller",
	)
)

Errors returned when stores can't find an entity.

Functions

func LimitAndOffsetFromContext added in v3.17.2

func LimitAndOffsetFromContext(ctx context.Context) (limit, offset uint32)

LimitAndOffsetFromContext gets the limit and offset from the context.

func OrderFromContext added in v3.17.2

func OrderFromContext(ctx context.Context, table, defaultTableField, defaultDirection string) string

OrderFromContext returns the ordering string (field and direction) for the query. If the context contains ordering options, those are used. Otherwise, the default field and order are used.

func SetPaginationDefaults added in v3.32.2

func SetPaginationDefaults(d PaginationDefaults)

SetPaginationDefaults should only be called at the initialization of the server, never on regitries or auxiliary functions.

func SetTotal added in v3.17.2

func SetTotal(ctx context.Context, total uint64)

SetTotal sets the total number of results into the destination set by SetTotalCount if not already set.

func WithFilter added in v3.32.0

func WithFilter(ctx context.Context, field string, threshold string) context.Context

WithFilter instructs the store to filter the results by the given field and threshold.

func WithOrder

func WithOrder(ctx context.Context, spec string) context.Context

WithOrder instructs the store to sort the results by the given field. If the field is prefixed with a minus, the order is reversed.

func WithPagination

func WithPagination(ctx context.Context, limit, page uint32, total *uint64) context.Context

WithPagination instructs the store to paginate the results, and set the total number of results into total.

func WithSoftDeleted added in v3.12.0

func WithSoftDeleted(ctx context.Context, onlyDeleted bool) context.Context

WithSoftDeleted returns a context that tells the store to include (only) deleted entities.

func WithSoftDeletedBetween added in v3.17.2

func WithSoftDeletedBetween(ctx context.Context, deletedAfter, deletedBefore *time.Time) context.Context

WithSoftDeletedBetween returns a context that tells the store to include deleted entities between (exclusive) the given times.

Types

type APIKeyStore

type APIKeyStore interface {
	// Create a new API key for the given entity.
	CreateAPIKey(
		ctx context.Context, entityID *ttnpb.EntityIdentifiers, key *ttnpb.APIKey,
	) (*ttnpb.APIKey, error)
	// Find API keys of the given entity.
	FindAPIKeys(
		ctx context.Context, entityID *ttnpb.EntityIdentifiers,
	) ([]*ttnpb.APIKey, error)
	// Get an API key.
	GetAPIKey(
		ctx context.Context, entityID *ttnpb.EntityIdentifiers, id string,
	) (*ttnpb.APIKey, error)
	// Get an API key by its ID.
	GetAPIKeyByID(
		ctx context.Context, id string,
	) (*ttnpb.EntityIdentifiers, *ttnpb.APIKey, error)
	// Update key rights on an entity.
	// Rights can be deleted by not passing any rights, in which case the returned API key will be nil.
	UpdateAPIKey(
		ctx context.Context, entityID *ttnpb.EntityIdentifiers, key *ttnpb.APIKey, fieldMask FieldMask,
	) (*ttnpb.APIKey, error)
	// DeleteAPIKey deletes key rights on an entity.
	DeleteAPIKey(ctx context.Context, entityID *ttnpb.EntityIdentifiers, key *ttnpb.APIKey) error
	// Delete api keys deletes all api keys tied to an entity. Used when purging entities.
	DeleteEntityAPIKeys(ctx context.Context, entityID *ttnpb.EntityIdentifiers) error
}

APIKeyStore interface for storing API keys for entities (applications, clients, gateways, organizations or users).

type ApplicationStore

type ApplicationStore interface {
	CreateApplication(ctx context.Context, app *ttnpb.Application) (*ttnpb.Application, error)
	CountApplications(ctx context.Context) (uint64, error)
	FindApplications(
		ctx context.Context, ids []*ttnpb.ApplicationIdentifiers, fieldMask FieldMask,
	) ([]*ttnpb.Application, error)
	GetApplication(
		ctx context.Context, id *ttnpb.ApplicationIdentifiers, fieldMask FieldMask,
	) (*ttnpb.Application, error)
	UpdateApplication(
		ctx context.Context, app *ttnpb.Application, fieldMask FieldMask,
	) (*ttnpb.Application, error)
	DeleteApplication(ctx context.Context, id *ttnpb.ApplicationIdentifiers) error
	RestoreApplication(ctx context.Context, id *ttnpb.ApplicationIdentifiers) error
	PurgeApplication(ctx context.Context, id *ttnpb.ApplicationIdentifiers) error
}

ApplicationStore interface for storing Applications.

All functions assume the input and fieldMask to be validated, and assume sufficient rights to perform the action.

type ClientStore

type ClientStore interface {
	CreateClient(ctx context.Context, cli *ttnpb.Client) (*ttnpb.Client, error)
	CountClients(ctx context.Context) (uint64, error)
	FindClients(
		ctx context.Context, ids []*ttnpb.ClientIdentifiers, fieldMask FieldMask,
	) ([]*ttnpb.Client, error)
	GetClient(
		ctx context.Context, id *ttnpb.ClientIdentifiers, fieldMask FieldMask,
	) (*ttnpb.Client, error)
	UpdateClient(
		ctx context.Context, cli *ttnpb.Client, fieldMask FieldMask,
	) (*ttnpb.Client, error)
	DeleteClient(ctx context.Context, id *ttnpb.ClientIdentifiers) error
	RestoreClient(ctx context.Context, id *ttnpb.ClientIdentifiers) error
	PurgeClient(ctx context.Context, id *ttnpb.ClientIdentifiers) error
}

ClientStore interface for storing Clients.

All functions assume the input and fieldMask to be validated, and assume sufficient rights to perform the action.

type ContactInfoStore

type ContactInfoStore interface {
	GetContactInfo(ctx context.Context, entityID ttnpb.IDStringer) ([]*ttnpb.ContactInfo, error)
	SetContactInfo(
		ctx context.Context, entityID ttnpb.IDStringer, contactInfo []*ttnpb.ContactInfo,
	) ([]*ttnpb.ContactInfo, error)
	ValidateContactInfo(ctx context.Context, validation *ttnpb.ContactInfoValidation) error
	DeleteEntityContactInfo(ctx context.Context, entityID ttnpb.IDStringer) error

	CreateValidation(ctx context.Context, validation *ttnpb.ContactInfoValidation) (*ttnpb.ContactInfoValidation, error)
	GetValidation(ctx context.Context, validation *ttnpb.ContactInfoValidation) (*ttnpb.ContactInfoValidation, error)
	ExpireValidation(ctx context.Context, validation *ttnpb.ContactInfoValidation) error
	// RefreshValidation sets the updated_at field of a validation, should be called before resending to the receiver.
	RefreshValidation(ctx context.Context, validation *ttnpb.ContactInfoValidation) error
	// ListRefreshableValidations returns all not used validations for a given entity.
	ListRefreshableValidations(
		ctx context.Context, entityID *ttnpb.EntityIdentifiers, refreshInterval time.Duration,
	) ([]*ttnpb.ContactInfoValidation, error)
}

ContactInfoStore interface for contact info validation.

type DeletedOptions added in v3.17.2

type DeletedOptions struct {
	IncludeDeleted bool
	OnlyDeleted    bool
	DeletedBefore  *time.Time
	DeletedAfter   *time.Time
}

DeletedOptions stores the options for selecting deleted entities.

func SoftDeletedFromContext added in v3.17.2

func SoftDeletedFromContext(ctx context.Context) *DeletedOptions

SoftDeletedFromContext returns the DeletedOptions from the context if present.

type EUIStore added in v3.13.0

type EUIStore interface {
	CreateEUIBlock(
		ctx context.Context, configPrefix types.EUI64Prefix, initCounter int64, euiType string,
	) error
	IssueDevEUIForApplication(
		ctx context.Context, id *ttnpb.ApplicationIdentifiers, applicationLimit int,
	) (*types.EUI64, error)
}

EUIStore interface for assigning DevEUI blocks and addresses.

type EmailValidationStore added in v3.29.0

type EmailValidationStore interface {
	CreateEmailValidation(ctx context.Context, validation *ttnpb.EmailValidation) (*ttnpb.EmailValidation, error)
	GetEmailValidation(ctx context.Context, validation *ttnpb.EmailValidation) (*ttnpb.EmailValidation, error)
	ExpireEmailValidation(ctx context.Context, validation *ttnpb.EmailValidation) error
	// GetRefreshableEmailValidation returns a not used validation for a given user.
	GetRefreshableEmailValidation(
		ctx context.Context, id *ttnpb.UserIdentifiers, refreshInterval time.Duration,
	) (*ttnpb.EmailValidation, error)
	// RefreshEmailValidation refreshes a email validation for an user.
	RefreshEmailValidation(ctx context.Context, validation *ttnpb.EmailValidation) error
}

EmailValidationStore interface for email validation.

type EndDeviceStore

type EndDeviceStore interface {
	CreateEndDevice(ctx context.Context, dev *ttnpb.EndDevice) (*ttnpb.EndDevice, error)
	CountEndDevices(ctx context.Context, ids *ttnpb.ApplicationIdentifiers) (uint64, error)
	ListEndDevices(
		ctx context.Context, ids *ttnpb.ApplicationIdentifiers, fieldMask FieldMask,
	) ([]*ttnpb.EndDevice, error)
	FindEndDevices(
		ctx context.Context, ids []*ttnpb.EndDeviceIdentifiers, fieldMask FieldMask,
	) ([]*ttnpb.EndDevice, error)
	GetEndDevice(
		ctx context.Context, id *ttnpb.EndDeviceIdentifiers, fieldMask FieldMask,
	) (*ttnpb.EndDevice, error)
	UpdateEndDevice(
		ctx context.Context, dev *ttnpb.EndDevice, fieldMask FieldMask,
	) (*ttnpb.EndDevice, error)
	DeleteEndDevice(ctx context.Context, id *ttnpb.EndDeviceIdentifiers) error
	BatchUpdateEndDeviceLastSeen(
		ctx context.Context,
		devsLastSeen []*ttnpb.BatchUpdateEndDeviceLastSeenRequest_EndDeviceLastSeenUpdate,
	) error
	BatchDeleteEndDevices(
		ctx context.Context,
		appIDs *ttnpb.ApplicationIdentifiers,
		devIDs []string,
	) ([]*ttnpb.EndDeviceIdentifiers, error)
}

EndDeviceStore interface for storing EndDevices.

All functions assume the input and fieldMask to be validated, and assume sufficient rights to perform the action.

type FieldMask added in v3.18.1

type FieldMask []string

FieldMask is used to specify applicable fields in SELECT or UPDATE queries.

func (FieldMask) Contains added in v3.21.0

func (fm FieldMask) Contains(search string) bool

Contains returns true if the given field is present in the field mask.

func (FieldMask) TopLevel added in v3.21.0

func (fm FieldMask) TopLevel() FieldMask

TopLevel returns the top-level fields from the field mask.

func (FieldMask) TrimPrefix added in v3.21.0

func (fm FieldMask) TrimPrefix(prefix string) FieldMask

TrimPrefix returns a field mask with all fields of fm that contain prefix, but then having that prefix removed.

type FilterOptions added in v3.32.0

type FilterOptions struct {
	Field     string
	Threshold string
}

FilterOptions stores the filter options that are propagated in the context.

func FilterOptionsFromContext added in v3.32.0

func FilterOptionsFromContext(ctx context.Context) (FilterOptions, bool)

FilterOptionsFromContext returns the filtering options for the query.

type GatewayStore

type GatewayStore interface {
	CreateGateway(ctx context.Context, gtw *ttnpb.Gateway) (*ttnpb.Gateway, error)
	CountGateways(ctx context.Context) (uint64, error)
	FindGateways(
		ctx context.Context, ids []*ttnpb.GatewayIdentifiers, fieldMask FieldMask,
	) ([]*ttnpb.Gateway, error)
	GetGateway(
		ctx context.Context, id *ttnpb.GatewayIdentifiers, fieldMask FieldMask,
	) (*ttnpb.Gateway, error)
	UpdateGateway(
		ctx context.Context, gtw *ttnpb.Gateway, fieldMask FieldMask,
	) (*ttnpb.Gateway, error)
	DeleteGateway(ctx context.Context, id *ttnpb.GatewayIdentifiers) error
	RestoreGateway(ctx context.Context, id *ttnpb.GatewayIdentifiers) error
	PurgeGateway(ctx context.Context, id *ttnpb.GatewayIdentifiers) error
	BatchDeleteGateways(
		ctx context.Context,
		ids []*ttnpb.GatewayIdentifiers,
	) ([]*ttnpb.GatewayIdentifiers, error)
}

GatewayStore interface for storing Gateways.

All functions assume the input and fieldMask to be validated, and assume sufficient rights to perform the action.

type InvitationStore

type InvitationStore interface {
	CreateInvitation(ctx context.Context, invitation *ttnpb.Invitation) (*ttnpb.Invitation, error)
	FindInvitations(ctx context.Context) ([]*ttnpb.Invitation, error)
	GetInvitation(ctx context.Context, token string) (*ttnpb.Invitation, error)
	SetInvitationAcceptedBy(ctx context.Context, token string, usrIDs *ttnpb.UserIdentifiers) error
	DeleteInvitation(ctx context.Context, email string) error
}

InvitationStore interface for storing user invitations.

type LoginTokenStore added in v3.12.0

type LoginTokenStore interface {
	FindActiveLoginTokens(ctx context.Context, userIDs *ttnpb.UserIdentifiers) ([]*ttnpb.LoginToken, error)
	CreateLoginToken(ctx context.Context, token *ttnpb.LoginToken) (*ttnpb.LoginToken, error)
	ConsumeLoginToken(ctx context.Context, token string) (*ttnpb.LoginToken, error)
}

LoginTokenStore interface for storing user login tokens.

type MemberByID added in v3.22.0

type MemberByID struct {
	Ids    *ttnpb.OrganizationOrUserIdentifiers
	Rights *ttnpb.Rights
}

MemberByID defines a set containing a User or Organization Ids and their respective Rights.

type MembershipChain added in v3.15.2

type MembershipChain struct {
	UserIdentifiers         *ttnpb.UserIdentifiers
	RightsOnOrganization    *ttnpb.Rights
	OrganizationIdentifiers *ttnpb.OrganizationIdentifiers
	RightsOnEntity          *ttnpb.Rights
	EntityIdentifiers       *ttnpb.EntityIdentifiers
}

MembershipChain is a User -> (Membership -> Organization) -> Membership -> Entity chain.

func (*MembershipChain) GetRights added in v3.15.2

func (m *MembershipChain) GetRights() *ttnpb.Rights

GetRights returns the intersected rights.

type MembershipChains added in v3.15.2

type MembershipChains []*MembershipChain

MembershipChains is a list of membership chains.

func (MembershipChains) GetRights added in v3.15.2

GetRights returns the rights of the member on the entity.

type MembershipStore

type MembershipStore interface {
	// Count direct memberships of the organization or user.
	CountMemberships(ctx context.Context, id *ttnpb.OrganizationOrUserIdentifiers, entityType string) (uint64, error)

	// Find direct and optionally also indirect memberships of the organization or user.
	FindMemberships(
		ctx context.Context, id *ttnpb.OrganizationOrUserIdentifiers, entityType string, includeIndirect bool,
	) ([]*ttnpb.EntityIdentifiers, error)

	// Find memberships (through organizations) between the user and entity.
	FindAccountMembershipChains(
		ctx context.Context, accountID *ttnpb.OrganizationOrUserIdentifiers, entityType string, entityIDs ...string,
	) ([]*MembershipChain, error)

	// Find direct members and rights of the given entity.
	FindMembers(
		ctx context.Context, entityID *ttnpb.EntityIdentifiers,
	) ([]*MemberByID, error)
	// Get direct member rights on an entity.
	GetMember(
		ctx context.Context, id *ttnpb.OrganizationOrUserIdentifiers, entityID *ttnpb.EntityIdentifiers,
	) (*ttnpb.Rights, error)
	// Set direct member rights on an entity.
	SetMember(
		ctx context.Context,
		id *ttnpb.OrganizationOrUserIdentifiers,
		entityID *ttnpb.EntityIdentifiers,
		rights *ttnpb.Rights,
	) error
	// DeleteMember elminates the direct member rights attached to an entity.
	DeleteMember(ctx context.Context, id *ttnpb.OrganizationOrUserIdentifiers, entityID *ttnpb.EntityIdentifiers) error
	// Delete all member rights on an entity. Used for purging entities.
	DeleteEntityMembers(ctx context.Context, entityID *ttnpb.EntityIdentifiers) error
	// Delete all user rights for an entity.
	DeleteAccountMembers(ctx context.Context, id *ttnpb.OrganizationOrUserIdentifiers) error
}

MembershipStore interface for storing membership (collaboration) relations between accounts (users or organizations) and entities (applications, clients, gateways or organizations).

As the operations in this store may be quite expensive, the results of FindXXX operations should typically be cached. The recommended cache behavior is:

type NotificationStore added in v3.19.0

type NotificationStore interface {
	CreateNotification(
		ctx context.Context, notification *ttnpb.Notification, receiverIDs []*ttnpb.UserIdentifiers,
	) (*ttnpb.Notification, error)
	ListNotifications(
		ctx context.Context, receiverIDs *ttnpb.UserIdentifiers, statuses []ttnpb.NotificationStatus,
	) ([]*ttnpb.Notification, error)
	UpdateNotificationStatus(
		ctx context.Context,
		receiverIDs *ttnpb.UserIdentifiers,
		notificationIDs []string,
		status ttnpb.NotificationStatus,
	) error
}

NotificationStore interface for notifications.

type OAuthStore

type OAuthStore interface {
	ListAuthorizations(
		ctx context.Context, userIDs *ttnpb.UserIdentifiers,
	) ([]*ttnpb.OAuthClientAuthorization, error)
	GetAuthorization(
		ctx context.Context, userIDs *ttnpb.UserIdentifiers, clientIDs *ttnpb.ClientIdentifiers,
	) (*ttnpb.OAuthClientAuthorization, error)
	Authorize(
		ctx context.Context, req *ttnpb.OAuthClientAuthorization,
	) (authorization *ttnpb.OAuthClientAuthorization, err error)
	DeleteAuthorization(
		ctx context.Context, userIDs *ttnpb.UserIdentifiers, clientIDs *ttnpb.ClientIdentifiers,
	) error
	DeleteUserAuthorizations(ctx context.Context, userIDs *ttnpb.UserIdentifiers) error
	DeleteClientAuthorizations(ctx context.Context, clientIDs *ttnpb.ClientIdentifiers) error

	CreateAuthorizationCode(
		ctx context.Context, code *ttnpb.OAuthAuthorizationCode,
	) (*ttnpb.OAuthAuthorizationCode, error)
	GetAuthorizationCode(ctx context.Context, code string) (*ttnpb.OAuthAuthorizationCode, error)
	DeleteAuthorizationCode(ctx context.Context, code string) error

	CreateAccessToken(
		ctx context.Context, token *ttnpb.OAuthAccessToken, previousID string,
	) (*ttnpb.OAuthAccessToken, error)
	ListAccessTokens(
		ctx context.Context, userIDs *ttnpb.UserIdentifiers, clientIDs *ttnpb.ClientIdentifiers,
	) ([]*ttnpb.OAuthAccessToken, error)
	GetAccessToken(ctx context.Context, id string) (*ttnpb.OAuthAccessToken, error)
	DeleteAccessToken(ctx context.Context, id string) error
}

OAuthStore interface for the OAuth server.

For internal use (by the OAuth server) only.

type OrderOptions added in v3.17.2

type OrderOptions struct {
	Field     string
	Direction string
}

OrderOptions stores the ordering options that are propagated in the context.

func OrderOptionsFromContext added in v3.21.0

func OrderOptionsFromContext(ctx context.Context) OrderOptions

OrderOptionsFromContext returns the ordering options for the query.

type OrganizationStore

type OrganizationStore interface {
	CreateOrganization(
		ctx context.Context, org *ttnpb.Organization,
	) (*ttnpb.Organization, error)
	CountOrganizations(ctx context.Context) (uint64, error)
	FindOrganizations(
		ctx context.Context, ids []*ttnpb.OrganizationIdentifiers, fieldMask FieldMask,
	) ([]*ttnpb.Organization, error)
	GetOrganization(
		ctx context.Context, id *ttnpb.OrganizationIdentifiers, fieldMask FieldMask,
	) (*ttnpb.Organization, error)
	UpdateOrganization(
		ctx context.Context, org *ttnpb.Organization, fieldMask FieldMask,
	) (*ttnpb.Organization, error)
	DeleteOrganization(ctx context.Context, id *ttnpb.OrganizationIdentifiers) error
	RestoreOrganization(ctx context.Context, id *ttnpb.OrganizationIdentifiers) error
	PurgeOrganization(ctx context.Context, id *ttnpb.OrganizationIdentifiers) error
}

OrganizationStore interface for storing Organizations.

All functions assume the input and fieldMask to be validated, and assume sufficient rights to perform the action.

type PaginationDefaults added in v3.32.2

type PaginationDefaults struct {
	DefaultLimit uint32
}

PaginationDefaults sets default values for paginations options within the IS store.

type PaginationOptions added in v3.17.2

type PaginationOptions struct {
	// contains filtered or unexported fields
}

PaginationOptions stores the pagination options that are propagated in the context.

type TransactionalStore added in v3.18.1

type TransactionalStore interface {
	Store

	Transact(ctx context.Context, fc func(context.Context, Store) error) error
}

TransactionalStore is Store, but with a method that uses a transaction.

type UserBookmarkStore added in v3.30.0

type UserBookmarkStore interface {
	CreateBookmark(context.Context, *ttnpb.UserBookmark) (*ttnpb.UserBookmark, error)
	FindBookmarks(
		ctx context.Context, usrID *ttnpb.UserIdentifiers, entityTypes ...string,
	) ([]*ttnpb.UserBookmark, error)
	PurgeBookmark(context.Context, *ttnpb.UserBookmark) error
	BatchPurgeBookmarks(
		context.Context, *ttnpb.UserIdentifiers, []*ttnpb.EntityIdentifiers,
	) ([]*ttnpb.UserBookmark, error)

	DeleteEntityBookmarks(context.Context, *ttnpb.EntityIdentifiers) error
	RestoreEntityBookmarks(context.Context, *ttnpb.EntityIdentifiers) error
	PurgeEntityBookmarks(context.Context, *ttnpb.EntityIdentifiers) error
	DeleteUserBookmarks(context.Context, *ttnpb.UserIdentifiers) error
	RestoreUserBookmarks(context.Context, *ttnpb.UserIdentifiers) error
	PurgeUserBookmarks(context.Context, *ttnpb.UserIdentifiers) error
}

UserBookmarkStore interface for storing user bookmarks.

type UserSessionStore

type UserSessionStore interface {
	CreateSession(
		ctx context.Context, sess *ttnpb.UserSession,
	) (*ttnpb.UserSession, error)
	FindSessions(
		ctx context.Context, userIDs *ttnpb.UserIdentifiers,
	) ([]*ttnpb.UserSession, error)
	GetSession(
		ctx context.Context, userIDs *ttnpb.UserIdentifiers, sessionID string,
	) (*ttnpb.UserSession, error)
	GetSessionByID(ctx context.Context, tokenID string) (*ttnpb.UserSession, error)
	DeleteSession(ctx context.Context, userIDs *ttnpb.UserIdentifiers, sessionID string) error
	DeleteAllUserSessions(ctx context.Context, userIDs *ttnpb.UserIdentifiers) error
}

UserSessionStore interface for storing User sessions.

For internal use (by the OAuth server) only.

type UserStore

type UserStore interface {
	CreateUser(ctx context.Context, usr *ttnpb.User) (*ttnpb.User, error)
	CountUsers(ctx context.Context) (uint64, error)
	FindUsers(
		ctx context.Context, ids []*ttnpb.UserIdentifiers, fieldMask FieldMask,
	) ([]*ttnpb.User, error)
	ListAdmins(ctx context.Context, fieldMask FieldMask) ([]*ttnpb.User, error)
	GetUser(
		ctx context.Context, id *ttnpb.UserIdentifiers, fieldMask FieldMask,
	) (*ttnpb.User, error)
	GetUserByPrimaryEmailAddress(
		ctx context.Context, email string, fieldMask FieldMask,
	) (*ttnpb.User, error)
	UpdateUser(
		ctx context.Context, usr *ttnpb.User, fieldMask FieldMask,
	) (*ttnpb.User, error)
	DeleteUser(ctx context.Context, id *ttnpb.UserIdentifiers) error
	RestoreUser(ctx context.Context, id *ttnpb.UserIdentifiers) error
	PurgeUser(ctx context.Context, id *ttnpb.UserIdentifiers) error
}

UserStore interface for storing Users.

All functions assume the input and fieldMask to be validated, and assume sufficient rights to perform the action.

Directories

Path Synopsis
Package migrations contains Identity Server store migrations.
Package migrations contains Identity Server store migrations.

Jump to

Keyboard shortcuts

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