storage

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package storage defines shared types and interfaces for storage.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStatusReportNotFound = errors.New("status report not found")
	ErrDeclarationNotFound  = errors.New("declaration not found")
)

Functions

This section is empty.

Types

type DeclarationAPIRetriever added in v0.4.0

type DeclarationAPIRetriever interface {
	// RetrieveDeclaration retrieves a declaration from storage.
	RetrieveDeclaration(ctx context.Context, declarationID string) (*ddm.Declaration, error)
	// RetrieveDeclarationModTime retrieves the last modification time of the declaration.
	RetrieveDeclarationModTime(ctx context.Context, declarationID string) (time.Time, error)
}

type DeclarationAPIStorage added in v0.4.0

DeclarationAPIStorage are storage interfaces relating to declarations.

type DeclarationDeleter added in v0.4.0

type DeclarationDeleter interface {
	// DeleteDeclaration deletes a declaration.
	// If the declaration was deleted true should be returned.
	//
	// Implementations should return an error if there are declarations
	// that depend on it or if the declaration is associated with a set.
	DeleteDeclaration(ctx context.Context, declarationID string) (bool, error)
}

type DeclarationRetriever added in v0.4.0

type DeclarationRetriever interface {
	// RetrieveEnrollmentDeclarationJSON fetches the JSON for a declaration for an enrollment ID.
	// This is part of the core DDM protocol for handling declarations for enrollments.
	RetrieveEnrollmentDeclarationJSON(ctx context.Context, declarationID, declarationType, enrollmentID string) ([]byte, error)
}

type DeclarationSetRetriever added in v0.4.0

type DeclarationSetRetriever interface {
	// RetrieveDeclarationSets retrieves the list of set names for declarationID.
	RetrieveDeclarationSets(ctx context.Context, declarationID string) (setNames []string, err error)
}

type DeclarationStorer added in v0.4.0

type DeclarationStorer interface {
	// StoreDeclaration stores a declaration.
	// If the declaration is new or has changed true should be returned.
	//
	// Note that a storage backend may try to create relations
	// based on the the ddm.IdentifierRefs field.
	StoreDeclaration(ctx context.Context, d *ddm.Declaration) (bool, error)
}

type DeclarationsRetriever added in v0.4.0

type DeclarationsRetriever interface {
	// RetrieveDeclarations retrieves a list of all declarations.
	RetrieveDeclarations(ctx context.Context) ([]string, error)
}

type EnrollmentDeclarationStorage added in v0.4.0

type EnrollmentDeclarationStorage interface {
	TokensDeclarationItemsRetriever
	DeclarationRetriever
}

EnrollmentDeclarationStorage is the storage required to support declarations in the DDM protocol. This is part of the core DDM protocol for handling declarations for enrollments.

type EnrollmentIDRetriever added in v0.4.0

type EnrollmentIDRetriever interface {
	// RetrieveEnrollmentIDs retrieves MDM enrollment IDs from storage.
	// In the case of sets and declarations the transitive associations
	// are traversed to try and collect the IDs. When multiple slices
	// are given they should be treated like a logical or (i.e. finding
	// all enrollment IDs for any of the given slices).
	// Warning: the results may be very large for e.g. sets (or, transitively,
	// declarations) that are assigned to many enrollment IDs.
	RetrieveEnrollmentIDs(ctx context.Context, declarations []string, sets []string, ids []string) ([]string, error)
}

type EnrollmentSetRemover added in v0.4.0

type EnrollmentSetRemover interface {
	// StoreEnrollmentSet dissociates enrollmentID and setName.
	// If the association is removed true is returned.
	// It should not be an error if the association does not exist.
	RemoveEnrollmentSet(ctx context.Context, enrollmentID, setName string) (bool, error)
}

type EnrollmentSetStorage added in v0.4.0

type EnrollmentSetStorage interface {
	EnrollmentSetsRetriever
	EnrollmentSetStorer
	EnrollmentSetRemover
}

EnrollmentSetStorage are storage interfaces related to MDM enrollment IDs.

type EnrollmentSetStorer added in v0.4.0

type EnrollmentSetStorer interface {
	// StoreEnrollmentSet associates enrollmentID and setName.
	// If the association is created true is returned.
	// It should not be an error if the association does not exist.
	StoreEnrollmentSet(ctx context.Context, enrollmentID, setName string) (bool, error)
}

type EnrollmentSetsRetriever added in v0.4.0

type EnrollmentSetsRetriever interface {
	// RetrieveEnrollmentSets retrieves the sets that are associated with enrollmentID.
	RetrieveEnrollmentSets(ctx context.Context, enrollmentID string) (setNames []string, err error)
}

type SetDeclarationRemover added in v0.4.0

type SetDeclarationRemover interface {
	// StoreSetDeclaration dissociates setName and declarationID.
	// If the association is removed true should be returned.
	// It should not be an error if the association does not exist.
	RemoveSetDeclaration(ctx context.Context, setName, declarationID string) (bool, error)
}

