api

package
v0.2.37 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Authentication & Authorization Errors (2000-2099)
	ErrorCodeUnauthorized         = 2000
	ErrorCodeInvalidToken         = 2001 // Used for expired tokens
	ErrorCodeInvalidUserCode      = 2002
	ErrorCodeTokenNotFound        = 2003
	ErrorCodeInvalidDeviceCode    = 2004
	ErrorCodeAuthorizationPending = 2005

	// Organization Errors (3000-3099)
	ErrorCodeOrganizationNotFound = 3000
	ErrorCodeNotOrgMember         = 3001
	ErrorCodeNoCreatePermission   = 3002

	// Application Errors (4000-4099)
	ErrorCodeApplicationNotFound = 4000
	ErrorCodeNoApplicationAccess = 4001
	ErrorCodeDuplicateAppName    = 4002

	// GitHub Integration Errors (5000-5099)
	ErrorCodeGitHubRepoNotFound          = 5000
	ErrorCodeGitHubRepoAccessDenied      = 5001
	ErrorCodeGitHubCollaboratorAddFailed = 5002
)

Error code constants from @repo/errors

Variables

This section is empty.

Functions

func ToCLIError added in v0.2.10

func ToCLIError(errResp *ErrorResponse) error

ToCLIError converts an APIError to a CLIError If a specific error code mapping exists, it returns that CLIError Otherwise, it creates a generic CLIError with the API error details

Types

type AddGithubCollaboratorsRequest added in v0.1.9

type AddGithubCollaboratorsRequest struct {
	ApplicationID  string `json:"applicationId"`
	GithubUsername string `json:"githubUsername"`
}

AddGithubCollaboratorsRequest represents the request body for POST /applications/add-gh-collaborators

type AddGithubCollaboratorsResponse added in v0.1.9

type AddGithubCollaboratorsResponse struct {
	Error   *AppErrorDetail `json:"error,omitempty"`
	Success bool            `json:"success,omitempty"`
	Message string          `json:"message,omitempty"`
}

AddGithubCollaboratorsResponse represents the response from POST /applications/add-gh-collaborators

type AppErrorDetail added in v0.1.11

type AppErrorDetail struct {
	InternalCode int    `json:"internal_code"`
	ErrorString  string `json:"error_string"`
	StatusCode   int    `json:"status_code"`
}

AppErrorDetail represents the error detail from the API (new format)

type ApplicationItem added in v0.1.6

type ApplicationItem struct {
	ID                   string `json:"id"`
	Name                 string `json:"name"`
	GithubRepositoryName string `json:"githubRepositoryName"`
	CloneURLSSH          string `json:"cloneUrlSsh"`
	CloneURLHTTPS        string `json:"cloneUrlHttps"`
}

ApplicationItem represents a single application in the list

type CheckVersionResponse added in v0.1.11

type CheckVersionResponse struct {
	Error         *AppErrorDetail `json:"error,omitempty"`
	ForceUpgrade  bool            `json:"forceUpgrade,omitempty"`
	CanUpgrade    bool            `json:"canUpgrade,omitempty"`
	LatestVersion *string         `json:"latestVersion,omitempty"`
}

CheckVersionResponse represents the response from GET /version/check

type Client

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

Client represents an API client for making authenticated requests

func NewClient

func NewClient(baseURL string) *Client

NewClient creates a new API client with the provided base URL and optional token

func (*Client) AddGithubCollaborators added in v0.1.9

func (c *Client) AddGithubCollaborators(applicationID, githubUsername string) (*AddGithubCollaboratorsResponse, error)

AddGithubCollaborators adds the user as a collaborator to the GitHub repository

func (*Client) CheckVersion added in v0.1.11

func (c *Client) CheckVersion(currentVersion string) (*CheckVersionResponse, error)

CheckVersion checks if the CLI version is up to date

func (*Client) CreateApplication

func (c *Client) CreateApplication(name, description, organizationID string) (*CreateApplicationResponse, error)

CreateApplication creates a new application with a GitHub repository

func (*Client) CreateApplicationVersion added in v0.1.2

func (c *Client) CreateApplicationVersion(applicationID string, appURL string) (*CreateApplicationVersionResponse, error)

