Help us shape the future of Go! Take the 2026 Go Developer Survey

static

package
v0.267.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 11 Imported by: 6

Documentation

Overview

Package static is an implementation of Source which loads assets from a static JSON file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCampaign added in v0.247.5

func NewCampaign(uuid assets.CampaignUUID, name string) assets.Campaign

NewCampaign creates a new campaign

func NewChannel added in v0.134.0

func NewChannel(uuid assets.ChannelUUID, name string, address string, schemes []string, roles []assets.ChannelRole, features []assets.ChannelFeature) assets.Channel

NewChannel creates a new channel

func NewClassifier added in v0.134.0

func NewClassifier(uuid assets.ClassifierUUID, name string, type_ string, intents []string) assets.Classifier

NewClassifier creates a new classifier

func NewField added in v0.134.0

func NewField(uuid assets.FieldUUID, key string, name string, valueType assets.FieldType) assets.Field

NewField creates a new field from the passed in key, name and type

func NewFlow added in v0.151.0

func NewFlow(uuid assets.FlowUUID, name string, definition []byte) assets.Flow

NewFlow creates a new flow from the passed in UUID, name and definition

func NewGlobal added in v0.134.0

func NewGlobal(key, name, value string) assets.Global

NewGlobal creates a new global

func NewGroup added in v0.134.0

func NewGroup(uuid assets.GroupUUID, name string, query string) assets.Group

NewGroup creates a new group from the passed in UUID, name and query

func NewLLM added in v0.232.0

func NewLLM(uuid assets.LLMUUID, name string, type_ string) assets.LLM

NewLLM creates a new LLM

func NewLabel added in v0.134.0

func NewLabel(uuid assets.LabelUUID, name string) assets.Label

NewLabel creates a new label from the passed in UUID and name

func NewOptIn added in v0.195.0

func NewOptIn(uuid assets.OptInUUID, name string, channel *assets.ChannelReference) assets.OptIn

NewOptIn creates a new topic

func NewResthook added in v0.134.0

func NewResthook(slug string, subscribers []string) assets.Resthook

NewResthook creates a new resthook

func NewTelChannel added in v0.134.0

func NewTelChannel(uuid assets.ChannelUUID, name string, address string, roles []assets.ChannelRole, parent *assets.ChannelReference, country i18n.Country, matchPrefixes []string, allowInternational bool) assets.Channel

NewTelChannel creates a new tel channel

func NewTopic added in v0.134.0

func NewTopic(uuid assets.TopicUUID, name string) assets.Topic

NewTopic creates a new topic

func NewUser added in v0.134.0

func NewUser(uuid assets.UserUUID, name, email string) assets.User

NewUser creates a new user from the passed in email and name

Types

type Campaign added in v0.247.5

type Campaign struct {
	UUID_ assets.CampaignUUID `json:"uuid"  validate:"required,uuid"`
	Name_ string              `json:"name"  validate:"required"`
}

Campaign is a JSON serializable implementation of a campaign asset

func (*Campaign) Name added in v0.247.5

func (t *Campaign) Name() string

Name returns the name of this campaign

func (*Campaign) UUID added in v0.247.5

func (t *Campaign) UUID() assets.CampaignUUID

UUID returns the UUID of this campaign

type Channel added in v0.134.0

type Channel struct {
	UUID_               assets.ChannelUUID      `json:"uuid" validate:"required,uuid"`
	Name_               string                  `json:"name"`
	Address_            string                  `json:"address"`
	Schemes_            []string                `json:"schemes" validate:"min=1"`
	Roles_              []assets.ChannelRole    `json:"roles" validate:"min=1,dive,eq=send|eq=receive|eq=call|eq=answer|eq=ussd"`
	Features_           []assets.ChannelFeature `json:"features,omitempty"`
	Country_            i18n.Country            `json:"country,omitempty"`
	MatchPrefixes_      []string                `json:"match_prefixes,omitempty"`
	AllowInternational_ bool                    `json:"allow_international,omitempty"`
}

Channel is a JSON serializable implementation of a channel asset

func (*Channel) Address added in v0.134.0

func (c *Channel) Address() string

Address returns the address of this channel

func (*Channel) AllowInternational added in v0.134.0

func (c *Channel) AllowInternational() bool

AllowInternational returns whether this channel allows sending internationally (only applies to TEL schemes)

func (*Channel) Country added in v0.134.0

func (c *Channel) Country() i18n.Country

Country returns this channel's associated country code (if any)

func (*Channel) Features added in v0.195.0

func (c *Channel) Features() []assets.ChannelFeature

Features returnsthe featurs this channel supports