type SetDeclarationStorage added in v0.4.0

SetStorage are storage interfaces related to sets.

type SetDeclarationStorer added in v0.4.0

type SetDeclarationStorer interface {
	// StoreSetDeclaration associates setName and declarationID.
	// If the association is created true should be returned.
	// It should not be an error if the association does not exist.
	StoreSetDeclaration(ctx context.Context, setName, declarationID string) (bool, error)
}

type SetDeclarationsRetriever added in v0.4.0

type SetDeclarationsRetriever interface {
	// RetrieveSetDeclarations retreives the list of declarations IDs for setName.
	RetrieveSetDeclarations(ctx context.Context, setName string) (declarationIDs []string, err error)
}

type SetRetreiver added in v0.4.0

type SetRetreiver interface {
	// RetrieveSets returns the list of all sets.
	RetrieveSets(ctx context.Context) ([]string, error)
}

type StatusAPIStorage added in v0.4.0

StatusAPIStorage are storage interfaces related to retrieving status channel data.

type StatusDeclarationsRetriever added in v0.4.0

type StatusDeclarationsRetriever interface {
	// RetrieveDeclarationStatus retrieves the status of the declarations for enrollmentIDs.
	RetrieveDeclarationStatus(ctx context.Context, enrollmentIDs []string) (map[string][]ddm.DeclarationQueryStatus, error)
}

type StatusError

type StatusError struct {
	Path      string      `json:"path"`
	Error     interface{} `json:"error"`
	Timestamp time.Time   `json:"timestamp"`
	StatusID  string      `json:"status_id,omitempty"`
}

type StatusErrorsRetriever added in v0.4.0

type StatusErrorsRetriever interface {
	// RetrieveStatusErrors retrieves the collected errors for enrollmentIDs.
	RetrieveStatusErrors(ctx context.Context, enrollmentIDs []string, offset, limit int) (map[string][]StatusError, error)
}

type StatusReportQuery added in v0.4.0

type StatusReportQuery struct {
	EnrollmentID string
	StatusID     *string
	Index        *int
}

StatusReportQuery specifies search criteria for finding specific status reports for enrollments.

func (StatusReportQuery) Valid added in v0.4.0

func (q StatusReportQuery) Valid() error

Valid performs basic sanity checks for querying for status reports.

type StatusReportRetriever added in v0.4.0

type StatusReportRetriever interface {
	RetrieveStatusReport(ctx context.Context, q StatusReportQuery) (*StoredStatusReport, error)
}

type StatusStorer added in v0.4.0

type StatusStorer interface {
	// StoreDeclarationStatus stores the status report details.
	// For later retrieval by the StatusAPIStorage interface(s).
	StoreDeclarationStatus(ctx context.Context, enrollmentID string, status *ddm.StatusReport) error
}

type StatusValue

type StatusValue struct {
	Path      string    `json:"path"`
	Value     string    `json:"value"`
	Timestamp time.Time `json:"timestamp"`
	StatusID  string    `json:"status_id,omitempty"`
}

type StatusValuesRetriever added in v0.4.0

type StatusValuesRetriever interface {
	// RetrieveStatusErrors retrieves the collected errors for enrollmentIDs.
	RetrieveStatusValues(ctx context.Context, enrollmentIDs []string, pathPrefix string) (map[string][]StatusValue, error)
}

type StoredStatusReport added in v0.4.0

type StoredStatusReport struct {
	Raw       []byte    // the raw JSON bytes of the status report
	Timestamp time.Time // the date the status report was saved
	StatusID  string    // optional unique identifier of report. defined when report was saved.
	Index     int       // optional "index" for this enrollment's status reports.
}

StoredStatusReport represents a stored status report by StoreDeclarationStatus.

type TokensDeclarationItemsRetriever added in v0.4.0

type TokensDeclarationItemsRetriever interface {
	// RetrieveDeclarationItemsJSON returns the declaration items JSON for enrollmentID.
	// This is part of the core DDM protocol for handling declarations for enrollments.
	RetrieveDeclarationItemsJSON(ctx context.Context, enrollmentID string) ([]byte, error)
	TokensJSONRetriever
}

type TokensJSONRetriever added in v0.4.0

type TokensJSONRetriever interface {
	// RetrieveTokensJSON returns the sync token JSON for enrollmentID.
	// This is part of the core DDM protocol for handling declarations for enrollments.
	RetrieveTokensJSON(ctx context.Context, enrollmentID string) ([]byte, error)
}

type Toucher added in v0.4.0

type Toucher interface {
	// TouchDeclaration forces a change to a declaration's ServerToken only.
	TouchDeclaration(ctx context.Context, declarationID string) error
}

Directories

Path Synopsis
Package file is a filesystem-based storage backend for KMFDDM.
Package file is a filesystem-based storage backend for KMFDDM.
Package mysql is a MySQL storage backend for KMFDDM.
Package mysql is a MySQL storage backend for KMFDDM.

Jump to

Keyboard shortcuts

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