* Add Playground struct and basic support for creating it and retrieving it * Add missing functions in pwd mock * Get playground from request domain and validate it exists. If valid set it on the newly created session. * Move playground specific configurations to the playground struct and use it everytime we need that conf. * Don't allow to specify a duration bigger that the allowed in the playground
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package storage
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/play-with-docker/play-with-docker/pwd/types"
|
|
)
|
|
|
|
var NotFoundError = errors.New("NotFound")
|
|
|
|
func NotFound(e error) bool {
|
|
return e == NotFoundError
|
|
}
|
|
|
|
type StorageApi interface {
|
|
SessionGet(id string) (*types.Session, error)
|
|
SessionGetAll() ([]*types.Session, error)
|
|
SessionPut(session *types.Session) error
|
|
SessionDelete(id string) error
|
|
SessionCount() (int, error)
|
|
|
|
InstanceGet(name string) (*types.Instance, error)
|
|
InstancePut(instance *types.Instance) error
|
|
InstanceDelete(name string) error
|
|
InstanceCount() (int, error)
|
|
InstanceFindBySessionId(sessionId string) ([]*types.Instance, error)
|
|
|
|
WindowsInstanceGetAll() ([]*types.WindowsInstance, error)
|
|
WindowsInstancePut(instance *types.WindowsInstance) error
|
|
WindowsInstanceDelete(id string) error
|
|
|
|
ClientGet(id string) (*types.Client, error)
|
|
ClientPut(client *types.Client) error
|
|
ClientDelete(id string) error
|
|
ClientCount() (int, error)
|
|
ClientFindBySessionId(sessionId string) ([]*types.Client, error)
|
|
|
|
LoginRequestPut(loginRequest *types.LoginRequest) error
|
|
LoginRequestGet(id string) (*types.LoginRequest, error)
|
|
LoginRequestDelete(id string) error
|
|
|
|
UserFindByProvider(providerName, providerUserId string) (*types.User, error)
|
|
UserPut(user *types.User) error
|
|
UserGet(id string) (*types.User, error)
|
|
|
|
PlaygroundPut(playground *types.Playground) error
|
|
PlaygroundGet(id string) (*types.Playground, error)
|
|
PlaygroundGetAll() ([]*types.Playground, error)
|
|
}
|