model

package
v0.0.0-...-9057cf5 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitGlobalClient

func InitGlobalClient(initFunc func() (Client, error)) error

func IsDuplicateAttributeError

func IsDuplicateAttributeError(err error) bool

func NewAppId

func NewAppId() string

func NewAppName

func NewAppName() string

func SortAppsByAccessedTime

func SortAppsByAccessedTime(apps []*App)

func SortAppsByCreatedTime

func SortAppsByCreatedTime(apps []*App)

Types

type Api

type Api struct {
	Id                 string   `bson:"_id"`
	Name               string   `bson:"name"`
	LogoUrl            string   `bson:"logo_url"`
	Description        string   `bson:"description"`
	PortalUrl          string   `bson:"portal_url"`
	Tags               []string `bson:"tags"`
	Packages           []string `bson:"packages"`
	RequiredEnvVarKeys []string `bson:"required_env_var_keys"`
	OptionalEnvVarKeys []string `bson:"optional_env_var_keys"`
	Snippet            string   `bson:"snippet"`
}

func (*Api) ToJsonMap

func (api *Api) ToJsonMap() map[string]interface{}

type App

type App struct {
	// Metadata
	Id           string    `bson:"_id"`
	Description  string    `bson:"description"`
	Icon         string    `bson:"icon"`
	UserId       string    `bson:"user_id"`
	Name         string    `bson:"name"`
	WorktreeId   string    `bson:"worktree_id"`
	CreatedTime  time.Time `bson:"created_time"`
	AccessedTime time.Time `bson:"accessed_time"`
	Private      bool      `bson:"private"`

	StartCmd string         `bson:"start_cmd"`
	EnvVars  []KeyValuePair `bson:"env_vars"`

	Gallery bool `bson:"gallery"`

	// APIs enabled for this app
	ApiIds []string `bson:"api_ids"`

	SourceTimestamp  int64 `bson:"source_timestamp"`
	RunningTimestamp int64 `bson:"running_timestamp"`
}

func (*App) GetSystemEnvVarMap

func (app *App) GetSystemEnvVarMap() map[string]string

func (*App) ToJsonMap

func (app *App) ToJsonMap() map[string]interface{}

type AppsByAccessedTime

type AppsByAccessedTime []*App

func (AppsByAccessedTime) Len

func (bat AppsByAccessedTime) Len() int

func (AppsByAccessedTime) Less

func (bat AppsByAccessedTime) Less(i, j int) bool

func (AppsByAccessedTime) Swap

func (bat AppsByAccessedTime) Swap(i, j int)

type AppsByCreatedTime

type AppsByCreatedTime []*App

func (AppsByCreatedTime) Len

func (bct AppsByCreatedTime) Len() int

func (AppsByCreatedTime) Less

func (bct AppsByCreatedTime) Less(i, j int) bool

func (AppsByCreatedTime) Swap

func (bct AppsByCreatedTime) Swap(i, j int)

type Client

type Client interface {
	// App functions
	NewApp(app *App) (*App, error)
	UpdateApp(app *App, fields []string) error
	UpdateAppName(app *App, newName string) error
	UpdateAppDescription(app *App, newDescription string) error
	UpdateAppSourceTimestamp(app *App) error
	UpdateAppRunningTimestamp(app *App) error

	GetApp(id string) (*App, error)
	GetAppByName(name string) (*App, error)
	GetAppsByUserId(userId string) ([]*App, error)
	GetAppByWorktreeId(worktreeId string) (*App, error)
	GetGalleryApps(limit int) ([]*App, error)

	DeleteApp(id string) error

	// User functions
	GetUser(id string) (*User, error)

	// Api functions
	GetApis() ([]*Api, error)
	GetApi(id string) (*Api, error)
	GetApisByIds(ids []string) ([]*Api, error)
}

func C

func C() Client

func NewDummyClient

func NewDummyClient() Client

func NewMongodbClient

func NewMongodbClient(url string) (Client, error)

type DummyClient

type DummyClient struct {
	UserClient
	Mutex            sync.RWMutex
	IdToAppMap       map[string]*App
	NameToAppMap     map[string]*App
	WorktreeToAppMap map[string]*App

	IdToApiMap map[string]*Api
}

Dummy implementation of the client, for development only.

func (*DummyClient) DeleteApp

func (mc *DummyClient) DeleteApp(id string) error

func (*DummyClient) GetApi