CreateApplicationVersion creates a new version of an application

func (*Client) CreateDemoApplication added in v0.2.27

func (c *Client) CreateDemoApplication(organizationID string) (*CreateDemoApplicationResponse, error)

CreateDemoApplication creates a new demo application with a GitHub repository

func (*Client) GetApplicationByRepo

func (c *Client) GetApplicationByRepo(owner, repo string) (*GetApplicationByRepoResponse, error)

GetApplicationByRepo retrieves an application by its repository owner and name

func (*Client) GetApplicationEnv

func (c *Client) GetApplicationEnv(organizationID, applicationID string) (map[string]string, error)

GetApplicationEnv retrieves environment variables for an application

func (*Client) GetApplicationEnvironment added in v0.2.28

func (c *Client) GetApplicationEnvironment(applicationID string) (*GetApplicationEnvironmentResponse, error)

GetApplicationEnvironment retrieves the user's current environment choice for an application

func (c *Client) GetApplicationForLink(applicationID string) (*GetApplicationForLinkResponse, error)

GetApplicationForLink retrieves application info needed for the link command

func (*Client) GetApplicationResources added in v0.1.1

func (c *Client) GetApplicationResources(applicationID string) (*GetApplicationResourcesResponse, error)

GetApplicationResources retrieves resources for an application

func (*Client) GetDemoResource added in v0.2.27

func (c *Client) GetDemoResource(orgID string) (*GetDemoResourceResponse, error)

GetDemoResource retrieves the singular demo resource

func (*Client) GetOrganizationApplications added in v0.1.6

func (c *Client) GetOrganizationApplications(organizationID string) (*GetOrganizationApplicationsResponse, error)

GetOrganizationApplications retrieves all applications for an organization

func (*Client) GetOrganizations

func (c *Client) GetOrganizations() (*OrganizationsResponse, error)

GetOrganizations retrieves the list of organizations for the authenticated user

func (*Client) GetResources added in v0.1.18

func (c *Client) GetResources(organizationID string) (*GetResourcesResponse, error)

GetResources retrieves all resources for an organization

func (*Client) GetTemplates added in v0.2.0

func (c *Client) GetTemplates() (*GetTemplatesResponse, error)

GetTemplates retrieves all available templates

func (*Client) GetVersionStatus added in v0.1.13

func (c *Client) GetVersionStatus(applicationID, organizationID, versionID string) (*GetVersionStatusResponse, error)

GetVersionStatus retrieves the deployment status of an application version

func (*Client) ListApplicationEnvironments added in v0.2.28

func (c *Client) ListApplicationEnvironments(applicationID string) (*ListEnvironmentsResponse, error)

ListApplicationEnvironments retrieves all available environments for an application

func (*Client) Logout

func (c *Client) Logout() error

Logout revokes the current token

func (*Client) PollLogin

func (c *Client) PollLogin(deviceCode string) (*LoginPollResponse, error)

PollLogin polls the login endpoint to check if the user has authorized the device

func (*Client) PushTemplate added in v0.2.34

func (c *Client) PushTemplate(applicationID, templateID string) (*PushTemplateResponse, error)

PushTemplate pushes template files to the application repository using backend GitHub App credentials This bypasses the need for user's SSH access, allowing template push even when the user hasn't accepted the GitHub invitation yet.

func (*Client) SaveApplicationResources added in v0.1.18

func (c *Client) SaveApplicationResources(organizationID, applicationID string, resourceIDs []string) (*SaveApplicationResourcesResponse, error)

SaveApplicationResources saves the selected resources for an application

func (*Client) SetApplicationEnvironment added in v0.2.28

func (c *Client) SetApplicationEnvironment(applicationID, environmentID string) (*SetEnvironmentChoiceResponse, error)

SetApplicationEnvironment sets the user's environment choice for an application

func (*Client) SetApplicationTemplate added in v0.2.1

func (c *Client) SetApplicationTemplate(applicationID, templateID string) (*SetApplicationTemplateResponse, error)

SetApplicationTemplate associates a template with an application

func (*Client) StartLogin

func (c *Client) StartLogin() (*LoginStartResponse, error)

StartLogin initiates the device flow login process

func (*Client) VerifyToken

