Documentation
¶
Index ¶
- Constants
- func FindSSHPublicKey() (string, error)
- func GetAPIKey() (string, error)
- func GetClientOptions() ([]option.RequestOption, error)
- func GetConfigPath() (string, error)
- func GetGitEmail() (string, error)
- func GetOrCreateSSHKey(vmID string, client *vers.Client, apiCtx context.Context) (string, error)
- func GetVMDomain() string
- func GetVersUrl() (*url.URL, error)
- func HasAPIKey() (bool, error)
- func PromptForLogin() error
- func SaveAPIKey(apiKey string) error
- func SaveConfig(config *Config) error
- type Config
- type SSHKeyResponse
- type ShellAuthCreateKeyRequest
- type ShellAuthCreateKeyResponse
- type ShellAuthErrorResponse
- type ShellAuthInitRequest
- type ShellAuthInitResponse
- type ShellAuthOrg
- type ShellAuthVerifyRequest
- type ShellAuthVerifyResponse
Constants ¶
const DEFAULT_VERS_URL_STR = "https://api.vers.sh"
Variables ¶
This section is empty.
Functions ¶
func FindSSHPublicKey ¶ added in v0.7.2
FindSSHPublicKey finds the user's SSH public key, checking common locations. Returns the key contents (not the path).
func GetClientOptions ¶
func GetClientOptions() ([]option.RequestOption, error)
GetClientOptions returns the options for the SDK client
func GetConfigPath ¶
GetConfigPath returns the path to the .versrc file in the user's home directory
func GetGitEmail ¶ added in v0.7.2
GetGitEmail returns the user's git config email.
func GetOrCreateSSHKey ¶
GetOrCreateSSHKey retrieves the path to an SSH key, fetching and saving it if necessary.
func GetVMDomain ¶ added in v0.6.0
func GetVMDomain() string
GetVMDomain derives the VM SSH domain from the configured VERS_URL. For example:
- "https://api.vers.sh" -> "vm.vers.sh"
- "https://api.staging.vers.sh" -> "vm.staging.vers.sh"
func GetVersUrl ¶
GetVersUrl returns the full URL with protocol validation
func PromptForLogin ¶
func PromptForLogin() error
PromptForLogin creates a helper function that checks for API key and prompts for login if not found
func SaveAPIKey ¶
SaveAPIKey saves the API key to the config file
func SaveConfig ¶
SaveConfig saves the configuration to the .versrc file
Types ¶
type Config ¶
type Config struct {
APIKey string `json:"apiKey"`
}
Config represents the structure of the .versrc file
func LoadConfig ¶
LoadConfig loads the configuration from the .versrc file
type SSHKeyResponse ¶ added in v0.5.0
type SSHKeyResponse struct {
SSHPrivateKey string `json:"ssh_private_key"`
SSHPort int `json:"ssh_port"`
}
SSHKeyResponse represents the API response for VM SSH key
type ShellAuthCreateKeyRequest ¶ added in v0.7.2
type ShellAuthCreateKeyRequest struct {
Email string `json:"email"`
SSHPublicKey string `json:"ssh_public_key"`
Label string `json:"label"`
OrgName string `json:"org_name,omitempty"`
}
ShellAuthCreateKeyRequest is the request body for POST /api/shell-auth/api-keys.
type ShellAuthCreateKeyResponse ¶ added in v0.7.2
type ShellAuthCreateKeyResponse struct {
Success bool `json:"success"`
APIKey string `json:"api_key"`
APIKeyID string `json:"api_key_id"`
OrgID string `json:"org_id"`
OrgName string `json:"org_name"`
}
ShellAuthCreateKeyResponse is the response from POST /api/shell-auth/api-keys.
func ShellAuthCreateAPIKey ¶ added in v0.7.2
func ShellAuthCreateAPIKey(email, sshPubKey, label, orgName string) (*ShellAuthCreateKeyResponse, error)
ShellAuthCreateAPIKey creates an API key for the verified user.
type ShellAuthErrorResponse ¶ added in v0.7.2
ShellAuthErrorResponse captures error details from the API.
type ShellAuthInitRequest ¶ added in v0.7.2
type ShellAuthInitRequest struct {
Email string `json:"email"`
SSHPublicKey string `json:"ssh_public_key"`
Body string `json:"body,omitempty"`
}
ShellAuthInitRequest is the request body for POST /api/shell-auth.
type ShellAuthInitResponse ¶ added in v0.7.2
type ShellAuthInitResponse struct {
Success bool `json:"success"`
UserID string `json:"user_id"`
Email string `json:"email"`
IsNewUser bool `json:"is_new_user"`
Nonce string `json:"nonce"`
SSHPublicKey string `json:"ssh_public_key"`
AlreadyVerified bool `json:"already_verified"`
}
ShellAuthInitResponse is the response from POST /api/shell-auth.
func ShellAuthInitiate ¶ added in v0.7.2
func ShellAuthInitiate(email, sshPubKey string) (*ShellAuthInitResponse, error)
ShellAuthInitiate starts the shell auth flow.
type ShellAuthOrg ¶ added in v0.7.2
type ShellAuthOrg struct {
OrgID string `json:"org_id"`
Name string `json:"name"`
Role string `json:"role"`
}
ShellAuthOrg represents an organization in the verify response.
type ShellAuthVerifyRequest ¶ added in v0.7.2
type ShellAuthVerifyRequest struct {
Email string `json:"email"`
SSHPublicKey string `json:"ssh_public_key"`
}
ShellAuthVerifyRequest is the request body for POST /api/shell-auth/verify-key.
type ShellAuthVerifyResponse ¶ added in v0.7.2
type ShellAuthVerifyResponse struct {
Verified bool `json:"verified"`
IsActive bool `json:"is_active"`
UserID string `json:"user_id"`
KeyID string `json:"key_id"`
Orgs []ShellAuthOrg `json:"orgs"`
Reason string `json:"reason,omitempty"`
}
ShellAuthVerifyResponse is the response from POST /api/shell-auth/verify-key.
func ShellAuthCheckVerification ¶ added in v0.7.2
func ShellAuthCheckVerification(email, sshPubKey string) (*ShellAuthVerifyResponse, error)
ShellAuthCheckVerification does a single verification check (no polling). Use when you already know the key is verified and just need the org list.
func ShellAuthPollVerification ¶ added in v0.7.2
func ShellAuthPollVerification(email, sshPubKey string, timeout time.Duration) (*ShellAuthVerifyResponse, error)
ShellAuthPollVerification polls until the email is verified or timeout. Returns the verify response with orgs on success.