mockapi

package
v0.0.0-...-906dae5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 39 Imported by: 0

Documentation

Overview

Package mockapi provides mocks of the HTTP API for use in integration tests.

Index

Constants

View Source
const (
	ActivityResultSuccess = "success"
	ActivityResultFailure = "failure"
)

Activity results.

View Source
const (
	SSHKeySourceAccounts = "accounts"
	SSHKeySourceAuth     = "auth"
)

SSH key sources, reported by /ssh-key-source.

View Source
const ActivityStateCancelled = "cancelled" //nolint:misspell // The API's spelling.

ActivityStateCancelled is the state of an activity after cancellation.

Variables

View Source
var TestPhoneVerificationCode = "123456"
View Source
var ValidAPITokens = []string{"api-token-1", "api-token-2"}

ValidAPITokens are the API tokens that the server accepts. Each is exchanged for the access token at the same index in accessTokens, unless SetUniqueAccessTokens is used.

Functions

func JWTAccessToken

func JWTAccessToken(id string, expires time.Time) string

JWTAccessToken returns an unsigned JWT with the given "jti" and "exp" claims.

func NumericID

func NumericID() string

NumericID generates a random numeric ID.

func Problem

func Problem(status int, detail string) string

Problem returns the body of an API error (RFC 9457), with a detail message.

func ProjectID

func ProjectID() string

ProjectID generates a random project ID.

func RequestLogger

func RequestLogger(t testing.TB) func(http.Handler) http.Handler

RequestLogger logs requests to the test log, so that parallel tests' logs are not interleaved.

func SSHKeyFingerprint

func SSHKeyFingerprint(publicKey string) string

SSHKeyFingerprint returns the SHA-256 fingerprint of a public key, in the format of `ssh-keygen -l`.

Types

type Activity