func (c *Client) VerifyToken() (*VerifyTokenResponse, error)

VerifyToken verifies the current token and returns user information

type CreateApplicationRequest

type CreateApplicationRequest struct {
	Name           string `json:"name"`
	Description    string `json:"description"`
	OrganizationID string `json:"organizationId"`
}

CreateApplicationRequest represents the request body for POST /applications

type CreateApplicationResponse

type CreateApplicationResponse struct {
	Error          *AppErrorDetail `json:"error,omitempty"`
	ApplicationID  string          `json:"applicationId,omitempty"`
	RepositoryName string          `json:"repositoryName,omitempty"`
	CloneURLSSH    string          `json:"cloneUrlSsh,omitempty"`
	CloneURLHTTPS  string          `json:"cloneUrlHttps,omitempty"`
}

CreateApplicationResponse represents the response from POST /applications

type CreateApplicationVersionRequest added in v0.1.2

type CreateApplicationVersionRequest struct {
	ApplicationID string `json:"applicationId"`
	AppURL        string `json:"appURL,omitempty"`
}

CreateApplicationVersionRequest represents the request body for POST /applications/versions

type CreateApplicationVersionResponse added in v0.1.2

type CreateApplicationVersionResponse struct {
	Error     *AppErrorDetail `json:"error,omitempty"`
	VersionID string          `json:"versionId,omitempty"`
}

CreateApplicationVersionResponse represents the response from POST /applications/versions

type CreateDemoApplicationRequest added in v0.2.27

type CreateDemoApplicationRequest struct {
	OrganizationID string `json:"organizationId"`
}

CreateDemoApplicationRequest represents the request body for POST /demo_application

type CreateDemoApplicationResponse added in v0.2.27

type CreateDemoApplicationResponse struct {
	Error          *AppErrorDetail `json:"error,omitempty"`
	ApplicationID  string          `json:"applicationId,omitempty"`
	RepositoryName string          `json:"repositoryName,omitempty"`
	CloneURLSSH    string          `json:"cloneUrlSsh,omitempty"`
	CloneURLHTTPS  string          `json:"cloneUrlHttps,omitempty"`
}

CreateDemoApplicationResponse represents the response from POST /demo_application

type EnvironmentItem added in v0.2.28

type EnvironmentItem struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	IsDefault bool   `json:"isDefault"`
}

EnvironmentItem represents a single environment

type ErrorResponse

type ErrorResponse struct {
	Error *AppErrorDetail `json:"error,omitempty"`
}

ErrorResponse represents an error response from the API (new format only)

type GetApplicationByRepoRequest

type GetApplicationByRepoRequest struct {
	Owner string `json:"owner"`
	Repo  string `json:"repo"`
}

GetApplicationByRepoRequest represents the request body for GET /application/from-repo

type GetApplicationByRepoResponse

type GetApplicationByRepoResponse struct {
	Error          *AppErrorDetail         `json:"error,omitempty"`
	ApplicationID  string                  `json:"applicationId,omitempty"`
	OrganizationID string                  `json:"organizationId,omitempty"`
	TemplateID     *string                 `json:"templateId,omitempty"`
	TemplateName   *constants.TemplateName `json:"templateName,omitempty"`
	URLSlug        *string                 `json:"urlSlug,omitempty"`
}

GetApplicationByRepoResponse represents the response from GET /application/from-repo

type GetApplicationEnvRequest

type GetApplicationEnvRequest struct {
	OrganizationID string `json:"organizationId"`
	ApplicationID  string `json:"applicationId"`
}

GetApplicationEnvRequest represents the request body for POST /application/env

type GetApplicationEnvResponse

type GetApplicationEnvResponse struct {
	Error   *AppErrorDetail   `json:"error,omitempty"`
	EnvVars map[string]string `json:"envVars,omitempty"`
}

GetApplicationEnvResponse represents the response from POST /application/env

type GetApplicationEnvironmentResponse added in v0.2.28

type GetApplicationEnvironmentResponse struct {
	Error           *AppErrorDetail `json:"error,omitempty"`
	EnvironmentID   *string         `json:"environmentId,omitempty"`
	EnvironmentName *string         `json:"environmentName,omitempty"`
}

