db

package
v0.0.60 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LABS_DURATION_MIN = 5     // seconds
	LABS_DURATION_MAX = 14400 // seconds
)

/////////////

View Source
const (
	USER_STATUS_ACTIVE   = "Active"
	USER_STATUS_INACTIVE = "Inactive"
)
View Source
const (
	NAME_LABS        = "labs"
	NAME_ANSWERS     = "qanswers"
	NAME_QUESTIONS   = "qquestions"
	NAME_SUBMISSIONS = "qsubmissions"
	NAME_SNAPSHOTS   = "snapshots"
)

To aide in the setting/getting of the map data types in the table.

View Source
const ACCTS_AWS_ACCTS_GSI_NAME = "GSI"
View Source
const ACCTS_AWS_ACCTS_TABLE_NAME = "AwsAccts"

/////////////

View Source
const ACTIVE_LABS_GSI_NAME = "GSI"
View Source
const ACTIVE_LABS_TABLE_NAME = "ActiveLabs"

/////////////

View Source
const AdministratorRole = "http://purl.imsglobal.org/vocab/lis/v2/system/person#Administrator"
View Source
const CLASSES_TABLE_NAME = "Classes"

/////////////

View Source
const FacultyRole = "http://purl.imsglobal.org/vocab/lis/v2/institution/person#Faculty"
View Source
const InstructorRole = "http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor"

/////////////////

View Source
const LABS_TABLE_NAME = "Labs"

/////////////

View Source
const LTI_ACCESS_TOKEN_NAME = "LtiAccessToken"
View Source
const LTI_CONFIG_TABLE_NAME = "LtiConfig"

/////////////

View Source
const LTI_LAUNCH_TABLE_NAME = "LtiLaunch"
View Source
const LTI_STATE_TABLE_NAME = "LtiState"
View Source
const SORT_ID_LAUNCH = "SNF_LAUNCH"
View Source
const (
	STATE_INUSE = "inuse"
)

/////////////

View Source
const StudentRole = "http://purl.imsglobal.org/vocab/lis/v2/institution/person#Student"
View Source
const TOKEN_DELTA = -60

///////////// The amount of time to subtract from the access token database ttl.

View Source
const USERS_GSI_NAME = "GSI"
View Source
const USERS_TABLE_NAME = "Users"

/////////////

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
	TokenType   string `json:"token_type"`
	Scope       string `json:"scope"`
	AcquiredAt  int64  // Set by the code.
	Hash        string // Set by the code.
}

type Accts

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

func (*Accts) GetAll

func (ac *Accts) GetAll() []AcctsItem

///////////////////// https://thomasstep.com/blog/using-dynamodb-with-golang#string-sets - StringSets

func (*Accts) GetAllSortKey added in v0.0.59

func (ac *Accts) GetAllSortKey(id, sortKey string) []AcctsItem

///////////////////// https://thomasstep.com/blog/using-dynamodb-with-golang#string-sets - StringSets

func (*Accts) GetState

func (ac *Accts) GetState(id, sortKey string) *string

////////////////////////////////////////

func (*Accts) Init

func (ac *Accts) Init(ctx context.Context)

///////////////////// https://dynobase.dev/dynamodb-golang-query-examples/

func (*Accts) RemoveState added in v0.0.33

func (ac *Accts) RemoveState(id, sortKey string) bool

/////////////////////

func (*Accts) SetState

func (ac *Accts) SetState(id, sortKey, state string) bool

///////////////////// https://thomasstep.com/blog/using-dynamodb-with-golang#string-sets - StringSets

type AcctsItem

type AcctsItem struct {
	Id       string  `dynamodbav:"id"`
	Alias    string  `dynamodbav:"alias"`
	Email    string  `dynamodbav:"email"`
	LastUsed int     `dynamodbav:"last_used"`
	State    *string `dynamodbav:"state,omitempty"`
}

/////////////

type ActiveLabItems

type ActiveLabItems struct {
	Params []string `dynamodbav:"params"`
}

/////////////

type ActiveLabs

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

func (*ActiveLabs) BatchDelete

func (ac *ActiveLabs) BatchDelete(ctx context.Context, id string, sortKeys []string) error

////////////////////////////////////////

func (*ActiveLabs) DeleteAll

func (ac *ActiveLabs) DeleteAll(ctx context.Context, id, sortKey string) error

////////////////////////////////////////

func (*ActiveLabs) DeleteParams

func (ac *ActiveLabs) DeleteParams(ctx context.Context, id, sortKey string, params []string) error

////////////////////////////////////////

func (*ActiveLabs) GetAll

func (ac *ActiveLabs) GetAll(ctx context.Context, id, expression string) []ActiveLabItems

////////////////////////////////////////

func (*ActiveLabs) GetAllIndex

func (ac *ActiveLabs) GetAllIndex(ctx context.Context, sort_key string) []ActiveLabItems

////////////////////////////////////////