type Activity struct {
	ID         string         `json:"id"`
	Type       string         `json:"type"`
	Parameters map[string]any `json:"parameters"`

	State             string    `json:"state"`
	Result            string    `json:"result"`
	CompletionPercent int       `json:"completion_percent"`
	CompletedAt       time.Time `json:"completed_at"`
	StartedAt         time.Time `json:"started_at"`

	Project      string   `json:"project"`
	Environments []string `json:"environments"`
	Integration  string   `json:"integration,omitempty"`

	Description string `json:"description"`
	Text        string `json:"text"`

	Payload any `json:"payload"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	// Links defaults to "self", "log" and, if the activity is cancellable, "#cancel".
	Links HalLinks `json:"_links,omitempty"`
	// contains filtered or unexported fields
}

func (Activity) MarshalJSON

func (a Activity) MarshalJSON() ([]byte, error)

MarshalJSON adds the default links. Its value receiver means it also applies when encoding a value.

type App

type App struct {
	Name string `json:"name"`
	Type string `json:"type"`
	Size string `json:"size,omitempty"`
	Disk int    `json:"disk"`

	Mounts    map[string]Mount `json:"mounts"`
	Resources map[string]any   `json:"resources,omitempty"`

	Web     map[string]any `json:"web,omitempty"`
	Runtime map[string]any `json:"runtime,omitempty"`
	Stack   any            `json:"stack,omitempty"`
}

type AuthServer

type AuthServer struct {
	*httptest.Server
	// contains filtered or unexported fields
}

AuthServer is a mock authentication server for testing.

Like the real server, it rotates refresh tokens on every refresh. Reusing a rotated refresh token revokes all refresh tokens from the same login.

func NewAuthServer

func NewAuthServer(t *testing.T) *AuthServer

NewAuthServer creates a new mock authentication server. The caller must call Close() on the server when finished.

func (*AuthServer) APITokenExchanges

func (s *AuthServer) APITokenExchanges() int

APITokenExchanges returns the number of api_token grant requests received.

func (*AuthServer) AddRefreshToken

func (s *AuthServer) AddRefreshToken(token string)

AddRefreshToken makes a refresh token valid, as if it had been issued at login.

func (*AuthServer) AuthorizePrompts

func (s *AuthServer) AuthorizePrompts() []string

AuthorizePrompts returns the "prompt" parameter of each authorization request.

func (*AuthServer) RefreshRequests

func (s *AuthServer) RefreshRequests() int

RefreshRequests returns the number of refresh_token grant requests received.

func (*AuthServer) ReuseDetected

func (s *AuthServer) ReuseDetected() bool

ReuseDetected reports whether a rotated refresh token was sent again.

func (*AuthServer) RevokedTokens

func (s *AuthServer) RevokedTokens() []string

RevokedTokens returns a copy of all tokens that have been revoked, excluding failed revocations.

func (*AuthServer) SSHCertificateCount

func (s *AuthServer) SSHCertificateCount() int

SSHCertificateCount returns the number of SSH certificates issued.

func (*AuthServer) SetJWTAccessTokens

func (s *AuthServer) SetJWTAccessTokens(jwt bool)

SetJWTAccessTokens makes the server issue access tokens as unsigned JWTs, whose "jti" claim is the token that it would otherwise issue, and whose "exp" claim is the token's expiry.

func (*AuthServer) SetRefreshDelay

func (s *AuthServer) SetRefreshDelay(d time.Duration)

SetRefreshDelay delays refresh token responses, e.g. to make concurrent refreshes overlap.

func (*AuthServer) SetRefreshFailures

func (s *AuthServer) SetRefreshFailures(n int)

SetRefreshFailures makes the next n refresh requests fail with a 503 error.

func (*AuthServer) SetRevokeFailures

func (s *AuthServer) SetRevokeFailures(n, status int)

SetRevokeFailures makes the next n revocation requests fail with an HTTP status.

func (*AuthServer) SetSSHCertificate

func (s *AuthServer) SetSSHCertificate(keyID string, lifetime time.Duration)

SetSSHCertificate sets the key ID and lifetime of issued SSH certificates (default: "test-key-id" and 1 minute). The legacy CLI only reuses a certificate if its key ID is the user ID, and it expires more than 2 minutes later.

func (*AuthServer) SetTokenLifetime

func (s *AuthServer) SetTokenLifetime(d time.Duration)

SetTokenLifetime sets the lifetime of issued access tokens (default: 1 hour).

func (*AuthServer) SetUniqueAccessTokens

func (s *AuthServer) SetUniqueAccessTokens(unique bool)

SetUniqueAccessTokens makes the server issue a new access token each time ("access-token-1", "access-token-2", ...), instead of always "access-token-1".

type Backup

type Backup struct {
	ID            string    `json:"id"`
	EnvironmentID string    `json:"environment"`
	Status        string    `json:"status"`
	Safe          bool      `json:"safe"`
	Restorable    bool      `json:"restorable"`
	Automated     bool      `json:"automated"`
	CommitID      string    `json:"commit_id"`
	ExpiresAt     time.Time `json:"expires_at"`

	Links HalLinks `json:"_links,omitempty"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type BillingProfile

type BillingProfile struct {
	ID                 string `json:"billing_profile_id"`
	Name               string `json:"name"`
	BillingEmail       string `json:"billing_email"`
	BillingContacts    string `json:"billing_contacts"`
	Country            string `json:"country"`
	Currency           string `json:"currency"`
	BillingStreet1     string `json:"billing_street_1"`
	BillingStreet2     string `json:"billing_street_2"`
	Locality           string `json:"locality"`
	AdministrativeArea string `json:"administrative_area"`
	PostalCode         string `json:"postal_code"`
	PricingModel       string `json:"pricing_model"`

	Links HalLinks `json:"_links,omitempty"`
}

BillingProfile is a billing profile on the new billing system.

type CanCreateRequiredAction

type CanCreateRequiredAction struct {
	Action string `json:"action"`
	Type   string `json:"type"`
}

type CanCreateResponse

type CanCreateResponse struct {
	CanCreate bool   `json:"can_create"`
	Message   string `json:"message"`

	RequiredAction *CanCreateRequiredAction `json:"required_action"`
}

type Certificate

type Certificate struct {
	ID            string     `json:"id"`
	Certificate   string     `json:"certificate"`
	Chain         []string   `json:"chain"`
	Domains       []string   `json:"domains"`
	AuthType      []string   `json:"auth_type"`
	Issuer        []NameAttr `json:"issuer"`
	IsProvisioned bool       `json:"is_provisioned"`
	IsInvalid     bool       `json:"is_invalid"`
	IsRoot        bool       `json:"is_root"`

	ExpiresAt time.Time `json:"expires_at"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	Links HalLinks `json:"_links,omitempty"`
}

func (Certificate) MarshalJSON

func (c Certificate) MarshalJSON() ([]byte, error)

MarshalJSON outputs empty lists instead of null.

type Commands

type Commands struct {
	Start string `json:"start"`
}

type Deployment

type Deployment struct {
	WebApps  map[string]App     `json:"webapps"`
	Services map[string]Service `json:"services"`
	Workers  map[string]Worker  `json:"workers"`
	Tasks    map[string]App     `json:"tasks,omitempty"`

	ProjectInfo map[string]any `json:"project_info,omitempty"`

	Routes map[string]any `json:"routes"`

	Links HalLinks `json:"_links,omitempty"`
}

func (Deployment) MarshalJSON

func (d Deployment) MarshalJSON() ([]byte, error)

MarshalJSON outputs empty objects instead of null, as the API does.

type Domain

type Domain struct {
	ID             string    `json:"id"`
	Name           string    `json:"name"`
	RegisteredName string    `json:"registered_name,omitempty"`
	Type           string    `json:"type"`
	IsDefault      bool      `json:"is_default"`
	ReplacementFor string    `json:"replacement_for,omitempty"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`

	SSL *DomainSSL `json:"ssl"`

	Links HalLinks `json:"_links,omitempty"`
}

func (Domain) MarshalJSON

func (d Domain) MarshalJSON() ([]byte, error)

MarshalJSON leaves out is_default from replacement domains, as the API does.

type DomainSSL

type DomainSSL struct {
	HasCertificate bool       `json:"has_certificate"`
	Certificate    string     `json:"certificate,omitempty"`
	ExpiresOn      *time.Time `json:"expires_on,omitempty"`
}

DomainSSL is computed from the project's certificates, as the API does.

type EnvLevelVariable

type EnvLevelVariable struct {
	Variable

	Project       string `json:"project"`
	Environment   string `json:"environment"`
	IsEnabled     bool   `json:"is_enabled"`
	Inherited     bool   `json:"inherited"`
	IsInheritable bool   `json:"is_inheritable"`
}

type Environment

type Environment struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	MachineName string    `json:"machine_name"`
	Title       string    `json:"title"`
	Type        string    `json:"type"`
	Status      string    `json:"status"`
	Parent      any       `json:"parent"`
	Project     string    `json:"project"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Links       HalLinks  `json:"_links,omitempty"`

	HTTPAccess       map[string]any `json:"http_access,omitempty"`
	HeadCommit       string         `json:"head_commit,omitempty"`
	MergeInfo        map[string]any `json:"merge_info,omitempty"`
	CanRollingDeploy bool           `json:"can_rolling_deploy,omitempty"`
	// contains filtered or unexported fields
}

func (*Environment) AddOperations

func (e *Environment) AddOperations(ops ...string)

AddOperations adds links for environment operations (e.g. "branch" or "merge"), which the CLI checks before running them.

func (*Environment) SetAutoscalingSettings

func (e *Environment) SetAutoscalingSettings(s map[string]any)

SetAutoscalingSettings sets the autoscaling settings, and the environment links needed to read and manage them.

func (*Environment) SetCurrentDeployment

func (e *Environment) SetCurrentDeployment(d *Deployment)

func (*Environment) SetNextDeployment

func (e *Environment) SetNextDeployment(d map[string]any)

SetNextDeployment sets the next deployment, which is served as raw data so that tests can include fields the Deployment type lacks. PATCH requests to it are recorded, and returned by Handler.DeploymentPatches.

func (*Environment) SetSetting

func (e *Environment) SetSetting(key string, val any)

type EnvironmentAction

type EnvironmentAction struct {
	Type string         // The activity type, e.g. "environment.deploy".
	Body map[string]any // The decoded request body, if any.
}

EnvironmentAction is a request to an environment operation, e.g. deploy or branch.

type HALLink struct {
	HREF string `json:"href"`
}
type HalLinks map[string]HALLink
func MakeHALLinks(nameAndPath ...string) HalLinks

MakeHALLinks helps make a list of HAL links out of arguments in the format name=path.

type Handler

type Handler struct {
	*chi.Mux
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(t *testing.T) *Handler

func (*Handler) AllRequests

func (h *Handler) AllRequests() []Request

AllRequests returns every request received, in order.

func (*Handler) AutoscalingPatches

func (s *Handler) AutoscalingPatches(projectID, environmentID string) []map[string]any

AutoscalingPatches returns the bodies of PATCH requests to an environment's autoscaling settings.

func (*Handler) BackupRestores

func (s *Handler) BackupRestores(projectID string) []map[string]any

BackupRestores returns the bodies of requests to restore a project's backups.

func (*Handler) BillingProfile

func (s *Handler) BillingProfile(id string) *BillingProfile

BillingProfile returns a copy of a billing profile, e.g. to check updates.

func (*Handler) DeploymentPatches

func (h *Handler) DeploymentPatches(projectID, environmentID string) []map[string]any

DeploymentPatches returns the bodies of PATCH requests to an environment's next deployment.

func (*Handler) Domains

func (s *Handler) Domains(projectID, environmentID string) []*Domain

Domains returns copies of a project's domains, or of an environment's if environmentID is not empty. SSL information is not included.

func (*Handler) Environment

func (s *Handler) Environment(projectID, environmentID string) *Environment

Environment returns a copy of an environment, or nil if it does not exist.

func (*Handler) EnvironmentActions

func (s *Handler) EnvironmentActions(projectID, environmentID string) []EnvironmentAction

EnvironmentActions returns the operation requests made to an environment.

func (*Handler) FailNext

func (h *Handler) FailNext(method, pattern string, status int, body string)

FailNext makes the next request with a method and a path matching a pattern fail with a status and a body, instead of reaching its route. The pattern is for path.Match, as in Requests. Each call fails one request.

A JSON body is sent as an API error (see Problem), and any other body as HTML, like a proxy's error page.

func (*Handler) Integrations

func (s *Handler) Integrations(projectID string) []*Integration

Integrations returns copies of a project's integrations.

func (*Handler) OrgIDs

func (s *Handler) OrgIDs() []string

OrgIDs returns the IDs of the organizations.

func (*Handler) OrgInvitations

func (s *Handler) OrgInvitations(orgID string) []OrgInvitation

OrgInvitations returns copies of the invitations created on an organization.

func (*Handler) ProjectActivities

func (s *Handler) ProjectActivities(projectID string) []*Activity

ProjectActivities returns copies of a project's activities, newest first. The Payload is not copied.

func (*Handler) ProjectBackups

func (s *Handler) ProjectBackups(projectID string) []*Backup

ProjectBackups returns copies of a project's backups, sorted by ID.

func (*Handler) ProjectCertificates

func (s *Handler) ProjectCertificates(projectID string) []*Certificate

ProjectCertificates returns copies of a project's certificates.

func (*Handler) ProjectIDs

func (s *Handler) ProjectIDs() []string

ProjectIDs returns the IDs of the projects.

func (*Handler) ProjectInvitations

func (s *Handler) ProjectInvitations(projectID string) []ProjectInvitation

ProjectInvitations returns copies of the invitations created on a project.

func (*Handler) ProjectSettingsPatches

func (s *Handler) ProjectSettingsPatches(projectID string) []map[string]any

ProjectSettingsPatches returns the bodies of PATCH requests to a project's settings.

func (*Handler) RejectAccessToken

func (h *Handler) RejectAccessToken(token string)

RejectAccessToken makes requests with an access token fail with a 401 error, as if it were revoked.

func (*Handler) Requests

func (h *Handler) Requests(method, pattern string) []Request

Requests returns the requests received with a method and a path matching a pattern, in order. The pattern is for path.Match, where "*" matches one path segment.

func (*Handler) RequireStepUp

func (h *Handler) RequireStepUp(amr []string)

RequireStepUp makes every request fail with a step-up authentication challenge (RFC 9470).

func (*Handler) RespondWithActivity

func (h *Handler) RespondWithActivity(w http.ResponseWriter, projectID, environmentID, activityType string)

RespondWithActivity creates an activity and writes an action response that embeds it, for use in custom handlers. The activity is in progress until it is next read, when it completes with the result set by SetActivityResult.

func (*Handler) SSHKeys

func (s *Handler) SSHKeys() []*SSHKey

SSHKeys returns copies of the SSH keys in the current user's account.

func (*Handler) SetActivityResult

func (s *Handler) SetActivityResult(result string)

SetActivityResult sets the result of activities created from now on, e.g. by deploy or backup actions. The default is ActivityResultSuccess.

func (*Handler) SetBillingProfiles

func (s *Handler) SetBillingProfiles(profiles []*BillingProfile)

func (*Handler) SetCanCreate

func (s *Handler) SetCanCreate(orgID string, r *CanCreateResponse)

func (*Handler) SetEnvLevelVariables

func (s *Handler) SetEnvLevelVariables(projectID, environmentID string, vars []*EnvLevelVariable)

func (*Handler) SetEnvironmentDomains

func (s *Handler) SetEnvironmentDomains(projectID, environmentID string, domains []*Domain)

SetEnvironmentDomains sets an environment's domains. The default branch's domains are the project's domains, so the project must be set first.

func (*Handler) SetEnvironments

func (s *Handler) SetEnvironments(envs []*Environment)

func (*Handler) SetMyUser

func (s *Handler) SetMyUser(u *User)

func (*Handler) SetOrgMembers

func (s *Handler) SetOrgMembers(orgID string, members []*OrgMember)

SetOrgMembers sets the members of an organization.

func (*Handler) SetOrgs

func (s *Handler) SetOrgs(orgs []*Org)

func (*Handler) SetOtherUserSSHKeys

func (s *Handler) SetOtherUserSSHKeys(values []string)

SetOtherUserSSHKeys sets the values of SSH keys registered by other users.

func (*Handler) SetProjectActivities

func (s *Handler) SetProjectActivities(projectID string, activities []*Activity)

func (*Handler) SetProjectBackups

func (s *Handler) SetProjectBackups(projectID string, backups []*Backup)

func (*Handler) SetProjectCertificates

func (s *Handler) SetProjectCertificates(projectID string, certs []*Certificate)

func (*Handler) SetProjectDomains

func (s *Handler) SetProjectDomains(projectID string, domains []*Domain)

func (*Handler) SetProjectIntegrations

func (s *Handler) SetProjectIntegrations(projectID string, integrations []*Integration)

func (*Handler) SetProjectVariables

func (s *Handler) SetProjectVariables(projectID string, vars []*Variable)

func (*Handler) SetProjects

func (s *Handler) SetProjects(pros []*Project)

func (*Handler) SetSSHKeySource

func (s *Handler) SetSSHKeySource(source string)

SetSSHKeySource sets the API that owns SSH keys. By default, /ssh-key-source does not exist, so the CLI uses the Accounts API.

func (*Handler) SetSSHKeys

func (s *Handler) SetSSHKeys(keys []*SSHKey)

SetSSHKeys sets the SSH keys in the current user's account.

func (*Handler) SetTeamMembers

func (s *Handler) SetTeamMembers(teamID string, members []*TeamMember)

SetTeamMembers sets the users in a team.

func (*Handler) SetTeamProjects

func (s *Handler) SetTeamProjects(teamID string, projects []*TeamProjectAccess)

SetTeamProjects sets the projects a team can access.

func (*Handler) SetTeams

func (s *Handler) SetTeams(teams []*Team)

SetTeams sets the teams, replacing any existing teams, members and project access.

func (*Handler) SetUserGrants

func (s *Handler) SetUserGrants(grants []*UserGrant)

type Integration

type Integration struct {
	ID   string `json:"id"`
	Type string `json:"type"`

	BaseURL    string `json:"base_url,omitempty"`
	Token      string `json:"-"` // Write-only in the API.
	Repository string `json:"repository,omitempty"`

	BuildPullRequests      bool `json:"build_pull_requests,omitempty"`
	BuildDraftPullRequests bool `json:"build_draft_pull_requests,omitempty"`

	URL    string   `json:"url,omitempty"`
	Events []string `json:"events,omitempty"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	Links HalLinks `json:"_links,omitempty"`
}

type InvitationPermission

type InvitationPermission struct {
	Type string `json:"type"`
	Role string `json:"role"`
}

InvitationPermission is an environment type role in a project invitation.

type Mount

type Mount struct {
	Source     string `json:"source"`
	SourcePath string `json:"source_path"`
}

type NameAttr

type NameAttr struct {
	OID   string `json:"oid"`
	Alias string `json:"alias"`
	Value string `json:"value"`
}

NameAttr is an attribute of an X.509 name, such as the certificate issuer.

type Org

type Org struct {
	ID           string   `json:"id"`
	Type         string   `json:"type"`
	Name         string   `json:"name"`
	Label        string   `json:"label"`
	Owner        string   `json:"owner_id"`
	Capabilities []string `json:"capabilities"`
	Links        HalLinks `json:"_links,omitempty"`

	BillingLegacy    *bool  `json:"billing_legacy,omitempty"`
	BillingProfileID string `json:"billing_profile_id,omitempty"`
}

func (*Org) AsRef

func (o *Org) AsRef() *OrgRef

func (Org) MarshalJSON

func (o Org) MarshalJSON() ([]byte, error)

MarshalJSON outputs an empty list of capabilities instead of null.

type OrgInvitation

type OrgInvitation struct {
	ID             string
	State          string
	OrganizationID string
	Email          string
	Permissions    []string
	CreatedAt      time.Time
}

type OrgMember

type OrgMember struct {
	OrganizationID string    `json:"organization_id"`
	UserID         string    `json:"user_id"`
	Permissions    []string  `json:"permissions"`
	Owner          bool      `json:"owner"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

OrgMember is a user in an organization. Its ID is the user ID.

type OrgProject

type OrgProject struct {
	ID             string    `json:"id"`
	OrganizationID string    `json:"organization_id"`
	Title          string    `json:"title"`
	Region         string    `json:"region"`
	Vendor         string    `json:"vendor"`
	Status         string    `json:"status"`
	SubscriptionID string    `json:"subscription_id,omitempty"`
	ProjectUI      string    `json:"project_ui,omitempty"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	Links          HalLinks  `json:"_links"`
}

OrgProject is a project in an organization's project list.

type OrgRef

type OrgRef struct {
	ID    string `json:"id"`
	Type  string `json:"type"`
	Name  string `json:"name"`
	Label string `json:"label"`
	Owner string `json:"owner_id"`
}

type Project

type Project struct {
	ID            string            `json:"id"`
	Title         string            `json:"title"`
	Region        string            `json:"region"`
	Organization  string            `json:"organization"`
	Owner         string            `json:"owner,omitempty"`
	Vendor        string            `json:"vendor"`
	Repository    ProjectRepository `json:"repository"`
	DefaultBranch string            `json:"default_branch"`
	Links         HalLinks          `json:"_links,omitempty"`
	CreatedAt     time.Time         `json:"created_at"`
	UpdatedAt     time.Time         `json:"updated_at"`

	Subscription ProjectSubscriptionInfo `json:"subscription,omitempty"`

	SubscriptionID string `json:"-"`
	// ProjectUI is the Console URL served by the Projects API.
	ProjectUI string `json:"-"`

	// Settings are served at the project's /settings path, if set.
	Settings map[string]any `json:"-"`
}

func (*Project) AsRef

func (p *Project) AsRef() *ProjectRef

type ProjectInvitation

type ProjectInvitation struct {
	ID          string
	State       string
	ProjectID   string
	Email       string
	Role        string
	Permissions []InvitationPermission
	CreatedAt   time.Time
}

type ProjectRef

type ProjectRef struct {
	ID             string    `json:"id"`
	Region         string    `json:"region"`
	Title          string    `json:"title"`
	Status         string    `json:"status"`
	OrganizationID string    `json:"organization_id"`
	SubscriptionID string    `json:"subscription_id"`
	Vendor         string    `json:"vendor,omitempty"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

type ProjectRepository

type ProjectRepository struct {
	URL string `json:"url"`
}

type ProjectSubscriptionInfo

type ProjectSubscriptionInfo struct {
	LicenseURI string `json:"license_uri,omitempty"`

	Plan          string `json:"plan,omitempty"`
	Environments  int    `json:"environments,omitempty"`
	Storage       int    `json:"storage,omitempty"`
	IncludedUsers int    `json:"included_users,omitempty"`
	UserLicenses  int    `json:"user_licenses,omitempty"`

	ManagementURI string `json:"subscription_management_uri,omitempty"`

	Restricted bool `json:"restricted,omitempty"`
	Suspended  bool `json:"suspended,omitempty"`
}

type ProjectUserGrant

type ProjectUserGrant struct {
	ProjectID      string    `json:"project_id"`
	OrganizationID string    `json:"organization_id"`
	UserID         string    `json:"user_id"`
	Permissions    []string  `json:"permissions"`
	GrantedAt      time.Time `json:"granted_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

type Request

type Request struct {
	Method string
	Path   string
	Query  url.Values
	Header http.Header
	Body   string
}

Request is a request received by the mock API.

type SSHKey

type SSHKey struct {
	ID     string
	Label  string
	Value  string
	Active bool
}

SSHKey is an SSH public key in the current user's account. Keys from the Accounts API have numeric IDs.

type Service

type Service struct {
	Type string `json:"type"`
	Size string `json:"size,omitempty"`
	Disk int    `json:"disk,omitempty"`
}

Service is a service in a deployment.

type Subscription

type Subscription struct {
	ID            string   `json:"id"`
	Links         HalLinks `json:"_links,omitempty"`
	ProjectID     string   `json:"project_id"`
	ProjectRegion string   `json:"project_region"`
	ProjectTitle  string   `json:"project_title"`
	Status        string   `json:"status"`
	ProjectUI     string   `json:"project_ui"`
}

type Team

type Team struct {
	ID                 string     `json:"id"`
	OrganizationID     string     `json:"organization_id"`
	Label              string     `json:"label"`
	ProjectPermissions []string   `json:"project_permissions"`
	Counts             TeamCounts `json:"counts"`
	CreatedAt          time.Time  `json:"created_at"`
	UpdatedAt          time.Time  `json:"updated_at"`
	Links              HalLinks   `json:"_links,omitempty"`
}

type TeamCounts

type TeamCounts struct {
	MemberCount  int `json:"member_count"`
	ProjectCount int `json:"project_count"`
}

TeamCounts is calculated from the team's members and projects.

type TeamMember

type TeamMember struct {
	TeamID    string    `json:"team_id"`
	UserID    string    `json:"user_id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Links     HalLinks  `json:"_links,omitempty"`
}

type TeamProjectAccess

type TeamProjectAccess struct {
	TeamID         string    `json:"team_id"`
	OrganizationID string    `json:"organization_id"`
	ProjectID      string    `json:"project_id"`
	ProjectTitle   string    `json:"project_title"`
	GrantedAt      time.Time `json:"granted_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	Links          HalLinks  `json:"_links,omitempty"`
}

type User

type User struct {
	ID string `json:"id"`

	Deactivated bool `json:"deactivated"`

	Namespace string `json:"namespace"`

	Username      string `json:"username"`
	FirstName     string `json:"first_name"`
	LastName      string `json:"last_name"`
	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`
	Picture       string `json:"picture"`
	Country       string `json:"country,omitempty"`

	PhoneNumberVerified bool `json:"phone_number_verified"`

	MFAEnabled bool `json:"mfa_enabled"`
	SSOEnabled bool `json:"sso_enabled"`

	ConsentMethod string    `json:"consent_method,omitempty"`
	ConsentedAt   time.Time `json:"consented_at"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type UserGrant

type UserGrant struct {
	ResourceID     string    `json:"resource_id"`
	ResourceType   string    `json:"resource_type"`
	OrganizationID string    `json:"organization_id"`
	UserID         string    `json:"user_id"`
	Permissions    []string  `json:"permissions"`
	GrantedAt      time.Time `json:"granted_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

type UserRef

type UserRef struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	Username  string `json:"username"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
}

type Variable

type Variable struct {
	ID               string            `json:"id"`
	Name             string            `json:"name"`
	Value            string            `json:"value,omitempty"`
	Attributes       map[string]string `json:"attributes"`
	IsJSON           bool              `json:"is_json"`
	IsSensitive      bool              `json:"is_sensitive"`
	VisibleBuild     bool              `json:"visible_build"`
	VisibleRuntime   bool              `json:"visible_runtime"`
	ApplicationScope []string          `json:"application_scope"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	Links HalLinks `json:"_links,omitempty"`
}

type Worker

type Worker struct {
	App
	Worker WorkerInfo `json:"worker"`
}

type WorkerInfo

type WorkerInfo struct {
	Commands Commands `json:"commands"`
}

Jump to

Keyboard shortcuts

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