GetApplicationEnvironmentResponse represents the response from GET /application/:applicationId/environment

type GetApplicationForLinkResponse added in v0.2.29

type GetApplicationForLinkResponse struct {
	Error            *AppErrorDetail `json:"error,omitempty"`
	ApplicationID    string          `json:"applicationId,omitempty"`
	OrganizationID   string          `json:"organizationId,omitempty"`
	OrganizationName string          `json:"organizationName,omitempty"`
	Name             string          `json:"name,omitempty"`
	CloneURLSSH      string          `json:"cloneUrlSsh,omitempty"`
	CloneURLHTTPS    string          `json:"cloneUrlHttps,omitempty"`
}

GetApplicationForLinkResponse represents the response from GET /application/:applicationId/link-info

type GetApplicationResourcesResponse added in v0.1.1

type GetApplicationResourcesResponse struct {
	Error     *AppErrorDetail `json:"error,omitempty"`
	Resources []ResourceItem  `json:"resources,omitempty"`
}

GetApplicationResourcesResponse represents the response from GET /applications/:applicationId/resources

type GetDemoResourceResponse added in v0.2.27

type GetDemoResourceResponse struct {
	Error    *AppErrorDetail `json:"error,omitempty"`
	Resource *ResourceItem   `json:"resource,omitempty"`
}

GetDemoResourceResponse represents the response from GET /demo_resource

type GetOrganizationApplicationsRequest added in v0.1.7

type GetOrganizationApplicationsRequest struct {
	OrganizationID string `json:"organizationId"`
}

GetOrganizationApplicationsRequest represents the request body for POST /organizations/applications

type GetOrganizationApplicationsResponse added in v0.1.6

type GetOrganizationApplicationsResponse struct {
	Error        *AppErrorDetail   `json:"error,omitempty"`
	Applications []ApplicationItem `json:"applications,omitempty"`
}

GetOrganizationApplicationsResponse represents the response from POST /organizations/applications

type GetResourcesRequest added in v0.1.18

type GetResourcesRequest struct {
	OrganizationID string `json:"organizationId"`
}

GetResourcesRequest represents the request body for POST /resources

type GetResourcesResponse added in v0.1.18

type GetResourcesResponse struct {
	Error     *AppErrorDetail `json:"error,omitempty"`
	Resources []ResourceItem  `json:"resources,omitempty"`
}

GetResourcesResponse represents the response from POST /resources

type GetTemplatesResponse added in v0.2.0

type GetTemplatesResponse struct {
	Error     *AppErrorDetail `json:"error,omitempty"`
	Templates []*TemplateItem `json:"templates,omitempty"`
}

GetTemplatesResponse represents the response from GET /templates

type GetVersionStatusRequest added in v0.1.13

type GetVersionStatusRequest struct {
	ApplicationID  string `json:"applicationId"`
	OrganizationID string `json:"organizationId"`
	VersionID      string `json:"versionId"`
}

GetVersionStatusRequest represents the request body for POST /applications/versions/status

type GetVersionStatusResponse added in v0.1.13

type GetVersionStatusResponse struct {
	Error           *AppErrorDetail `json:"error,omitempty"`
	Status          string          `json:"status,omitempty"`
	DeploymentError string          `json:"deploymentError,omitempty"`
	AppURL          string          `json:"app_url,omitempty"`
}

GetVersionStatusResponse represents the response from POST /applications/versions/status

type ListEnvironmentsResponse added in v0.2.28

type ListEnvironmentsResponse struct {
	Error        *AppErrorDetail   `json:"error,omitempty"`
	Environments []EnvironmentItem `json:"environments,omitempty"`
}

ListEnvironmentsResponse represents the response from GET /application/:applicationId/environments

type LoginPollRequest

type LoginPollRequest struct {
	DeviceCode string `json:"device_code"`
}

LoginPollRequest represents the request body for POST /login/poll

type LoginPollResponse

type LoginPollResponse struct {
	Error       *AppErrorDetail `json:"error,omitempty"`
	AccessToken string          `json:"access_token,omitempty"`
	TokenType   string          `json:"token_type,omitempty"`
	ExpiresIn   int             `json:"expires_in,omitempty"`
}

LoginPollResponse represents the response from POST /login/poll

type LoginStartResponse