func (*ActiveLabs) GetAllSortKey

func (ac *ActiveLabs) GetAllSortKey(ctx context.Context, id, sortKey string) []ActiveLabItems

////////////////////////////////////////

func (*ActiveLabs) GetLaunch

func (ac *ActiveLabs) GetLaunch(id string) *Launch

////////////////////////////////////////

func (*ActiveLabs) GetParams

func (ac *ActiveLabs) GetParams(id, sortKey string) []string

////////////////////////////////////////

func (*ActiveLabs) Init

func (ac *ActiveLabs) Init(ctx context.Context)

///////////////////// https://dynobase.dev/dynamodb-golang-query-examples/

func (*ActiveLabs) SetLaunch

func (ac *ActiveLabs) SetLaunch(id string, launch Launch) error

//

func (*ActiveLabs) SetParams

func (ac *ActiveLabs) SetParams(id, sortKey string, params []string) error

///////////////////// https://thomasstep.com/blog/using-dynamodb-with-golang#string-sets - StringSets

func (*ActiveLabs) SetState

func (ac *ActiveLabs) SetState(id, activeState string) error

///////////////////// https://thomasstep.com/blog/using-dynamodb-with-golang#string-sets - StringSets

type AuthParams

type AuthParams struct {
	State    string `dynamodbav:"state"`
	Nonce    string `dynamodbav:"nonce"`
	ClientId string `dynamodbav:"client_id"`
}

type CanvasConfig

type CanvasConfig struct {
	Platform       string   `dynamodbav:"platform"`
	AuthLoginUrl   string   `dynamodbav:"auth_login_url"`
	AuthTokenUrl   string   `dynamodbav:"auth_token_url"`
	DevelopmentIds []string `dynamodbav:"deployment_ids"`
	Domain         string   `dynamodbav:"domain"`
	TargetLinkUri  string   `dynamodbav:"target_link_uri"`
	KetSetUrl      string   `dynamodbav:"key_set_url"`
}

'ClientId' is the key

type ClassLabItem

type ClassLabItem struct {
	Id       string `json:"Id"`
	Desc     string `json:"Desc"`
	Attempts int    `json:"Attempts"`
}

type Classes

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

func (*Classes) Convert

func (cl *Classes) Convert(labItem string) ClassLabItem

/////////////////

func (*Classes) Get

func (cl *Classes) Get(ctx context.Context, id, sortKey string) []ClassLabItem

////////////////////////////////////////

func (*Classes) GetAll

func (cl *Classes) GetAll(ctx context.Context, id, sort_key string) []ClassLabItem

////////////////////////////////////////

func (*Classes) Init

func (cl *Classes) Init()

///////////////////// https://dynobase.dev/dynamodb-golang-query-examples/

func (*Classes) Set

func (cl *Classes) Set(ctx context.Context, id, sortKey string, labs []string) error

///////////////////// https://thomasstep.com/blog/using-dynamodb-with-golang#string-sets - StringSets

type DomainConfig added in v0.0.5

type DomainConfig struct {
	Created  string   `dynamodbav:"created"`
	Enabled  bool     `dynamodbav:"enabled"`
	Platform string   `dynamodbav:"platform"`
	Scopes   []string `dynamodbav:"scopes"`
	Contact  string   `dynamodbav:"contact"`
}

'Domain' is the key

type LabItem

type LabItem struct {
	Id         string            `dynamodbav:"id"`
	Name       string            `dynamodbav:"name"`
	Desc       string            `dynamodbav:"desc"`
	Duration   json.Number       `dynamodbav:"duration"`
	QQuestions map[string]string `dynamodbav:"qquestions"`
	QAnswers   map[string]string `dynamodbav:"qanswers"`
}

/////////////

type Labs

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

func (*Labs) Get

func (ac *Labs) Get(labId string) *LabItem

////////////////////////////////////////

func (*Labs) GetAll

func (ac *Labs) GetAll(ctx context.Context) []LabItem

////////////////////////////////////////

func (*Labs) Init

func (ac *Labs) Init(ctx context.Context)

///////////////////// https://dynobase.dev/dynamodb-golang-query-examples/

func (*Labs) SetLab

func (ac *Labs) SetLab(item LabItem) error

///////////////////// https://thomasstep.com/blog/using-dynamodb-with-golang#string-sets - StringSets

type Launch

type Launch struct {
	Id                string   `dynamodbav:"id" json:"id"`
	AwsAcctId         string   `dynamodbav:"aws_acct_id" json:"aws_acct_id"` // lower case that's how it is stored in the db.
	Timestamp         string   `dynamodbav:"timestamp" json:"timestamp"`
	ActiveState       string   `dynamodbav:"active_state" json:"active_state"`
	ExecutionArn      string   `dynamodbav:"execution_arn" json:"execution_arn"`
	LabId             string   `dynamodbav:"lab_id" json:"lab_id"`
	ClassId           string   `dynamodbav:"class_id" json:"class_id"`
	AttemptsRemaining int64    `dynamodbav:"attempts_remaining" json:"attempts_remaining"`
	Duration          int64    `dynamodbav:"duration" json:"duration"`
	Roles             []string `dynamodbav:"roles" json:"roles"`
	Services          []string `dynamodbav:"services" json:"services"`
	Name              string   `dynamodbav:"name" json:"name"`
	Email             string   `dynamodbav:"email" json:"email"`
}

