Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) AcceptOrganizationInvitation(ctx context.Context, orgID string) error
- func (c *Client) CheckProjectSlugIsTaken(ctx context.Context, orgID, projID, slug string) error
- func (c *Client) CreateOrganization(ctx context.Context, name, slug string) (models.Organization, error)
- func (c *Client) CreateProject(ctx context.Context, orgID string, project models.Project) (models.Project, error)
- func (c *Client) DeleteProject(ctx context.Context, orgID, projID string) error
- func (c *Client) DeployProject(ctx context.Context, orgID, projID, deployType string) error
- func (c *Client) GetDeploymentHealthStatus(ctx context.Context, projID string) (map[string]models.DeploymentHealthCheckResult, error)
- func (c *Client) GetDeploymentStatus(ctx context.Context, projID string) ([]byte, error)
- func (c *Client) GetHealthStatus(ctx context.Context, projID string) ([]byte, error)
- func (c *Client) GetListRegions(ctx context.Context, orgID, projID string) ([]string, error)
- func (c *Client) GetLoginLink(ctx context.Context) (LoginLinkResponse, error)
- func (c *Client) GetLoginToken(ctx context.Context, callbackURL string) (models.LoginToken, error)
- func (c *Client) GetOrganizationByID(ctx context.Context, id string) (models.Organization, error)
- func (c *Client) GetOrganizationMembers(ctx context.Context, orgID string) ([]models.OrganizationMember, error)
- func (c *Client) GetOrganizations(ctx context.Context) ([]models.Organization, error)
- func (c *Client) GetOrganizationsInvitedTo(ctx context.Context) ([]models.Organization, error)
- func (c *Client) GetProjectByID(ctx context.Context, orgID, projID string) (models.Project, error)
- func (c *Client) GetProjects(ctx context.Context, orgID string) ([]models.Project, error)
- func (c *Client) GetRPCBaseURL() string
- func (c *Client) GetTemporaryCredential(ctx context.Context, orgID, projID string) (models.TemporaryCredential, error)
- func (c *Client) GetUser(ctx context.Context) (models.User, error)
- func (c *Client) InviteUserToOrganization(ctx context.Context, orgID, userEmail, role string) error
- func (c *Client) LookupProjectFromRepo(ctx context.Context, repoURL, repoPath string) (models.Project, error)
- func (c *Client) PreviewDeployment(ctx context.Context, orgID, projID, deployType string) (models.DeploymentPreview, error)
- func (c *Client) SetAuthToken(token string)
- func (c *Client) UpdateProject(ctx context.Context, orgID, projID string, project models.Project) (models.Project, error)
- func (c *Client) UpdateUser(ctx context.Context, name, email string) error
- func (c *Client) UpdateUserRoleInOrganization(ctx context.Context, orgID, userEmail, role string) error
- type ClientInterface
- type HTTPClientInterface
- type LoginLinkResponse
- type MockClient
- func (m *MockClient) AcceptOrganizationInvitation(ctx context.Context, orgID string) error
- func (m *MockClient) CheckProjectSlugIsTaken(ctx context.Context, orgID, projID, slug string) error
- func (m *MockClient) CreateOrganization(ctx context.Context, name, slug string) (models.Organization, error)
- func (m *MockClient) CreateProject(ctx context.Context, orgID string, project models.Project) (models.Project, error)
- func (m *MockClient) DeleteProject(ctx context.Context, orgID, projID string) error
- func (m *MockClient) DeployProject(ctx context.Context, orgID, projID, deployType string) error
- func (m *MockClient) GetDeploymentHealthStatus(ctx context.Context, projID string) (map[string]models.DeploymentHealthCheckResult, error)
- func (m *MockClient) GetDeploymentStatus(ctx context.Context, projID string) ([]byte, error)
- func (m *MockClient) GetHealthStatus(ctx context.Context, projID string) ([]byte, error)
- func (m *MockClient) GetListRegions(ctx context.Context, orgID, projID string) ([]string, error)
- func (m *MockClient) GetLoginLink(ctx context.Context) (LoginLinkResponse, error)
- func (m *MockClient) GetLoginToken(ctx context.Context, callbackURL string) (models.LoginToken, error)
- func (m *MockClient) GetOrganizationByID(ctx context.Context, id string) (models.Organization, error)
- func (m *MockClient) GetOrganizationMembers(ctx context.Context, orgID string) ([]models.OrganizationMember, error)
- func (m *MockClient) GetOrganizations(ctx context.Context) ([]models.Organization, error)
- func (m *MockClient) GetOrganizationsInvitedTo(ctx context.Context) ([]models.Organization, error)
- func (m *MockClient) GetProjectByID(ctx context.Context, orgID, projID string) (models.Project, error)
- func (m *MockClient) GetProjects(ctx context.Context, orgID string) ([]models.Project, error)
- func (m *MockClient) GetRPCBaseURL() string
- func (m *MockClient) GetTemporaryCredential(ctx context.Context, orgID, projID string) (models.TemporaryCredential, error)
- func (m *MockClient) GetUser(ctx context.Context) (models.User, error)
- func (m *MockClient) InviteUserToOrganization(ctx context.Context, orgID, userEmail, role string) error
- func (m *MockClient) LookupProjectFromRepo(ctx context.Context, repoURL, repoPath string) (models.Project, error)
- func (m *MockClient) PreviewDeployment(ctx context.Context, orgID, projID, deployType string) (models.DeploymentPreview, error)
- func (m *MockClient) SetAuthToken(token string)
- func (m *MockClient) UpdateProject(ctx context.Context, orgID, projID string, project models.Project) (models.Project, error)
- func (m *MockClient) UpdateUser(ctx context.Context, name, email string) error
- func (m *MockClient) UpdateUserRoleInOrganization(ctx context.Context, orgID, userEmail, role string) error
- type MockHTTPClient
- type RequestConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoOrganizationID = eris.New("organization ID is required") ErrNoProjectID = eris.New("project ID is required") ErrNoProjectSlug = eris.New("project slug is required") )
var ( ErrNoUserEmail = eris.New("user email is required") ErrNoUserName = eris.New("user name is required") )
var ErrOrganizationSlugAlreadyExists = eris.New("organization slug already exists")
ErrOrganizationSlugAlreadyExists is passed from forge to world-cli, Must always match.
var ErrProjectSlugAlreadyExists = eris.New("project slug already exists")
ErrProjectSlugAlreadyExists is passed from forge to world-cli, Must always match.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
BaseURL string
ArgusIDBaseURL string
// TODO: Remove this once we have a proper RPC client
RPCURL string
Token string
HTTPClient HTTPClientInterface
}
Client implements HTTP API client with retry logic and authentication.
func (*Client) AcceptOrganizationInvitation ¶
AcceptOrganizationInvitation accepts an invitation to join an organization.
func (*Client) CheckProjectSlugIsTaken ¶
CheckProjectSlugIsTaken checks if a project slug is already taken.
func (*Client) CreateOrganization ¶
func (c *Client) CreateOrganization(ctx context.Context, name, slug string) (models.Organization, error)
CreateOrganization creates a new organization.
func (*Client) CreateProject ¶
func (c *Client) CreateProject(ctx context.Context, orgID string, project models.Project) (models.Project, error)
CreateProject creates a new project.
func (*Client) DeleteProject ¶
DeleteProject deletes a project.
func (*Client) DeployProject ¶
DeployProject deploy, resets, destroys, or promotes a project.
func (*Client) GetDeploymentHealthStatus ¶
func (c *Client) GetDeploymentHealthStatus( ctx context.Context, projID string, ) (map[string]models.DeploymentHealthCheckResult, error)
GetDeploymentHealthStatus retrieves deployment health status.
func (*Client) GetDeploymentStatus ¶
GetDeploymentStatus retrieves deployment status.
func (*Client) GetHealthStatus ¶
GetHealthStatus retrieves health status.
func (*Client) GetListRegions ¶
GetListRegions retrieves available regions for a project.
func (*Client) GetLoginLink ¶
func (c *Client) GetLoginLink(ctx context.Context) (LoginLinkResponse, error)
GetLoginLink gets the login link from ArgusID service.
func (*Client) GetLoginToken ¶
GetLoginToken polls the callback URL for login token.
func (*Client) GetOrganizationByID ¶
GetOrganizationByID retrieves a specific organization by ID.
func (*Client) GetOrganizationMembers ¶
func (*Client) GetOrganizations ¶
GetOrganizations retrieves the list of organizations the user belongs to.
func (*Client) GetOrganizationsInvitedTo ¶
GetOrganizationsInvitedTo retrieves organizations the user has been invited to.
func (*Client) GetProjectByID ¶
GetProjectByID retrieves a specific project by ID.
func (*Client) GetProjects ¶
GetProjects retrieves all projects for a given organization.
func (*Client) GetRPCBaseURL ¶
TODO: Remove this once we have a proper RPC client
func (*Client) GetTemporaryCredential ¶
func (*Client) InviteUserToOrganization ¶
InviteUserToOrganization invites a user to an organization.
func (*Client) LookupProjectFromRepo ¶
func (c *Client) LookupProjectFromRepo(ctx context.Context, repoURL, repoPath string) (models.Project, error)
LookupProjectFromRepo looks up a project based on repository URL and path.
func (*Client) PreviewDeployment ¶
func (c *Client) PreviewDeployment( ctx context.Context, orgID, projID, deployType string, ) (models.DeploymentPreview, error)
PreviewDeployment previews a deployment.
func (*Client) SetAuthToken ¶
SetAuthToken updates the client's authentication credentials.
func (*Client) UpdateProject ¶
func (c *Client) UpdateProject( ctx context.Context, orgID, projID string, project models.Project, ) (models.Project, error)
UpdateProject updates a project.
func (*Client) UpdateUser ¶
UpdateUser updates the current user information.
type ClientInterface ¶
type ClientInterface interface {
// GetLoginLink initiates the login flow by getting the login URLs from ArgusID
GetLoginLink(ctx context.Context) (LoginLinkResponse, error)
// GetLoginToken polls the callback URL to get the login token status
GetLoginToken(ctx context.Context, callbackURL string) (models.LoginToken, error)
// SetAuthToken updates the client's authentication token for API requests
SetAuthToken(token string)
// GetUser retrieves the current authenticated user's information
GetUser(ctx context.Context) (models.User, error)
// UpdateUser updates the current user's profile information
UpdateUser(ctx context.Context, name, email string) error
// InviteUserToOrganization invites a user to join an organization with a specific role
InviteUserToOrganization(ctx context.Context, orgID, userEmail, role string) error
// UpdateUserRoleInOrganization updates a user's role within an organization
UpdateUserRoleInOrganization(ctx context.Context, orgID, userEmail, role string) error
// GetOrganizationsInvitedTo retrieves organizations the user has been invited to
GetOrganizationsInvitedTo(ctx context.Context) ([]models.Organization, error)
// AcceptOrganizationInvitation accepts an invitation to join an organization
AcceptOrganizationInvitation(ctx context.Context, orgID string) error
// GetOrganizations retrieves all organizations the user belongs to
GetOrganizations(ctx context.Context) ([]models.Organization, error)
// GetOrganizationByID retrieves a specific organization by its ID
GetOrganizationByID(ctx context.Context, id string) (models.Organization, error)
// CreateOrganization creates a new organization
CreateOrganization(ctx context.Context, name, slug string) (models.Organization, error)
// GetOrganizationMembers retrieves all members of an organization
GetOrganizationMembers(ctx context.Context, orgID string) ([]models.OrganizationMember, error)
// GetProjects retrieves all projects within an organization
GetProjects(ctx context.Context, orgID string) ([]models.Project, error)
// GetProjectByID retrieves a specific project by its ID
GetProjectByID(ctx context.Context, projID, orgID string) (models.Project, error)
// LookupProjectFromRepo looks up a project based on repository URL and path
LookupProjectFromRepo(ctx context.Context, repoURL, repoPath string) (models.Project, error)
// CreateProject creates a new project within an organization
CreateProject(ctx context.Context, orgID string, project models.Project) (models.Project, error)
// UpdateProject updates an existing project's configuration
UpdateProject(ctx context.Context, orgID, projID string, project models.Project) (models.Project, error)
// DeleteProject removes a project from an organization
DeleteProject(ctx context.Context, orgID, projID string) error
// CheckProjectSlugIsTaken verifies if a project slug is available
CheckProjectSlugIsTaken(ctx context.Context, orgID, projID, slug string) error
// GetListRegions retrieves available deployment regions for a project
GetListRegions(ctx context.Context, orgID, projID string) ([]string, error)
// PreviewDeployment shows what would happen during a deployment without executing it
PreviewDeployment(ctx context.Context, orgID, projID, deployType string) (models.DeploymentPreview, error)
// DeployProject deploy, resets, destroys, or promotes a project
DeployProject(ctx context.Context, orgID, projID, deployType string) error
// GetTemporaryCredential retrieves temporary credentials for a project
GetTemporaryCredential(ctx context.Context, orgID, projID string) (models.TemporaryCredential, error)
// GetDeploymentStatus retrieves the current deployment status for a project
GetDeploymentStatus(ctx context.Context, projID string) ([]byte, error)
// GetHealthStatus retrieves the health status of deployed services
GetHealthStatus(ctx context.Context, projID string) ([]byte, error)
// GetDeploymentHealthStatus retrieves detailed health check results for deployments
GetDeploymentHealthStatus(ctx context.Context, projID string) (map[string]models.DeploymentHealthCheckResult, error)
// GetRPCBaseURL returns the RPC service base URL
// TODO: Remove this once we have a proper RPC client
GetRPCBaseURL() string
}
ClientInterface defines the contract for making API calls. This interface focuses on business operations rather than low-level HTTP details.
func NewClient ¶
func NewClient(baseURL, rpcURL, argusIDBaseURL string) ClientInterface
NewClient creates a new API client with the given base URL.
type HTTPClientInterface ¶
HTTPClientInterface allows for mocking the underlying HTTP client.
type LoginLinkResponse ¶
type LoginLinkResponse struct {
CallBackURL string `json:"callbackUrl"`
ClientURL string `json:"clientUrl"`
}
Login link response structure.
type MockClient ¶
MockClient is a mock implementation of ClientInterface.
func (*MockClient) AcceptOrganizationInvitation ¶
func (m *MockClient) AcceptOrganizationInvitation(ctx context.Context, orgID string) error
AcceptOrganizationInvitation mocks accepting an organization invitation.
func (*MockClient) CheckProjectSlugIsTaken ¶
func (m *MockClient) CheckProjectSlugIsTaken(ctx context.Context, orgID, projID, slug string) error
CheckProjectSlugIsTaken mocks checking if a project slug is taken.
func (*MockClient) CreateOrganization ¶
func (m *MockClient) CreateOrganization( ctx context.Context, name, slug string, ) (models.Organization, error)
CreateOrganization mocks creating an organization.
func (*MockClient) CreateProject ¶
func (m *MockClient) CreateProject(ctx context.Context, orgID string, project models.Project) (models.Project, error)
CreateProject mocks creating a project.
func (*MockClient) DeleteProject ¶
func (m *MockClient) DeleteProject(ctx context.Context, orgID, projID string) error
DeleteProject mocks deleting a project.
func (*MockClient) DeployProject ¶
func (m *MockClient) DeployProject( ctx context.Context, orgID, projID, deployType string, ) error
DeployProject mocks deploying a project.
func (*MockClient) GetDeploymentHealthStatus ¶
func (m *MockClient) GetDeploymentHealthStatus( ctx context.Context, projID string, ) (map[string]models.DeploymentHealthCheckResult, error)
GetDeploymentHealthStatus mocks getting deployment health status.
func (*MockClient) GetDeploymentStatus ¶
GetDeploymentStatus mocks getting deployment status.
func (*MockClient) GetHealthStatus ¶
GetHealthStatus mocks getting health status.
func (*MockClient) GetListRegions ¶
GetListRegions mocks getting list of regions.
func (*MockClient) GetLoginLink ¶
func (m *MockClient) GetLoginLink(ctx context.Context) (LoginLinkResponse, error)
GetLoginLink mocks getting the login link.
func (*MockClient) GetLoginToken ¶
func (m *MockClient) GetLoginToken(ctx context.Context, callbackURL string) (models.LoginToken, error)
GetLoginToken mocks getting the login token.
func (*MockClient) GetOrganizationByID ¶
func (m *MockClient) GetOrganizationByID(ctx context.Context, id string) (models.Organization, error)
GetOrganizationByID mocks getting an organization by ID.
func (*MockClient) GetOrganizationMembers ¶
func (m *MockClient) GetOrganizationMembers(ctx context.Context, orgID string) ([]models.OrganizationMember, error)
GetOrganizationMembers mocks getting organization members.
func (*MockClient) GetOrganizations ¶
func (m *MockClient) GetOrganizations(ctx context.Context) ([]models.Organization, error)
GetOrganizations mocks getting organizations.
func (*MockClient) GetOrganizationsInvitedTo ¶
func (m *MockClient) GetOrganizationsInvitedTo(ctx context.Context) ([]models.Organization, error)
GetOrganizationsInvitedTo mocks getting organization invitations.
func (*MockClient) GetProjectByID ¶
func (m *MockClient) GetProjectByID(ctx context.Context, orgID, projID string) (models.Project, error)
GetProjectByID mocks getting a project by ID.
func (*MockClient) GetProjects ¶
GetProjects mocks getting projects for an organization.
func (*MockClient) GetRPCBaseURL ¶
func (m *MockClient) GetRPCBaseURL() string
TODO: Remove this once we have a proper RPC client GetRPCBaseURL mocks getting RPC base URL.
func (*MockClient) GetTemporaryCredential ¶
func (m *MockClient) GetTemporaryCredential( ctx context.Context, orgID, projID string, ) (models.TemporaryCredential, error)
func (*MockClient) InviteUserToOrganization ¶
func (m *MockClient) InviteUserToOrganization(ctx context.Context, orgID, userEmail, role string) error
InviteUserToOrganization mocks inviting a user to an organization.
func (*MockClient) LookupProjectFromRepo ¶
func (m *MockClient) LookupProjectFromRepo(ctx context.Context, repoURL, repoPath string) (models.Project, error)
LookupProjectFromRepo mocks looking up a project from repository information.
func (*MockClient) PreviewDeployment ¶
func (m *MockClient) PreviewDeployment( ctx context.Context, orgID, projID, deployType string, ) (models.DeploymentPreview, error)
PreviewDeployment mocks previewing a deployment.
func (*MockClient) SetAuthToken ¶
func (m *MockClient) SetAuthToken(token string)
SetAuthToken mocks setting auth token.
func (*MockClient) UpdateProject ¶
func (m *MockClient) UpdateProject( ctx context.Context, orgID, projID string, project models.Project, ) (models.Project, error)
UpdateProject mocks updating a project.
func (*MockClient) UpdateUser ¶
func (m *MockClient) UpdateUser(ctx context.Context, name, email string) error
UpdateUser mocks updating user information.
func (*MockClient) UpdateUserRoleInOrganization ¶
func (m *MockClient) UpdateUserRoleInOrganization(ctx context.Context, orgID, userEmail, role string) error
UpdateUserRoleInOrganization mocks updating user role in organization.
type MockHTTPClient ¶
MockHTTPClient is a mock implementation of HTTPClientInterface for testing.
type RequestConfig ¶
type RequestConfig struct {
MaxRetries int
BaseDelay time.Duration
Timeout time.Duration
ContentType string
CustomHeaders map[string]string
}
RequestConfig holds configuration for individual requests.
func DefaultRequestConfig ¶
func DefaultRequestConfig() RequestConfig
DefaultRequestConfig returns sensible defaults.