func (mc *DummyClient) GetApi(id string) (*Api, error)

func (*DummyClient) GetApis

func (mc *DummyClient) GetApis() ([]*Api, error)

func (*DummyClient) GetApisByIds

func (mc *DummyClient) GetApisByIds(ids []string) ([]*Api, error)

func (*DummyClient) GetApp

func (mc *DummyClient) GetApp(id string) (*App, error)

func (*DummyClient) GetAppByName

func (mc *DummyClient) GetAppByName(name string) (*App, error)

func (*DummyClient) GetAppByWorktreeId

func (mc *DummyClient) GetAppByWorktreeId(worktreeId string) (*App, error)

func (*DummyClient) GetAppsByUserId

func (mc *DummyClient) GetAppsByUserId(userId string) ([]*App, error)

func (*DummyClient) GetGalleryApps

func (mc *DummyClient) GetGalleryApps(limit int) ([]*App, error)

func (*DummyClient) NewApp

func (mc *DummyClient) NewApp(app *App) (*App, error)

func (*DummyClient) UpdateApp

func (mc *DummyClient) UpdateApp(app *App, fields []string) error

func (*DummyClient) UpdateAppDescription

func (mc *DummyClient) UpdateAppDescription(app *App, newDescription string) error

func (*DummyClient) UpdateAppName

func (mc *DummyClient) UpdateAppName(app *App, newName string) error

func (*DummyClient) UpdateAppRunningTimestamp

func (mc *DummyClient) UpdateAppRunningTimestamp(app *App) error

func (*DummyClient) UpdateAppSourceTimestamp

func (mc *DummyClient) UpdateAppSourceTimestamp(app *App) error

type ErrorDuplicateAttribute

type ErrorDuplicateAttribute string

func (ErrorDuplicateAttribute) Error

func (ead ErrorDuplicateAttribute) Error() string

type KeyValuePair

type KeyValuePair struct {
	Key   string `bson:"key"`
	Value string `bson:"value"`
}

type MongodbClient

type MongodbClient struct {
	UserClient
	// contains filtered or unexported fields
}

func (*MongodbClient) DeleteApp

func (mc *MongodbClient) DeleteApp(id string) error

func (*MongodbClient) GetApi

func (mc *MongodbClient) GetApi(id string) (*Api, error)

func (*MongodbClient) GetApis

func (mc *MongodbClient) GetApis() ([]*Api, error)

func (*MongodbClient) GetApisByIds

func (mc *MongodbClient) GetApisByIds(ids []string) ([]*Api, error)

func (*MongodbClient) GetApp

func (mc *MongodbClient) GetApp(id string) (*App, error)

func (*MongodbClient) GetAppByName

func (mc *MongodbClient) GetAppByName(name string) (*App, error)

func (*MongodbClient) GetAppByWorktreeId

func (mc *MongodbClient) GetAppByWorktreeId(worktreeId string) (*App, error)

func (*MongodbClient) GetAppsByUserId

func (mc *MongodbClient) GetAppsByUserId(userId string) ([]*App, error)

func (*MongodbClient) GetGalleryApps

func (mc *MongodbClient) GetGalleryApps(limit int) ([]*App, error)

func (*MongodbClient) NewApp

func (mc *MongodbClient) NewApp(app *App) (*App, error)

func (*MongodbClient) UpdateApp

func (mc *MongodbClient) UpdateApp(app *App, fields []string) error

func (*MongodbClient) UpdateAppDescription

func (mc *MongodbClient) UpdateAppDescription(app *App, newDescription string) error

func (*MongodbClient) UpdateAppName

func (mc *MongodbClient) UpdateAppName(app *App, newName string) error

func (*MongodbClient) UpdateAppRunningTimestamp

func (mc *MongodbClient) UpdateAppRunningTimestamp(app *App) error

func (*MongodbClient) UpdateAppSourceTimestamp

func (mc *MongodbClient) UpdateAppSourceTimestamp(app *App) error

type User

type User struct {
	Id       string `json:"user_id"`
	Name     string `json:"name"`
	Nickname string `json:"nickname"`
	Picture  string `json:"picture"`
}

type UserClient

type UserClient struct {
	AccessToken string
	Mutex       sync.Mutex
}

func (*UserClient) GetUser

func (uc *UserClient) GetUser(id string) (*User, error)

func (*UserClient) RenewToken

func (uc *UserClient) RenewToken() error

Jump to

Keyboard shortcuts

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