models

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearChannelForURN added in v0.1.6

func ClearChannelForURN(ctx context.Context, db *sqlx.DB, interchange *Interchange, urn string) error

ClearChannelForURN clears any association with a channel a URN has

func SetChannelForURN

func SetChannelForURN(ctx context.Context, db *sqlx.DB, interchange *Interchange, channel *Channel, urn string) error

SetChannelForURN associates the passed in URN with the passed in Channel

func UpdateInterchangeConfig

func UpdateInterchangeConfig(ctx context.Context, db *sqlx.DB, interchanges []*Interchange) (err error)

UpdateInterchangeConfig updates our interchange configs according to the passed in interchanges. Returns any errors encountered during validation or writing to the db.

Types

type Channel

type Channel struct {
	UUID            string         `db:"uuid"              json:"uuid"      validate:"required,uuid4"`
	Name            string         `db:"name"              json:"name"      validate:"required"`
	InterchangeUUID string         `db:"interchange_uuid"  json:"-"`
	URL             string         `db:"url"               json:"url"       validate:"required,url"`
	Keywords        pq.StringArray `db:"keywords"          json:"keywords"`
}

Channel represents our channels

func GetChannelForURN

func GetChannelForURN(ctx context.Context, db *sqlx.DB, interchange *Interchange, urn string) (*Channel, error)

GetChannelForURN returns the channel that is associated with the passed in URN, if any

type Interchange

type Interchange struct {
	UUID               string    `db:"uuid"                  json:"uuid"     validate:"required,uuid4"`
	Name               string    `db:"name"                  json:"name"     validate:"required"`
	Country            string    `db:"country"               json:"country"  validate:"required"`
	Scheme             string    `db:"scheme"                json:"scheme"   validate:"required"`
	DefaultChannelUUID string    `db:"default_channel_uuid"  json:"-"`
	Channels           []Channel `                           json:"channels" validate:"required,dive"`
	// contains filtered or unexported fields
}

Interchange represents our interchanges

func GetInterchange

func GetInterchange(ctx context.Context, db *sqlx.DB, uuid string) (*Interchange, error)

GetInterchange returns the interchange configuration for the passed in UUID. This will include the channels for the interchange with the default channel being the first channel in the slice.

func GetInterchangeConfig

func GetInterchangeConfig(ctx context.Context, db *sqlx.DB) ([]*Interchange, error)

GetInterchangeConfig returns our complete interchange configuration

type URNMapping

type URNMapping struct {
	URN             string `db:"urn"              json:"urn"`
	InterchangeUUID string `db:"interchange_uuid" json:"interchange_uuid"`
	ChannelUUID     string `db:"channel_uuid"     json:"channel_uuid"`
}

URNMapping represents the mapping for a URN

Jump to

Keyboard shortcuts

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