type LoginStartResponse struct {
	Error           *AppErrorDetail `json:"error,omitempty"`
	DeviceCode      string          `json:"device_code,omitempty"`
	UserCode        string          `json:"user_code,omitempty"`
	VerificationURI string          `json:"verification_uri,omitempty"`
	ExpiresIn       int             `json:"expires_in,omitempty"`
	Interval        int             `json:"interval,omitempty"`
}

LoginStartResponse represents the response from POST /login/start

type Organization

type Organization struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Organization represents an organization from the API

type OrganizationsResponse

type OrganizationsResponse struct {
	Error         *AppErrorDetail `json:"error,omitempty"`
	Organizations []Organization  `json:"organizations,omitempty"`
}

OrganizationsResponse represents the response from GET /organizations

type PushTemplateRequest added in v0.2.34

type PushTemplateRequest struct {
	ApplicationID string `json:"applicationId"`
	TemplateID    string `json:"templateId"`
}

PushTemplateRequest represents the request body for POST /applications/push-template

type PushTemplateResponse added in v0.2.34

type PushTemplateResponse struct {
	Error      *AppErrorDetail `json:"error,omitempty"`
	Success    bool            `json:"success"`
	CommitSha  string          `json:"commitSha,omitempty"`
	FilesCount int             `json:"filesCount,omitempty"`
	ErrorMsg   string          `json:"errorMessage,omitempty"`
}

PushTemplateResponse represents the response from POST /applications/push-template

type ResourceItem added in v0.1.1

type ResourceItem struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
}

ResourceItem represents a single resource

type SaveApplicationResourcesRequest added in v0.1.18

type SaveApplicationResourcesRequest struct {
	OrganizationID string   `json:"organizationId"`
	ApplicationID  string   `json:"applicationId"`
	ResourceIDs    []string `json:"resourceIds"`
}

SaveApplicationResourcesRequest represents the request body for POST /application-resources

type SaveApplicationResourcesResponse added in v0.1.18

type SaveApplicationResourcesResponse struct {
	Error   *AppErrorDetail `json:"error,omitempty"`
	Success bool            `json:"success,omitempty"`
}

SaveApplicationResourcesResponse represents the response from POST /application-resources

type SetApplicationTemplateRequest added in v0.2.1

type SetApplicationTemplateRequest struct {
	ApplicationID string `json:"applicationId"`
	TemplateID    string `json:"templateId"`
}

SetApplicationTemplateRequest represents the request body for POST /applications/template

type SetApplicationTemplateResponse added in v0.2.1

type SetApplicationTemplateResponse struct {
	Error   *AppErrorDetail `json:"error,omitempty"`
	Success bool            `json:"success,omitempty"`
	Message string          `json:"message,omitempty"`
}

SetApplicationTemplateResponse represents the response from POST /applications/template

type SetEnvironmentChoiceRequest added in v0.2.28

type SetEnvironmentChoiceRequest struct {
	EnvironmentID string `json:"environmentId"`
}

SetEnvironmentChoiceRequest represents the request body for POST /application/:applicationId/environment

type SetEnvironmentChoiceResponse added in v0.2.28

type SetEnvironmentChoiceResponse struct {
	Error           *AppErrorDetail `json:"error,omitempty"`
	EnvironmentID   string          `json:"environmentId,omitempty"`
	EnvironmentName string          `json:"environmentName,omitempty"`
}

SetEnvironmentChoiceResponse represents the response from POST /application/:applicationId/environment

type TemplateItem added in v0.2.0

type TemplateItem struct {
	ID          string                 `json:"id"`
	Name        constants.TemplateName `json:"name"`
	TemplateURL string                 `json:"templateUrl"`
}

TemplateItem represents a single template

type VerifyTokenResponse

type VerifyTokenResponse struct {
	Error  *AppErrorDetail `json:"error,omitempty"`
	Active bool            `json:"active,omitempty"`
	UserID string          `json:"user_id,omitempty"`
	Email  string          `json:"email,omitempty"`
	Exp    int64           `json:"exp,omitempty"`
}

VerifyTokenResponse represents the response from GET /verify

type VersionCheckRequest added in v0.1.11

type VersionCheckRequest struct {
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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