Data acquired from both DynamoDb (dynamodbav) and cache (json).

type Oidc

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

func (*Oidc) DeleteLtiAccessToken

func (oi *Oidc) DeleteLtiAccessToken(scopesHash string) error

/////////////////////

func (*Oidc) DeleteLtiStateParams added in v0.0.8

func (oi *Oidc) DeleteLtiStateParams(state string) error

/////////////////////

func (*Oidc) GetLtiAccessToken

func (oi *Oidc) GetLtiAccessToken(scopesHash string) (string, error)

/////////////////////

func (*Oidc) GetLtiConfigParameters added in v0.0.3

func (oi *Oidc) GetLtiConfigParameters(clientId string) (*CanvasConfig, error)

////////////////////////////////////////

func (*Oidc) GetLtiDomainConfigParameters added in v0.0.6

func (oi *Oidc) GetLtiDomainConfigParameters(domain string) (*DomainConfig, error)

////////////////////////////////////////

func (*Oidc) GetLtiStateParams added in v0.0.3

func (oi *Oidc) GetLtiStateParams(state string) (*AuthParams, error)

/////////////////////

func (*Oidc) Init

func (oi *Oidc) Init(ctx context.Context)

///////////////////// https://dynobase.dev/dynamodb-golang-query-examples/

func (*Oidc) IsRoleAdministrator

func (oi *Oidc) IsRoleAdministrator(roles []string) bool

////////////////////////

func (*Oidc) IsRoleFaculty

func (oi *Oidc) IsRoleFaculty(roles []string) bool

////////////////////////

func (*Oidc) IsRoleInstructor

func (oi *Oidc) IsRoleInstructor(roles []string) bool

////////////////////////

func (*Oidc) IsRoleStudent

func (oi *Oidc) IsRoleStudent(roles []string) bool

//////////////////////// https://www.imsglobal.org/spec/lti/v1p3#role-vocabularies

func (*Oidc) SetLtiAccessToken

func (oi *Oidc) SetLtiAccessToken(at *AccessToken) error

/////////////////////

func (*Oidc) SetLtiStateParams added in v0.0.3

func (oi *Oidc) SetLtiStateParams(state, nonce, clientId string) error

/////////////////////////////////////////////////////////////////////////

type User

type User struct {
	Name   string            `dynamodbav:"name"`
	Email  string            `dynamodbav:"email"`
	Roles  []string          `dynamodbav:"roles"`
	Labs   map[string]string `dynamodbav:"labs"`
	Status string            `dynamodbav:"status"`
}

type UserAssessment

type UserAssessment struct {
	Id           string            `dynamodbav:"id"`
	SortKey      string            `dynamodbav:"sort_key"`
	Snapshots    map[string]string `dynamodbav:"snapshots"`
	QAnswers     map[string]string `dynamodbav:"qanswers"`
	QQuestions   map[string]string `dynamodbav:"qquestions"`
	QSubmissions map[string]string `dynamodbav:"qsubmissions"`
}

////////

type UserLab

type UserLab struct {
	Attempts int64 `json:"attempts"`
	Duration int64 `json:"duration"`
}

type Users

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

func (*Users) Get

func (st *Users) Get(id, sortKey string) (*User, map[string]UserLab)

////////////////////////////////////////

func (*Users) GetUserAssessment

func (st *Users) GetUserAssessment(id, labId, timestamp string) *UserAssessment

////////////////////////////////////////

func (*Users) GetUserAssessments

func (st *Users) GetUserAssessments(id string) []UserAssessment

////////////////////////////////////////

func (*Users) Init

func (st *Users) Init(ctx context.Context)

///////////////////// https://dynobase.dev/dynamodb-golang-query-examples/

func (*Users) SetInitialAssessment

func (st *Users) SetInitialAssessment(id, labId, timestamp string, questions map[string]string, answers map[string]string) error

/////////////////////

func (*Users) SetLabData added in v0.0.25

func (st *Users) SetLabData(id, sort_key, labId string, userLabData UserLab) error

/////////////////////

func (*Users) SetSnapshot

func (st *Users) SetSnapshot(id, labId, timestamp, serviceName string, param *string) error

/////////////////////

func (*Users) SetSubmission

func (st *Users) SetSubmission(id, labId, timestamp, ordinal, submission string) bool

////////////////////////////////////////

func (*Users) UpdateAll

func (st *Users) UpdateAll(prs []types.WriteRequest)

////////////////////////////////////////

Jump to

Keyboard shortcuts

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