func (*Channel) MatchPrefixes added in v0.134.0

func (c *Channel) MatchPrefixes() []string

MatchPrefixes returns this channel's match prefixes values used for selecting a channel for a URN (if any)

func (*Channel) Name added in v0.134.0

func (c *Channel) Name() string

Name returns the name of this channel

func (*Channel) Roles added in v0.134.0

func (c *Channel) Roles() []assets.ChannelRole

Roles returns the roles of this channel

func (*Channel) Schemes added in v0.134.0

func (c *Channel) Schemes() []string

Schemes returns the supported schemes of this channel

func (*Channel) UUID added in v0.134.0

func (c *Channel) UUID() assets.ChannelUUID

UUID returns the UUID of this channel

type Classifier added in v0.134.0

type Classifier struct {
	UUID_    assets.ClassifierUUID `json:"uuid" validate:"required,uuid"`
	Name_    string                `json:"name"`
	Type_    string                `json:"type"`
	Intents_ []string              `json:"intents"`
}

Classifier is a JSON serializable implementation of a classifier asset

func (*Classifier) Intents added in v0.134.0

func (c *Classifier) Intents() []string

Intents returns the intents of this classifier

func (*Classifier) Name added in v0.134.0

func (c *Classifier) Name() string

Name returns the name of this channel

func (*Classifier) Type added in v0.134.0

func (c *Classifier) Type() string

Type returns the type of this classifier

func (*Classifier) UUID added in v0.134.0

func (c *Classifier) UUID() assets.ClassifierUUID

UUID returns the UUID of this channel

type Field added in v0.134.0

type Field struct {
	UUID_ assets.FieldUUID `json:"uuid"`
	Key_  string           `json:"key" validate:"required"`
	Name_ string           `json:"name"`
	Type_ assets.FieldType `json:"type" validate:"required"`
}

Field is a JSON serializable implementation of a field asset

func (*Field) Key added in v0.134.0

func (f *Field) Key() string

Key returns the unique key of the field

func (*Field) Name added in v0.134.0

func (f *Field) Name() string

Name returns the name of the field

func (*Field) Type added in v0.134.0

func (f *Field) Type() assets.FieldType

Type returns the value type of the field

func (*Field) UUID added in v0.134.0

func (f *Field) UUID() assets.FieldUUID

UUID returns the UUID of this field

type Flow added in v0.134.0

type Flow struct {
	UUID_       assets.FlowUUID `json:"uuid" validate:"required,uuid"`
	Name_       string          `json:"name"`
	Definition_ []byte
}

Flow is a JSON serializable implementation of a flow asset

func (*Flow) Definition added in v0.134.0

func (f *Flow) Definition() []byte

func (*Flow) Name added in v0.134.0

func (f *Flow) Name() string

Name returns the name of the flow

func (*Flow) UUID added in v0.134.0

func (f *Flow) UUID() assets.FlowUUID

UUID returns the UUID of the flow

func (*Flow) UnmarshalJSON added in v0.134.0

func (f *Flow) UnmarshalJSON(data []byte) error

type Global added in v0.134.0

type Global struct {
	Key_   string `json:"key" validate:"required"`
	Name_  string `json:"name"`
	Value_ string `json:"value"`
}

Global is a JSON serializable implementation of a global asset

func (*Global) Key added in v0.134.0

func (g *Global) Key() string

Key returns the key of this global

func (*Global) Name added in v0.134.0

func (g *Global) Name() string

Name returns the name of this global

func (*Global) Value added in v0.134.0

func (g *Global) Value() string

Value returns the type of this global

type Group added in v0.134.0

type Group struct {
	UUID_  assets.GroupUUID `json:"uuid" validate:"required,uuid"`
	Name_  string           `json:"name"`
	Query_ string           `json:"query,omitempty"`
}

Group is a JSON serializable implementation of a group asset

func (*Group) Name added in v0.134.0

func (g *Group) Name() string

Name returns the name of the group

func (*Group) Query added in v0.134.0

func (g *Group) Query() string

Query returns the query of a query based group

func (*Group) UUID added in v0.134.0

func (g *Group) UUID() assets.GroupUUID

UUID returns the UUID of the group

type LLM added in v0.232.0

type LLM struct {
	UUID_ assets.LLMUUID `json:"uuid" validate:"required,uuid"`
	Name_ string         `json:"name"`
	Type_ string         `json:"type"`
}

LLM is a JSON serializable implementation of an LLM asset

func (*LLM) Name added in v0.232.0

func (l *LLM) Name() string

Name returns the name of this LLM

func (*LLM) Type added in v0.232.0

func (l *LLM) Type() string

Type returns the type of this LLM

