api

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHttpClient added in v0.9.1

func NewHttpClient() *http.Client

NewHttpClient creates a http client to use for API calls. The default http.Client only copies a few "safe" headers This custom CheckRedirect ensures all headers are transferred, including authorization headers which are necessary for DC redirects

Types

type Client

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

func NewClient

func NewClient(ctx context.Context, opts Configuration) *Client

func NewClientWithCustomDeps

func NewClientWithCustomDeps(ctx context.Context, opts Configuration, api *openapi_client.APIClient, time Time) *Client

For use in tests

func (*Client) CreateDomain

func (c *Client) CreateDomain(teamId int, domainName string) (*Domain, error)

func (*Client) CreateTeam

func (c *Client) CreateTeam(name string, dc int) (*Team, error)

func (*Client) CreateWorkspace

func (c *Client) CreateWorkspace(args CreateWorkspaceArgs) (*Workspace, error)

func (*Client) DeleteDomain

func (c *Client) DeleteDomain(teamId int, domainName string) error

func (*Client) DeleteTeam

func (c *Client) DeleteTeam(teamId int) error

func (*Client) DeleteWorkspace added in v0.6.0

func (c *Client) DeleteWorkspace(workspaceId int) error

func (Client) DeployWorkspace

func (client Client) DeployWorkspace(args DeployWorkspaceArgs) (*Workspace, error)

Deploys a workspace with the given configuration.

Returns [TimedOut] error if the timeout is reached

func (*Client) ExecCommand added in v0.3.0

func (c *Client) ExecCommand(workspaceId int, command string, workdir string, env map[string]string) (string, string, error)

func (*Client) GetDomain

func (c *Client) GetDomain(teamId int, domainName string) (*Domain, error)

func (*Client) GetPipelineState added in v0.6.0

func (c *Client) GetPipelineState(wsId int, stage string) ([]PipelineStatus, error)

func (*Client) GetTeam

func (c *Client) GetTeam(teamId int) (*Team, error)

func (*Client) GetWorkspace added in v0.3.0

func (c *Client) GetWorkspace(workspaceId int) (Workspace, error)

func (Client) GitPull added in v0.10.0

func (c Client) GitPull(workspaceId int, remote string, branch string) error

func (*Client) ListDataCenters

func (c *Client) ListDataCenters() ([]DataCenter, error)

func (*Client) ListDomains

func (c *Client) ListDomains(teamId int) ([]Domain, error)

func (*Client) ListTeams

func (c *Client) ListTeams() ([]Team, error)

func (*Client) ListWorkspacePlans

func (c *Client) ListWorkspacePlans() ([]WorkspacePlan, error)

func (*Client) ListWorkspaces

func (c *Client) ListWorkspaces(teamId int) ([]Workspace, error)

func (*Client) PlanByName

func (client *Client) PlanByName(name string) (WorkspacePlan, error)

Fetches the workspace plan for a given name.

Returns [NotFound] if no plan with the given Id could be found

func (*Client) SetEnvVarOnWorkspace

func (c *Client) SetEnvVarOnWorkspace(workspaceId int, envVars map[string]string) error

func (*Client) StartPipelineStage added in v0.6.0

func (c *Client) StartPipelineStage(wsId int, profile string, stage string) error

func (*Client) TeamIdByName

func (client *Client) TeamIdByName(name string) (Team, error)

Fetches the team for a given team name. If the name is ambigous an error is thrown.

Returns [NotFound] if no plan with the given Id could be found Returns [Duplicated] if no plan with the given Id could be found

func (*Client) UpdateDomain

func (c *Client) UpdateDomain(
	teamId int, domainName string, args UpdateDomainArgs,
) (*Domain, error)

func (*Client) UpdateWorkspaceConnections

func (c *Client) UpdateWorkspaceConnections(
	teamId int, domainName string, connections PathToWorkspaces,
) (*Domain, error)

func (*Client) VerifyDomain

func (c *Client) VerifyDomain(
	teamId int, domainName string,
) (*DomainVerificationStatus, error)

func (*Client) WaitForWorkspaceRunning

func (client *Client) WaitForWorkspaceRunning(workspace *Workspace, timeout time.Duration) error

Waits for a given workspace to be running.

Returns [TimedOut] error if the workspace does not become running in time.

func (*Client) WorkspaceStatus

func (c *Client) WorkspaceStatus(workspaceId int) (*WorkspaceStatus, error)

type Configuration

type Configuration struct {
	// Url of the codesphere environment
	// Defaults to https://codesphere.com
	BaseUrl *url.URL
	// Codesphere api token
	Token string
}

func (Configuration) GetApiUrl

func (c Configuration) GetApiUrl() *url.URL

type DeployWorkspaceArgs

type DeployWorkspaceArgs struct {
	TeamId        int
	PlanId        int
	Name          string
	EnvVars       map[string]string
	VpnConfigName *string //must be nil to use default

	IsPrivateRepo bool
	GitUrl        *string //must be nil to use default
	Branch        *string //must be nil to use default

	Timeout time.Duration
}

type MockTime

type MockTime struct {
	mock.Mock
}

MockTime is an autogenerated mock type for the Time type

func NewMockTime

func NewMockTime(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockTime

NewMockTime creates a new instance of MockTime. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockTime) EXPECT

func (_m *MockTime) EXPECT() *MockTime_Expecter

func (*MockTime) Now

func (_mock *MockTime) Now() time.Time

Now provides a mock function for the type MockTime

func (*MockTime) Sleep

func (_mock *MockTime) Sleep(duration time.Duration)

Sleep provides a mock function for the type MockTime

type MockTime_Expecter

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

func (*MockTime_Expecter) Now

Now is a helper method to define mock.On call

func (*MockTime_Expecter) Sleep

func (_e *MockTime_Expecter) Sleep(duration interface{}) *MockTime_Sleep_Call

Sleep is a helper method to define mock.On call

  • duration

type MockTime_Now_Call

type MockTime_Now_Call struct {
	*mock.Call
}

MockTime_Now_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Now'

func (*MockTime_Now_Call) Return

func (_c *MockTime_Now_Call) Return(time1 time.Time) *MockTime_Now_Call

func (*MockTime_Now_Call) Run

func (_c *MockTime_Now_Call) Run(run func()) *MockTime_Now_Call

func (*MockTime_Now_Call) RunAndReturn

func (_c *MockTime_Now_Call) RunAndReturn(run func() time.Time) *MockTime_Now_Call

type MockTime_Sleep_Call

type MockTime_Sleep_Call struct {
	*mock.Call
}

MockTime_Sleep_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Sleep'

func (*MockTime_Sleep_Call) Return

func (*MockTime_Sleep_Call) Run

func (_c *MockTime_Sleep_Call) Run(run func(duration time.Duration)) *MockTime_Sleep_Call

func (*MockTime_Sleep_Call) RunAndReturn

func (_c *MockTime_Sleep_Call) RunAndReturn(run func(duration time.Duration)) *MockTime_Sleep_Call

type PathToWorkspaces

type PathToWorkspaces = map[string][]*Workspace

type PipelineStatus added in v0.6.0

type RealTime

type RealTime struct{}

func (*RealTime) Now

func (r *RealTime) Now() time.Time

func (*RealTime) Sleep

func (r *RealTime) Sleep(t time.Duration)

type Team

func ConvertToTeam

func ConvertToTeam(t *openapi.TeamsGetTeam200Response) *Team

TODO: remove the conversion once the api is fixed

type Time

type Time interface {
	Sleep(time.Duration)
	Now() time.Time
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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