Documentation ¶
Overview ¶
Package datastore provides an interface and implementations for interacting with a badge datastore.
Index ¶
- Constants
- type AirtableBadge
- type AirtableBadgeTmp
- type AirtableDatastore
- func (ds *AirtableDatastore) CreateBadge(id string, badgeType string, enabled bool) error
- func (ds *AirtableDatastore) DeleteBadge(id string) error
- func (ds *AirtableDatastore) DisableBadge(id string) error
- func (ds *AirtableDatastore) EnableBadge(id string) error
- func (ds *AirtableDatastore) GetBadge(id string) (*Badge, error)
- func (ds *AirtableDatastore) HasAccess(id string) (bool, error)
- func (ds *AirtableDatastore) ListBadges() ([]Badge, error)
- type AirtableDatastoreConfig
- type Badge
- type Datastore
- type TextFile
- func (txt *TextFile) CreateBadge(id string, badgeType string, enabled bool) error
- func (txt *TextFile) DeleteBadge(id string) error
- func (txt *TextFile) DisableBadge(id string) error
- func (txt *TextFile) EnableBadge(id string) error
- func (txt *TextFile) GetBadge(id string) (*Badge, error)
- func (txt *TextFile) HasAccess(id string) (bool, error)
- func (txt *TextFile) ListBadges() ([]Badge, error)
- type TextFileConfig
Constants ¶
const (
// ErrBadgeDoesNotExist is returned when the badge requested does not exist in the datastore.
ErrBadgeDoesNotExist = "the badge requested does not exist"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AirtableBadge ¶
AirtableBadge provides a wrapper around the badge model for Airtable requests.
type AirtableBadgeTmp ¶
AirtableBadgeTmp is used to create a badge because the API does not like when AirtableID exists in the POST even though it is empty.
type AirtableDatastore ¶
type AirtableDatastore struct {
// contains filtered or unexported fields
}
AirtableDatastore is an implementation of the datastore interface for Airtable.
func NewAirTableDataStore ¶
func NewAirTableDataStore(config AirtableDatastoreConfig) (*AirtableDatastore, error)
NewAirTableDatastore provides an initialized datastore for Airtable using the provided configuration.
func (*AirtableDatastore) CreateBadge ¶
func (ds *AirtableDatastore) CreateBadge(id string, badgeType string, enabled bool) error
CreateBadge creates a badge in the Airflow datastore with the provided values.
func (*AirtableDatastore) DeleteBadge ¶
func (ds *AirtableDatastore) DeleteBadge(id string) error
DeleteBadge deletes a badge from the datastore.
func (*AirtableDatastore) DisableBadge ¶
func (ds *AirtableDatastore) DisableBadge(id string) error
DisableBadge disables a badge that exists in the datastore.
func (*AirtableDatastore) EnableBadge ¶
func (ds *AirtableDatastore) EnableBadge(id string) error
EnableBadge enables a badge that exists in the datastore.
func (*AirtableDatastore) GetBadge ¶
func (ds *AirtableDatastore) GetBadge(id string) (*Badge, error)
GetBadge returns a badge with the given ID. If the badge does not exist, ErrBadgeDoesNotExist will be returned.
func (*AirtableDatastore) HasAccess ¶
func (ds *AirtableDatastore) HasAccess(id string) (bool, error)
HasAccess returns true if the badge with the given ID should be given access.
func (*AirtableDatastore) ListBadges ¶
func (ds *AirtableDatastore) ListBadges() ([]Badge, error)
ListBadges returns a list of badges from the datastore.
type AirtableDatastoreConfig ¶
type AirtableDatastoreConfig struct { // Key is a valid Airtable API key. Key string // BaseID is a valid Airtable base id. BaseID string }
AirtableDatastoreConfig is a configuration struct for an Airtable datastore.
type Badge ¶
type Badge struct { // ID is the id burned into the RFID badge. ID string `json:"id"` // Enabled determines if the badge should be considered active. Enabled bool `json:"enabled"` // Type is the type of badge. E.x. card, sticker, keychain. Type string `json:"type"` }
Badge is a model for a badge in the datastore.
type Datastore ¶
type Datastore interface { HasAccess(id string) (bool, error) ListBadges() ([]Badge, error) CreateBadge(id string, badgeType string, enabled bool) error EnableBadge(id string) error DisableBadge(id string) error DeleteBadge(id string) error GetBadge(id string) (*Badge, error) }
Datastore is an interface for accessing a badge datastore.
type TextFile ¶
type TextFile struct {
// contains filtered or unexported fields
}
TextFile implements the datastore interface with a file.
func NewTextFile ¶
func NewTextFile(cfg TextFileConfig) (*TextFile, error)
NewTextFile provides an instantiated datastore.
func (*TextFile) CreateBadge ¶
func (*TextFile) DeleteBadge ¶
func (*TextFile) DisableBadge ¶
func (*TextFile) EnableBadge ¶
func (*TextFile) ListBadges ¶
type TextFileConfig ¶
type TextFileConfig struct {
Path string
}
TextFileConfig is a configuration struct for a a TextFile datastore.