func (*LLM) UUID added in v0.232.0

func (l *LLM) UUID() assets.LLMUUID

UUID returns the UUID of this LLM

type Label added in v0.134.0

type Label struct {
	UUID_ assets.LabelUUID `json:"uuid" validate:"required,uuid"`
	Name_ string           `json:"name"`
}

Label is a JSON serializable implementation of a label asset

func (*Label) Name added in v0.134.0

func (l *Label) Name() string

Name returns the name of the label

func (*Label) UUID added in v0.134.0

func (l *Label) UUID() assets.LabelUUID

UUID returns the UUID of the label

type OptIn added in v0.195.0

type OptIn struct {
	UUID_ assets.OptInUUID `json:"uuid" validate:"required,uuid"`
	Name_ string           `json:"name" validate:"required"`
}

OptIn is a JSON serializable implementation of an optin asset

func (*OptIn) Name added in v0.195.0

func (t *OptIn) Name() string

Name returns the name of this optin

func (*OptIn) UUID added in v0.195.0

func (t *OptIn) UUID() assets.OptInUUID

UUID returns the UUID of this optin

type Resthook added in v0.134.0

type Resthook struct {
	Slug_        string   `json:"slug" validate:"required"`
	Subscribers_ []string `json:"subscribers" validate:"required,dive,url"`
}

Resthook is a JSON serializable implementation of a resthook asset

func (*Resthook) Slug added in v0.134.0

func (r *Resthook) Slug() string

Slug returns the slug of the resthook

func (*Resthook) Subscribers added in v0.134.0

func (r *Resthook) Subscribers() []string

Subscribers returns the subscribers to the resthook

type StaticSource

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

StaticSource is an asset source which loads assets from a static JSON file

func LoadSource added in v0.26.0

func LoadSource(path string) (*StaticSource, error)

LoadSource loads a new static source from the given JSON file

func NewEmptySource added in v0.26.0

func NewEmptySource() *StaticSource

NewEmptySource creates a new empty source with no assets

func NewSource added in v0.26.0

func NewSource(data []byte) (*StaticSource, error)

NewSource creates a new static source from the given JSON

func (*StaticSource) Campaigns added in v0.247.5

func (s *StaticSource) Campaigns() ([]assets.Campaign, error)

Campaigns returns all campaign assets

func (*StaticSource) Channels

func (s *StaticSource) Channels() ([]assets.Channel, error)

Channels returns all channel assets

func (*StaticSource) Classifiers added in v0.51.0

func (s *StaticSource) Classifiers() ([]assets.Classifier, error)

Classifiers returns all classifier assets

func (*StaticSource) Fields

func (s *StaticSource) Fields() ([]assets.Field, error)

Fields returns all field assets

func (*StaticSource) FlowByName added in v0.151.0

func (s *StaticSource) FlowByName(name string) (assets.Flow, error)

Flow returns the flow asset with the given UUID

func (*StaticSource) FlowByUUID added in v0.151.0

func (s *StaticSource) FlowByUUID(uuid assets.FlowUUID) (assets.Flow, error)

Flow returns the flow asset with the given UUID

func (*StaticSource) Globals added in v0.57.0

func (s *StaticSource) Globals() ([]assets.Global, error)

Globals returns all global assets

func (*StaticSource) Groups

func (s *StaticSource) Groups() ([]assets.Group, error)

Groups returns all group assets

func (*StaticSource) LLMs added in v0.232.0

func (s *StaticSource) LLMs() ([]assets.LLM, error)

LLMs returns all LLM assets

func (*StaticSource) Labels

func (s *StaticSource) Labels() ([]assets.Label, error)

Labels returns all label assets

func (*StaticSource) Locations

func (s *StaticSource) Locations() ([]assets.LocationHierarchy, error)

Locations returns all location assets

func (*StaticSource) OptIns added in v0.195.0

func (s *StaticSource) OptIns() ([]assets.OptIn, error)

OptIns returns all optin assets

func (*StaticSource) Resthooks

func (s *StaticSource) Resthooks() ([]assets.Resthook, error)

Resthooks returns all resthook assets

func (*StaticSource) Templates added in v0.32.0

func (s *StaticSource) Templates() ([]assets.Template, error)

Templates returns all template assets

func (*StaticSource) Topics added in v0.132.0

func (s *StaticSource) Topics() ([]assets.Topic, error)

Topics returns all topic assets

func (*StaticSource) Users added in v0.124.0

func (s *StaticSource) Users() ([]assets.User, error)

Users returns all user assets

type Template added in v0.134.0

