graphql_api

package
v0.0.0-...-826d235 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidSessionError = errors.New("invalid session")
)

Functions

This section is empty.

Types

type APIKeyQueryParams

type APIKeyQueryParams struct {
	UserID *int `json:"userId" graphql:"userId"`
}

type ControlType

type ControlType struct {
	ID   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type CreateAPIKeyResponse

type CreateAPIKeyResponse struct {
	APIKey platform.APIKey `json:"createApiKey"`
}

type CreateEventResponse

type CreateEventResponse struct {
	Event platform.Event `json:"createEvent"`
}

type CreateMultiplayerServerConfigResponse

type CreateMultiplayerServerConfigResponse struct {
	CreateMultiplayerServerConfig platform.MultiplayerServerConfig `graphql:"createMultiplayerServerConfig(input: $input)"`
}

type CreateMultiplayerServerVersionResponse

type CreateMultiplayerServerVersionResponse struct {
	CreateMultiplayerServerVersion platform.MultiplayerServerVersion `graphql:"createMultiplayerServerVersion(input: $input)"`
}

type CreateSessionResponse

type CreateSessionResponse struct {
	Session Session `json:"createSession"`
}

type CreateUserResponse

type CreateUserResponse struct {
	User platform.User `json:"createUser"`
}

type DeleteAPIKeyResponse

type DeleteAPIKeyResponse struct {
	Success bool `json:"deleteApiKey"`
}

type DeleteUserResponse

type DeleteUserResponse struct {
	Success bool `json:"deleteUser"`
}

type GetAPIKeysResponse

type GetAPIKeysResponse struct {
	APIKeys []*platform.APIKey `json:"apiKeys"`
}

type GetControlTypesResponse

type GetControlTypesResponse struct {
	ControlTypes []*ControlType `json:"controls,omitempty"`
}

type GetPlatformsResponse

type GetPlatformsResponse struct {
	Platforms []*Platform `json:"platforms,omitempty"`
}

type GetUserResponse

type GetUserResponse struct {
	User platform.User `json:"user"`
}

type GraphQLAPIClient

type GraphQLAPIClient struct {
	*abstract_client.AbstractServiceClient
	*graphql.Client
	// contains filtered or unexported fields
}

GraphQLAPIClient is a struct for the graphql API that contains an abstract client

func NewClient

func NewClient(config urlfinder.ClientConfig) *GraphQLAPIClient

NewClient is a function that returns a GraphQLAPIClient

func NewClientWithBasicAuth

func NewClientWithBasicAuth(username, password string, config urlfinder.ClientConfig) (*GraphQLAPIClient, error)

NewClientWithBasicAuth is a function that returns a GraphQLAPIClient with basic auth performed

func (*GraphQLAPIClient) ActiveOrgID

func (g *GraphQLAPIClient) ActiveOrgID() int

func (*GraphQLAPIClient) ActiveUserID

func (g *GraphQLAPIClient) ActiveUserID() int

func (*GraphQLAPIClient) CreateAPIKey

func (g *GraphQLAPIClient) CreateAPIKey(ctx context.Context, input platform.APIKey) (*platform.APIKey, error)

func (*GraphQLAPIClient) CreateEvent

func (g *GraphQLAPIClient) CreateEvent(ctx context.Context, sessionID int, uuid string, eventType string, data string) (*platform.Event, error)

func (*GraphQLAPIClient) CreateModuleVersion

func (g *GraphQLAPIClient) CreateModuleVersion(ctx context.Context, input ModuleVersion) (*ModuleVersion, error)

func (*GraphQLAPIClient) CreateMultiplayerServerVersion

func (g *GraphQLAPIClient) CreateMultiplayerServerVersion(ctx context.Context, input MultiplayerServerVersion) (*MultiplayerServerVersion, error)

func (*GraphQLAPIClient) CreateSession

func (g *GraphQLAPIClient) CreateSession(ctx context.Context, moduleID int, ipAddress, deviceId string) (*Session, error)

func (*GraphQLAPIClient) CreateUser

func (g *GraphQLAPIClient) CreateUser(ctx context.Context, user platform.User) (*platform.User, error)

func (*GraphQLAPIClient) DeleteAPIKey

func (g *GraphQLAPIClient) DeleteAPIKey(ctx context.Context, id int) error

func (*GraphQLAPIClient) DeleteUser

func (g *GraphQLAPIClient) DeleteUser(ctx context.Context, id int) error

func (*GraphQLAPIClient) GetAPIKeys

func (g *GraphQLAPIClient) GetAPIKeys(ctx context.Context, params *APIKeyQueryParams) ([]*platform.APIKey, error)

func (*GraphQLAPIClient) GetControlTypes

func (g *GraphQLAPIClient) GetControlTypes(ctx context.Context) ([]*ControlType, error)

func (*GraphQLAPIClient) GetMultiplayerServerConfigs

func (*GraphQLAPIClient) GetMultiplayerServerVersion

func (g *GraphQLAPIClient) GetMultiplayerServerVersion(ctx context.Context, versionID int) (*MultiplayerServerVersion, error)

func (*GraphQLAPIClient) GetMultiplayerServerVersions

func (g *GraphQLAPIClient) GetMultiplayerServerVersions(ctx context.Context, params *MultiplayerServerVersionQueryParams) ([]*MultiplayerServerVersion, error)

func (*GraphQLAPIClient) GetPlatforms

func (g *GraphQLAPIClient) GetPlatforms(ctx context.Context) ([]*Platform, error)

func (*GraphQLAPIClient) GetSession

func (g *GraphQLAPIClient) GetSession(ctx context.Context, id int) (*Session, error)

func (*GraphQLAPIClient) GetUserByUsername

func (g *GraphQLAPIClient) GetUserByUsername(ctx context.Context, username string) (*platform.User, error)

func (*GraphQLAPIClient) Login

func (g *GraphQLAPIClient) Login(username, password string) error

Login performs a login request to the API

func (*GraphQLAPIClient) SetAPIKey

func (g *GraphQLAPIClient) SetAPIKey(key string)

func (*GraphQLAPIClient) SetToken

func (g *GraphQLAPIClient) SetToken(token string)

func (*GraphQLAPIClient) UpdateSession

func (g *GraphQLAPIClient) UpdateSession(ctx context.Context, session Session) (*Session, error)

func (*GraphQLAPIClient) UpdateUser

func (g *GraphQLAPIClient) UpdateUser(ctx context.Context, user platform.User) (*platform.User, error)

type LoginRequest

type LoginRequest struct {
	Login    string `json:"login"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	Token string           `json:"token"`
	User  primary_api.User `json:"user"`
}

type MockGraphQLClient

type MockGraphQLClient struct {
	abstract_client.MockAbstractClient

	CalledGetUser bool
	GetUserError  bool

	CalledCreateUser bool
	CreateUserError  bool

	CalledUpdateUser bool
	UpdateUserError  bool

	CalledDeleteUser bool
	DeleteUserError  bool

	CalledGetAPIKeys bool
	GetAPIKeysEmpty  bool
	GetAPIKeysError  bool

	CalledCreateAPIKey bool
	CreateAPIKeyError  bool

	CalledDeleteAPIKey bool
	DeleteAPIKeyError  bool

	CalledGetSession bool
	GetSessionError  bool

	CalledCreateSession bool
	CreateSessionError  bool

	CalledUpdateSession bool
	UpdateSessionError  bool

	CalledCreateEvent bool
	CreateEventError  bool

	CalledGetPlatforms bool
	GetPlatformsError  bool

	CalledGetControlTypes bool
	GetControlTypesError  bool

	CalledCreateModuleVersion bool
	CreateModuleVersionError  bool

	CalledGetMultiplayerServerConfigs        bool
	GetMultiplayerServerConfigsError         bool
	GetMultiplayerServerConfigsEmpty         bool
	GetMultiplayerServerConfigsEmptyVersions bool

	CalledGetMultiplayerServerVersions bool
	GetMultiplayerServerVersionsError  bool
	GetMultiplayerServerVersionsEmpty  bool

	CalledGetMultiplayerServerVersion bool
	GetMultiplayerServerVersionError  bool
	GetMultiplayerServerVersionEmpty  bool

	CalledCreateMultiplayerServerVersion bool
	CreateMultiplayerServerVersionError  bool
	// contains filtered or unexported fields
}

func (*MockGraphQLClient) ActiveOrgID

func (m *MockGraphQLClient) ActiveOrgID() int

func (*MockGraphQLClient) ActiveUserID

func (m *MockGraphQLClient) ActiveUserID() int

func (*MockGraphQLClient) CreateAPIKey

func (m *MockGraphQLClient) CreateAPIKey(ctx context.Context, input platform.APIKey) (*platform.APIKey, error)

func (*MockGraphQLClient) CreateEvent

func (m *MockGraphQLClient) CreateEvent(ctx context.Context, sessionID int, uuid string, eventType string, data string) (*platform.Event, error)

func (*MockGraphQLClient) CreateModuleVersion

func (m *MockGraphQLClient) CreateModuleVersion(ctx context.Context, input ModuleVersion) (*ModuleVersion, error)

func (*MockGraphQLClient) CreateMultiplayerServerVersion

func (m *MockGraphQLClient) CreateMultiplayerServerVersion(ctx context.Context, input MultiplayerServerVersion) (*MultiplayerServerVersion, error)

func (*MockGraphQLClient) CreateSession

func (m *MockGraphQLClient) CreateSession(ctx context.Context, moduleID int, ipAddress, deviceId string) (*Session, error)

func (*MockGraphQLClient) CreateUser

func (m *MockGraphQLClient) CreateUser(ctx context.Context, user platform.User) (*platform.User, error)

func (*MockGraphQLClient) DeleteAPIKey

func (m *MockGraphQLClient) DeleteAPIKey(ctx context.Context, id int) error

func (*MockGraphQLClient) DeleteUser

func (m *MockGraphQLClient) DeleteUser(ctx context.Context, id int) error

func (*MockGraphQLClient) GetAPIKeys

func (m *MockGraphQLClient) GetAPIKeys(ctx context.Context, params *APIKeyQueryParams) ([]*platform.APIKey, error)

func (*MockGraphQLClient) GetControlTypes

func (m *MockGraphQLClient) GetControlTypes(ctx context.Context) ([]*ControlType, error)

func (*MockGraphQLClient) GetMultiplayerServerConfigs

func (*MockGraphQLClient) GetMultiplayerServerVersion

func (m *MockGraphQLClient) GetMultiplayerServerVersion(ctx context.Context, versionID int) (*MultiplayerServerVersion, error)

func (*MockGraphQLClient) GetMultiplayerServerVersions

func (m *MockGraphQLClient) GetMultiplayerServerVersions(ctx context.Context, params *MultiplayerServerVersionQueryParams) ([]*MultiplayerServerVersion, error)

func (*MockGraphQLClient) GetPlatforms

func (m *MockGraphQLClient) GetPlatforms(ctx context.Context) ([]*Platform, error)

func (*MockGraphQLClient) GetSession

func (m *MockGraphQLClient) GetSession(ctx context.Context, id int) (*Session, error)

func (*MockGraphQLClient) GetToken

func (m *MockGraphQLClient) GetToken() string

func (*MockGraphQLClient) GetURL

func (m *MockGraphQLClient) GetURL() string

func (*MockGraphQLClient) GetUserByUsername

func (m *MockGraphQLClient) GetUserByUsername(ctx context.Context, username string) (*platform.User, error)

func (*MockGraphQLClient) IsAuthenticated

func (m *MockGraphQLClient) IsAuthenticated() bool

func (*MockGraphQLClient) Login

func (m *MockGraphQLClient) Login(username, password string) error

func (*MockGraphQLClient) SetAPIKey

func (m *MockGraphQLClient) SetAPIKey(apiKey string)

func (*MockGraphQLClient) SetToken

func (m *MockGraphQLClient) SetToken(token string)

func (*MockGraphQLClient) UpdateSession

func (m *MockGraphQLClient) UpdateSession(ctx context.Context, session Session) (*Session, error)

func (*MockGraphQLClient) UpdateUser

func (m *MockGraphQLClient) UpdateUser(ctx context.Context, user platform.User) (*platform.User, error)

type ModuleVersion

type ModuleVersion struct {
	ID              int                `json:"id,omitempty"`
	ModuleID        int                `json:"moduleId,omitempty"`
	Module          primary_api.Module `json:"module,omitempty"`
	Status          string             `json:"status,omitempty"`
	FileLink        string             `json:"fileLink,omitempty"`
	SemanticVersion string             `json:"version,omitempty"`
	Notes           string             `json:"notes,omitempty"`
	Package         string             `json:"package,omitempty"`
	ExternalID      string             `json:"externalId,omitempty"`
	LocalFilePath   string             `json:"-"`
	ControlIds      []int              `json:"controlIds,omitempty"`
	PlatformIds     []int              `json:"platformIds,omitempty"`
}

type MultiplayerServerConfigInput

type MultiplayerServerConfigInput struct {
	Input platform.MultiplayerServerConfig `graphql:"createMultiplayerConfig($input: MultiplayerServerConfigInput!)"`
}

type MultiplayerServerConfigParams

type MultiplayerServerConfigParams struct {
	ModuleID       int                         `json:"moduleId,omitempty"`
	OrgID          int                         `json:"orgId,omitempty"`
	ServerVersion  string                      `json:"serverVersion,omitempty"`
	Capacity       int                         `json:"capacity,omitempty"`
	ServerVersions []*MultiplayerServerVersion `json:"serverVersions,omitempty"`
}

type MultiplayerServerConfigQuery

type MultiplayerServerConfigQuery struct {
	MultiplayerServerConfigs []*MultiplayerServerConfigQueryParams `graphql:"multiplayerServerConfigs(params: $params)"`
}

type MultiplayerServerConfigQueryParams

type MultiplayerServerConfigQueryParams struct {
	ID       int  `json:"id" graphql:"id"`
	ModuleID int  `json:"moduleId" graphql:"moduleId"`
	Capacity int  `json:"capacity" graphql:"capacity"`
	Disabled bool `json:"disabled" graphql:"disabled"`
	Module   struct {
		ID   int    `json:"id" graphql:"id"`
		Name string `json:"name" graphql:"name"`
	}
	ServerVersions []*MultiplayerServerVersion `json:"serverVersions" graphql:"serverVersions"`
}

type MultiplayerServerVersion

type MultiplayerServerVersion struct {
	ID              int             `json:"id" graphql:"id"`
	ModuleID        int             `json:"moduleId" graphql:"moduleId"`
	Module          platform.Module `json:"module" graphql:"module"`
	Engine          string          `json:"engine" graphql:"engine"`
	Status          string          `json:"status" graphql:"status"`
	SemanticVersion string          `json:"semanticVersion" graphql:"semanticVersion"`
	ImageRegistry   string          `json:"imageRegistry" graphql:"imageRegistry"`
	FileLink        string          `json:"fileLink" graphql:"fileLink"`
	LocalFilePath   string          `json:"-" graphql:"-"`
}

type MultiplayerServerVersionInput

type MultiplayerServerVersionInput struct {
	Input platform.MultiplayerServerVersion `graphql:"createMultiplayerServer($input: MultiplayerServerVersionInput!)"`
}

type MultiplayerServerVersionParams

type MultiplayerServerVersionParams struct {
	ModuleID        int    `json:"moduleId,omitempty" graphql:"moduleId"`
	ImageRegistry   string `json:"imageRegistry,omitempty" graphql:"image"`
	SemanticVersion string `json:"semanticVersion,omitempty" graphql:"semanticVersion"`
	Status          string `json:"status,omitempty" graphql:"status"`
	Engine          string `json:"engine,omitempty" graphql:"engine"`
}

type MultiplayerServerVersionQuery

type MultiplayerServerVersionQuery struct {
	MultiplayerServerVersions []*platform.MultiplayerServerVersion `graphql:"multiplayerServerVersions(params: $params)"`
}

type MultiplayerServerVersionQueryParams

type MultiplayerServerVersionQueryParams struct {
	ModuleID        int    `json:"moduleId" graphql:"moduleId"`
	SemanticVersion string `json:"semanticVersion" graphql:"semanticVersion"`
}

type Platform

type Platform struct {
	ID        int    `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	ShortName string `json:"shortName,omitempty"`
}

type PlatformClient

type PlatformClient interface {
	abstract_client.AbstractClient

	ActiveUserID() int
	ActiveOrgID() int

	GetUserByUsername(ctx context.Context, username string) (*platform.User, error)
	CreateUser(ctx context.Context, user platform.User) (*platform.User, error)
	UpdateUser(ctx context.Context, user platform.User) (*platform.User, error)
	DeleteUser(ctx context.Context, id int) error

	GetAPIKeys(ctx context.Context, params *APIKeyQueryParams) ([]*platform.APIKey, error)
	CreateAPIKey(ctx context.Context, input platform.APIKey) (*platform.APIKey, error)
	DeleteAPIKey(ctx context.Context, id int) error

	GetPlatforms(ctx context.Context) ([]*Platform, error)
	GetControlTypes(ctx context.Context) ([]*ControlType, error)

	CreateModuleVersion(ctx context.Context, input ModuleVersion) (*ModuleVersion, error)

	GetSession(ctx context.Context, id int) (*Session, error)
	CreateSession(ctx context.Context, moduleID int, ipAddress, deviceId string) (*Session, error)
	UpdateSession(ctx context.Context, session Session) (*Session, error)
	CreateEvent(ctx context.Context, sessionID int, uuid string, eventType string, data string) (*platform.Event, error)

	GetMultiplayerServerConfigs(ctx context.Context, params *MultiplayerServerConfigParams) ([]*MultiplayerServerConfigQueryParams, error)
	GetMultiplayerServerVersions(ctx context.Context, params *MultiplayerServerVersionQueryParams) ([]*MultiplayerServerVersion, error)
	GetMultiplayerServerVersion(ctx context.Context, id int) (*MultiplayerServerVersion, error)
	CreateMultiplayerServerVersion(ctx context.Context, input MultiplayerServerVersion) (*MultiplayerServerVersion, error)
}

type Session

type Session struct {
	ID int `json:"id"`

	UUID        string  `json:"uuid"`
	IPAddress   string  `json:"ipAddress"`
	DeviceID    string  `json:"deviceId"`
	RawScore    float64 `json:"rawScore"`
	MaxScore    float64 `json:"maxScore"`
	ScaledScore float64 `json:"scaledScore"`
	Status      string  `json:"status"`
	Completed   bool    `json:"completed"`
	CompletedAt string  `json:"completedAt"`
	Duration    string  `json:"duration"`

	UserID   int              `json:"userId"`
	User     platform.User    `json:"user"`
	OrgID    int              `json:"orgId"`
	Org      platform.Org     `json:"org"`
	ModuleID int              `json:"moduleId"`
	Module   platform.Module  `json:"module"`
	Events   []platform.Event `json:"events"`

	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type SessionResponse

type SessionResponse struct {
	Session Session `json:"session"`
}

type UpdateSessionResponse

type UpdateSessionResponse struct {
	Session Session `json:"updateSession"`
}

type UpdateUserResponse

type UpdateUserResponse struct {
	User platform.User `json:"updateUser"`
}

Jump to

Keyboard shortcuts

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