type Template struct {
	UUID_         assets.TemplateUUID    `json:"uuid"         validate:"required,uuid"`
	Name_         string                 `json:"name"`
	Translations_ []*TemplateTranslation `json:"translations"`
}

Template is a JSON serializable implementation of a template asset

func NewTemplate added in v0.134.0

func NewTemplate(uuid assets.TemplateUUID, name string, translations []*TemplateTranslation) *Template

NewTemplate creates a new template

func (*Template) Name added in v0.134.0

func (t *Template) Name() string

Name returns the name of this template

func (*Template) Translations added in v0.134.0

func (t *Template) Translations() []assets.TemplateTranslation

Translations returns the translations for this template

func (*Template) UUID added in v0.134.0

func (t *Template) UUID() assets.TemplateUUID

UUID returns the UUID of this template

type TemplateComponent added in v0.201.0

type TemplateComponent struct {
	Name_      string         `json:"name"`
	Type_      string         `json:"type"`
	Content_   string         `json:"content"`
	Display_   string         `json:"display"`
	Variables_ map[string]int `json:"variables"`
}

func NewTemplateComponent added in v0.201.0

func NewTemplateComponent(name, type_, content, display string, variables map[string]int) *TemplateComponent

NewTemplateComponent creates a new template param

func (*TemplateComponent) Content added in v0.201.0

func (t *TemplateComponent) Content() string

Content returns the content for this template component

func (*TemplateComponent) Display added in v0.206.4

func (t *TemplateComponent) Display() string

Display returns the display for this template component

func (*TemplateComponent) Name added in v0.207.0

func (t *TemplateComponent) Name() string

Name returns the name for this template component

func (*TemplateComponent) Type added in v0.206.4

func (t *TemplateComponent) Type() string

Type returns the type for this template component

func (*TemplateComponent) Variables added in v0.208.0

func (t *TemplateComponent) Variables() map[string]int

Variables returns the variable mapping for this template component

type TemplateTranslation added in v0.134.0

type TemplateTranslation struct {
	Channel_    *assets.ChannelReference `json:"channel"      validate:"required"`
	Locale_     i18n.Locale              `json:"locale"       validate:"required"`
	Components_ []*TemplateComponent     `json:"components"`
	Variables_  []*TemplateVariable      `json:"variables"`
}

TemplateTranslation represents a single template translation

func NewTemplateTranslation added in v0.134.0

func NewTemplateTranslation(channel *assets.ChannelReference, locale i18n.Locale, components []*TemplateComponent, variables []*TemplateVariable) *TemplateTranslation

NewTemplateTranslation creates a new template translation

func (*TemplateTranslation) Channel added in v0.134.0

Channel returns the channel this template translation is for

func (*TemplateTranslation) Components added in v0.201.0

func (t *TemplateTranslation) Components() []assets.TemplateComponent

Components returns the components for this template translation

func (*TemplateTranslation) Locale added in v0.178.0

func (t *TemplateTranslation) Locale() i18n.Locale

Locale returns the locale this translation is in

func (*TemplateTranslation) Variables added in v0.208.0

func (t *TemplateTranslation) Variables() []assets.TemplateVariable

Variables returns the variables for this template translation

type TemplateVariable added in v0.208.0

type TemplateVariable struct {
	Type_ string `json:"type"`
}

TemplateVariable represents a single variable for a template translation

func NewTemplateVariable added in v0.208.0

func NewTemplateVariable(paramType string) *TemplateVariable

NewTemplateVariable creates a new template variable

func (*TemplateVariable) Type added in v0.208.0

func (t *TemplateVariable) Type() string

Type returns the type for this parameter

type Topic added in v0.134.0

type Topic struct {
	UUID_ assets.TopicUUID `json:"uuid" validate:"required,uuid"`
	Name_ string           `json:"name"`
}

Topic is a JSON serializable implementation of a topic asset

func (*Topic) Name added in v0.134.0

func (t *Topic) Name() string

Name returns the name of this topic

func (*Topic) UUID added in v0.134.0

func (t *Topic) UUID() assets.TopicUUID

UUID returns the UUID of this topic

type User added in v0.134.0

type User struct {
	UUID_  assets.UserUUID `json:"uuid"  validate:"required"`
	Name_  string          `json:"name"`
	Email_ string          `json:"email" validate:"required"`
}

User is a JSON serializable implementation of a user asset

func (*User) Email added in v0.134.0

func (u *User) Email() string

Email returns the unique email address of the user

func (*User) Name added in v0.134.0

func (u *User) Name() string

Name returns the name of the user

func (*User) UUID added in v0.245.0

func (u *User) UUID() assets.UserUUID

UUID returns the UUID of the user

Jump to

Keyboard shortcuts

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