client

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrStatus

func ErrStatus(statusCode int, body []byte) error

Types

type Address

type Address struct {
	Scheme      string `json:"Scheme,omitempty"`
	Host        string `json:"Host,omitempty"`
	Opaque      string `json:"Opaque,omitempty"`
	User        string `json:"User,omitempty"`
	Path        string `json:"Path,omitempty"`
	RawPath     string `json:"RawPath,omitempty"`
	ForceQuery  bool   `json:"ForceQuery"`
	RawQuery    string `json:"RawQuery,omitempty"`
	Fragment    string `json:"Fragment,omitempty"`
	RawFragment string `json:"RawFragment,omitempty"`
}

type Allowed

type Allowed struct {
	Driver []string `json:"driver,omitempty"`
	Plan   []string `json:"plan,omitempty"`
	Team   []string `json:"team,omitempty"`
}

type App

type App struct {
	Name        string         `json:"name,omitempty"`
	Description string         `json:"description,omitempty"`
	TeamOwner   string         `json:"teamowner,omitempty"`
	Plan        *Plan          `json:"plan,omitempty"`
	Units       []*Unit        `json:"units,omitempty"`
	IP          string         `json:"ip,omitempty"`
	Org         string         `json:"org,omitempty"`
	Entrypoints []*Entrypoint  `json:"entrypoints,omitempty"`
	Routers     []*Router      `json:"routers,omitempty"`
	Lock        *Lock          `json:"lock,omitempty"`
	Tags        []string       `json:"tags,omitempty"`
	Platform    string         `json:"platform,omitempty"`
	Status      string         `json:"status,omitempty"`
	Error       string         `json:"error,omitempty"` // not shows in API response
	Environment AppEnvironment `json:"environment,omitempty"`
}

type AppCname

type AppCname struct {
	Cname  string `json:"cname"`
	Scheme string `json:"scheme"`
}

type AppCnames added in v0.0.8

type AppCnames struct {
	Cnames []string `json:"cnames"`
}

type AppConfig added in v0.0.10

type AppConfig struct {
	Environment    string   `json:"environment"`
	Plan           string   `json:"plan"`
	Team           string   `json:"team"`
	Description    string   `json:"description"`
	Router         string   `json:"router"`
	Tags           []string `json:"tags,omitempty"`
	Env            []string `json:"env,omitempty"`
	DependencyFile []string `json:"dependencyFile,omitempty"`
}

AppConfig represents the JSON body that deploy /app expects

type AppDeploy

type AppDeploy struct {
	Image          string   `json:"image"`
	PrivateImage   bool     `json:"private-image,omitempty" terraform:"private_image"`
	RegistryUser   string   `json:"registry-user,omitempty" terraform:"registry_user"`
	RegistrySecret string   `json:"registry-secret,omitempty" terraform:"registry_secret"`
	Environment    string   `json:"environment,omitempty"`
	Plan           string   `json:"plan,omitempty"`
	Team           string   `json:"team,omitempty"`
	Description    string   `json:"description,omitempty"`
	Router         string   `json:"router,omitempty"`
	Tags           []string `json:"tags,omitempty"`
	Env            []string `json:"env,omitempty"`
	DependencyFile []string `json:"dependencyFile,omitempty"`
	Steps          int64    `json:"steps,omitempty"`
	StepWeight     int64    `json:"step-weight,omitempty" terraform:"step_weight"`
	StepInterval   int64    `json:"step-interval,omitempty" terraform:"step_interval"`
	Port           int64    `json:"port,omitempty"`
	Protocol       string   `json:"protocol,omitempty"`
	Detach         bool     `json:"detach"`
	Message        string   `json:"message,omitempty"`
	ShipaYaml      string   `json:"shipaYaml,omitempty" terraform:"shipa_yaml"`
	Origin         string   `json:"origin,omitempty"`
}

type AppDeployRequest added in v0.0.9

type AppDeployRequest struct {
	AppConfig      *AppConfig      `json:"appConfig,omitempty"`
	Image          string          `json:"image"`
	Port           *Port           `json:"port,omitempty"`
	Detach         bool            `json:"detach"`
	Message        string          `json:"message,omitempty"`
	Registry       *Registry       `json:"registry,omitempty"`
	Origin         string          `json:"origin,omitempty"`
	CanarySettings *CanarySettings `json:"canarySettings,omitempty"`
	ShipaYaml      string          `json:"shipaYaml,omitempty"`
}

AppDeployRequest represents the JSON body that deploy /app expects

type AppEnv

type AppEnv struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type AppEnvironment added in v0.0.16

type AppEnvironment struct {
	Id        string `json:"id"`
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Framework string `json:"framework"`
}

type CanarySettings added in v0.0.9

type CanarySettings struct {
	Steps        int `json:"steps,omitempty"`
	StepWeight   int `json:"stepWeight,omitempty"`
	StepInterval int `json:"stepInterval,omitempty"`
}

CanarySettings represents the JSON body that deploy /app expects

type Client

type Client struct {
	HostURL       string
	HTTPClient    *http.Client
	Token         string
	AdminEmail    string
	AdminPassword string
}

func NewClient

func NewClient(options ...Option) (*Client, error)

func (*Client) AssociateRoleToUser

func (c *Client) AssociateRoleToUser(role, email string) error

func (*Client) CreateApp

func (c *Client) CreateApp(app *App) error

func (*Client) CreateAppCname

func (c *Client) CreateAppCname(appName string, req *AppCname) error

func (*Client) CreateAppEnvs

func (c *Client) CreateAppEnvs(appName string, req *CreateAppEnv) error

func (*Client) CreateCluster

func (c *Client) CreateCluster(req *CreateClusterRequest) error

func (*Client) CreateOrUpdateNetworkPolicy

func (c *Client) CreateOrUpdateNetworkPolicy(app string, config *NetworkPolicy) error

CreateOrUpdateNetworkPolicy - creates or updates network policy

func (*Client) CreatePermission

func (c *Client) CreatePermission(req *Permission) error

func (*Client) CreatePlan

func (c *Client) CreatePlan(req *Plan) error

func (*Client) CreatePool

func (c *Client) CreatePool(req *CreatePoolRequest) error

func (*Client) CreatePoolConfig

func (c *Client) CreatePoolConfig(pool *PoolConfig) error

func (*Client) CreateRole

func (c *Client) CreateRole(req *Role) error

func (*Client) CreateTeam

func (c *Client) CreateTeam(req *Team) error

func (*Client) CreateUser

func (c *Client) CreateUser(req *User) error

func (*Client) DeleteApp

func (c *Client) DeleteApp(name string) error

func (*Client) DeleteAppCname

func (c *Client) DeleteAppCname(appName string, req *AppCnames) error

func (*Client) DeleteAppEnvs

func (c *Client) DeleteAppEnvs(appName string, req *DeleteAppEnv) error

func (*Client) DeleteCluster

func (c *Client) DeleteCluster(name string) error

func (*Client) DeleteNetworkPolicy

func (c *Client) DeleteNetworkPolicy(app string) error

DeleteNetworkPolicy - deletes network policy from the given app

func (*Client) DeletePermission

func (c *Client) DeletePermission(role, permission string) error

func (*Client) DeletePlan

func (c *Client) DeletePlan(name string) error

func (*Client) DeletePool

func (c *Client) DeletePool(name string) error

func (*Client) DeleteRole

func (c *Client) DeleteRole(name string) error

func (*Client) DeleteTeam

func (c *Client) DeleteTeam(name string) error

func (*Client) DeleteUser

func (c *Client) DeleteUser(email string) error

func (*Client) DeployApp

func (c *Client) DeployApp(appName string, req *AppDeploy) error

func (*Client) DisassociateRoleFromUser

func (c *Client) DisassociateRoleFromUser(role, email string) error

func (*Client) GetApp

func (c *Client) GetApp(name string) (*App, error)

func (*Client) GetAppEnvs

func (c *Client) GetAppEnvs(appName string) ([]*AppEnv, error)

func (*Client) GetCluster

func (c *Client) GetCluster(name string) (*CreateClusterRequest, error)

func (*Client) GetNetworkPolicy

func (c *Client) GetNetworkPolicy(app string) (*NetworkPolicy, error)

GetNetworkPolicy - get current policy of an app

func (*Client) GetPermission

func (c *Client) GetPermission(role string) (*Permission, error)

func (*Client) GetPlan

func (c *Client) GetPlan(name string) (*Plan, error)

func (*Client) GetPool

func (c *Client) GetPool(name string) (*Pool, error)

func (*Client) GetPoolConfig

func (c *Client) GetPoolConfig(name string) (*PoolConfig, error)

func (*Client) GetRole

func (c *Client) GetRole(name string) (*Role, error)

func (*Client) GetTeam

func (c *Client) GetTeam(name string) (*Team, error)

func (*Client) GetUser

func (c *Client) GetUser(email string) (*User, error)

func (*Client) ListApps

func (c *Client) ListApps() ([]*App, error)

func (*Client) ListPlans

func (c *Client) ListPlans() ([]*Plan, error)

func (*Client) ListPools

func (c *Client) ListPools() ([]*Pool, error)

func (*Client) ListUsers

func (c *Client) ListUsers() ([]*User, error)

func (*Client) UpdateApp

func (c *Client) UpdateApp(name string, app *UpdateAppRequest) error

func (*Client) UpdateAppCname

func (c *Client) UpdateAppCname(appName string, req *AppCname) error

func (*Client) UpdateCluster

func (c *Client) UpdateCluster(req *CreateClusterRequest) error

func (*Client) UpdatePool

func (c *Client) UpdatePool(req *UpdatePoolRequest) error

func (*Client) UpdatePoolConfig

func (c *Client) UpdatePoolConfig(req *PoolConfig) error

func (*Client) UpdateTeam

func (c *Client) UpdateTeam(name string, req *UpdateTeamRequest) error

type ClusterEndpointCreate

type ClusterEndpointCreate struct {
	Addresses         []string `json:"addresses,omitempty"`
	Certificate       string   `json:"caCert,omitempty" terraform:"ca_cert"`
	ClientCertificate string   `json:"clientCert,omitempty" terraform:"client_cert"`
	ClientKey         string   `json:"clientKey,omitempty" terraform:"client_key"`
	Token             string   `json:"token,omitempty"`
	Username          string   `json:"username,omitempty"`
	Password          string   `json:"password,omitempty"`
}

type ClusterResourcesCreate

type ClusterResourcesCreate struct {
	Frameworks         []*Framework                `json:"frameworks,omitempty"`
	IngressControllers []*IngressControllersCreate `json:"ingressControllers,omitempty" terraform:"ingress_controllers"`
}

type CreateAppEnv

type CreateAppEnv struct {
	Envs      []*AppEnv `json:"envs"`
	NoRestart bool      `json:"norestart"`
	Private   bool      `json:"private"`
}

type CreateClusterRequest

type CreateClusterRequest struct {
	Name      string                  `json:"name"`
	Endpoint  *ClusterEndpointCreate  `json:"endpoint"`
	Resources *ClusterResourcesCreate `json:"resources,omitempty"`
}

type CreatePoolRequest

type CreatePoolRequest struct {
	Name        string `json:"name"`
	Default     bool   `json:"default"`
	Provisioner string `json:"provisioner"`
	Public      bool   `json:"public"`
	Force       bool   `json:"force"`
}

type DeleteAppEnv

type DeleteAppEnv struct {
	Envs      []*AppEnv `json:"envs"`
	NoRestart bool      `json:"norestart"`
}

type Email

type Email struct {
	Email string `json:"email"`
}

type Entrypoint

type Entrypoint struct {
	Cname  string `json:"cname,omitempty"`
	Scheme string `json:"scheme,omitempty"`
}

type Framework

type Framework struct {
	Name string `json:"name,omitempty"`
}

type IngressControllersCreate

type IngressControllersCreate struct {
	IngressIP     string `json:"ingressIp,omitempty" terraform:"ingress_ip"`
	ServiceType   string `json:"serviceType,omitempty" terraform:"service_type"`
	Type          string `json:"type,omitempty"`
	HTTPPort      int64  `json:"httpPort,omitempty" terraform:"http_port"`
	HTTPSPort     int64  `json:"httpsPort,omitempty" terraform:"https_port"`
	ProtectedPort int64  `json:"protectedPort,omitempty" terraform:"protected_port"`
	Debug         bool   `json:"debug"`
	AcmeEmail     string `json:"acmeEmail,omitempty" terraform:"acme_email"`
	AcmeServer    string `json:"acmeServer,omitempty" terraform:"acme_server"`
}

type Lock

type Lock struct {
	Locked      bool   `json:"Locked"`
	Reason      string `json:"Reason,omitempty"`
	Owner       string `json:"Owner,omitempty"`
	AcquireDate string `json:"AcquireDate,omitempty"`
}

type NetworkPeer

type NetworkPeer struct {
	PodSelector       *NetworkPeerSelector `json:"podSelector,omitempty"`
	NamespaceSelector *NetworkPeerSelector `json:"namespaceSelector,omitempty"`
	IPBlock           []string             `json:"ipBlock,omitempty"`
}

type NetworkPeerSelector

type NetworkPeerSelector struct {
	MatchLabels      map[string]string     `json:"matchLabels,omitempty"`
	MatchExpressions []*SelectorExpression `json:"matchExpressions,omitempty"`
}

type NetworkPolicy

type NetworkPolicy struct {
	Ingress    *NetworkPolicyConfig `json:"ingress,omitempty"`
	Egress     *NetworkPolicyConfig `json:"egress,omitempty"`
	RestartApp bool                 `json:"restart_app"`
}

type NetworkPolicyConfig

type NetworkPolicyConfig struct {
	PolicyMode        string               `json:"policy_mode,omitempty"`
	CustomRules       []*NetworkPolicyRule `json:"custom_rules,omitempty"`
	ShipaRules        []*NetworkPolicyRule `json:"shipa_rules,omitempty"`
	ShipaRulesEnabled []string             `json:"shipa_rules_enabled,omitempty"`
}

type NetworkPolicyRule

type NetworkPolicyRule struct {
	ID                string         `json:"id,omitempty"`
	Enabled           bool           `json:"enabled"`
	Description       string         `json:"description,omitempty"`
	Ports             []*NetworkPort `json:"ports,omitempty"`
	Peers             []*NetworkPeer `json:"peers,omitempty"`
	AllowedApps       []string       `json:"allowed_apps,omitempty"`
	AllowedFrameworks []string       `json:"allowed_pools,omitempty" terraform:"allowed_frameworks,omitempty"`
}

type NetworkPort

type NetworkPort struct {
	Protocol string `json:"protocol,omitempty"`
	Port     int64  `json:"port,omitempty"`
}

type Option

type Option func(*Client) error

func WithAuth added in v0.0.4

func WithAuth(token string, adminEmail string, adminPassword string) Option

func WithClient

func WithClient(httpClient *http.Client) Option

func WithHost

func WithHost(host string) Option

type Permission

type Permission struct {
	Role        string   `json:"name"`
	Permissions []string `json:"permission"`
}

type Plan

type Plan struct {
	Name     string   `json:"name,omitempty"`
	Memory   int64    `json:"memory"`
	Swap     int64    `json:"swap"`
	CPUShare int64    `json:"cpushare"`
	Default  bool     `json:"default"`
	Public   bool     `json:"public"`
	Org      string   `json:"org,omitempty"`
	Teams    []string `json:"teams,omitempty"`
}

type PodAutoScaler added in v0.0.9

type PodAutoScaler struct {
	MinReplicas                    int `json:"minReplicas,omitempty"`
	MaxReplicas                    int `json:"maxReplicas,omitempty"`
	TargetCPUUtilizationPercentage int `json:"targetCPUUtilizationPercentage,omitempty"`
}

PodAutoScaler represents the JSON body that deploy /app expects

type Pool

type Pool struct {
	Name        string   `json:"name"`
	Default     bool     `json:"default"`
	Provisioner string   `json:"provisioner"`
	Public      bool     `json:"public"`
	Teams       []string `json:"teams,omitempty"`
	Allowed     *Allowed `json:"allowed,omitempty"`
}

type PoolAppQuota

type PoolAppQuota struct {
	Limit string `json:"limit,omitempty"`
}

type PoolAutoScale

type PoolAutoScale struct {
	MaxContainer int     `json:"maxContainer"`
	MaxMemory    int     `json:"maxMemory"`
	ScaleDown    float64 `json:"scaleDown"`
	Rebalance    bool    `json:"rebalance"`
}

type PoolConfig

type PoolConfig struct {
	Name      string         `json:"shipaFramework" terraform:"name"`
	Resources *PoolResources `json:"resources,omitempty"`
}

type PoolContainerPolicy

type PoolContainerPolicy struct {
	AllowedHosts []string `json:"allowedHosts,omitempty"`
}

type PoolDomainPolicy added in v0.0.7

type PoolDomainPolicy struct {
	AllowedCnames []string `json:"allowedCnames,omitempty"`
}

type PoolGeneral

type PoolGeneral struct {
	Setup           *PoolSetup           `json:"setup,omitempty"`
	Plan            *PoolPlan            `json:"plan,omitempty"`
	Security        *PoolSecurity        `json:"security,omitempty"`
	Access          *PoolServiceAccess   `json:"access,omitempty"`
	Services        *PoolServiceAccess   `json:"services,omitempty"`
	Router          string               `json:"router,omitempty"`
	Volumes         []string             `json:"volumes,omitempty"`
	AppQuota        *PoolAppQuota        `json:"appQuota,omitempty"`
	ContainerPolicy *PoolContainerPolicy `json:"containerPolicy,omitempty"`
	NetworkPolicy   *PoolNetworkPolicy   `json:"networkPolicy,omitempty"`
	DomainPolicy    *PoolDomainPolicy    `json:"domainPolicy,omitempty"`
	NodeSelector    *PoolNodeSelector    `json:"nodeSelector,omitempty"`
	PodAutoScaler   *PoolPodAutoScaler   `json:"podAutoScaler,omitempty"`
}

type PoolNetworkPolicy

type PoolNetworkPolicy struct {
	Ingress            *NetworkPolicyConfig `json:"ingress,omitempty"`
	Egress             *NetworkPolicyConfig `json:"egress,omitempty"`
	DisableAppPolicies bool                 `json:"disableAppPolicies"`
}

type PoolNode

type PoolNode struct {
	Drivers   []string       `json:"drivers,omitempty"`
	AutoScale *PoolAutoScale `json:"autoScale,omitempty"`
}

type PoolNodeSelector added in v0.0.7

type PoolNodeSelector struct {
	Terms  map[string]string `json:"terms"`
	Strict bool              `json:"disableAppOverride"`
}

type PoolPlan

type PoolPlan struct {
	Name string `json:"name,omitempty"`
}

type PoolPodAutoScaler added in v0.0.7

type PoolPodAutoScaler struct {
	DisableAppOverride             bool `json:"disableAppOverride"`
	MaxReplicas                    int  `json:"maxReplicas"`
	MinReplicas                    int  `json:"minReplicas"`
	TargetCPUUtilizationPercentage int  `json:"targetCPUUtilizationPercentage"`
}

type PoolResources

type PoolResources struct {
	General *PoolGeneral `json:"general,omitempty"`
	Node    *PoolNode    `json:"shipaNode,omitempty"`
}

type PoolSecurity

type PoolSecurity struct {
	DisableScan        bool     `json:"disableScan"`
	ScanPlatformLayers bool     `json:"scanPlatformLayers"`
	IgnoreComponents   []string `json:"ignoreComponents,omitempty"`
	IgnoreCVES         []string `json:"ignoreCves,omitempty"`
}

type PoolServiceAccess

type PoolServiceAccess struct {
	Append    []string `json:"append,omitempty"`
	Blacklist []string `json:"blacklist,omitempty"`
}

type PoolSetup

type PoolSetup struct {
	Default             bool   `json:"default"`
	Public              bool   `json:"public"`
	Provisioner         string `json:"provisioner,omitempty"`
	KubernetesNamespace string `json:"kubernetesNamespace,omitempty"`
}

type Port added in v0.0.9

type Port struct {
	Number   int    `json:"number,omitempty"`
	Protocol string `json:"protocol,omitempty"`
}

Port represents the JSON body that deploy /app expects

type QueryParam

type QueryParam struct {
	Key string
	Val interface{}
}

type Registry added in v0.0.9

type Registry struct {
	User   string `json:"user,omitempty"`
	Secret string `json:"secret,omitempty"`
}

Registry represents the JSON body that deploy /app expects

type Role

type Role struct {
	Name        string `json:"name"`
	Context     string `json:"context"`
	Description string `json:"description,omitempty"`
}

type Router

type Router struct {
	Name    string                 `json:"name,omitempty"`
	Opts    map[string]interface{} `json:"opts,omitempty"`
	Type    string                 `json:"type,omitempty"`
	Address string                 `json:"address,omitempty"`
	Default bool                   `json:"default"` // not show in API response
}

type SelectorExpression

type SelectorExpression struct {
	Key      string   `json:"key,omitempty"`
	Operator string   `json:"operator,omitempty"`
	Values   []string `json:"values,omitempty"`
}

type Team

type Team struct {
	Name string   `json:"name"`
	Tags []string `json:"tags,omitempty"`
}

type TerraformClusterResourcesCreate

type TerraformClusterResourcesCreate struct {
	Frameworks         *TerraformFramework         `json:"frameworks,omitempty"`
	IngressControllers []*IngressControllersCreate `json:"ingressControllers,omitempty" terraform:"ingress_controllers"`
}

type TerraformCreateClusterRequest

type TerraformCreateClusterRequest struct {
	Name      string                           `json:"name"`
	Endpoint  *ClusterEndpointCreate           `json:"endpoint"`
	Resources *TerraformClusterResourcesCreate `json:"resources,omitempty"`
}

func NewTerraformCreateClusterRequest

func NewTerraformCreateClusterRequest(from *CreateClusterRequest) *TerraformCreateClusterRequest

type TerraformFramework

type TerraformFramework struct {
	Name []string `json:"name,omitempty"`
}

type Unit

type Unit struct {
	ID          string   `json:"ID,omitempty"`
	Name        string   `json:"Name,omitempty"`
	AppName     string   `json:"AppName,omitempty"`
	ProcessName string   `json:"ProcessName,omitempty"`
	Type        string   `json:"Type,omitempty"`
	IP          string   `json:"IP,omitempty"`
	Status      string   `json:"Status,omitempty"`
	Version     string   `json:"Version,omitempty"`
	Org         string   `json:"Org,omitempty"`
	HostAddr    string   `json:"HostAddr,omitempty"`
	HostPort    string   `json:"HostPort,omitempty"`
	Address     *Address `json:"Address,omitempty"`
}

type UpdateAppRequest

type UpdateAppRequest struct {
	Pool        string   `json:"pool,omitempty"`
	TeamOwner   string   `json:"teamowner,omitempty"`
	Description string   `json:"description,omitempty"`
	Plan        string   `json:"plan,omitempty"`
	Platform    string   `json:"platform,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

func NewUpdateAppRequest

func NewUpdateAppRequest(a *App) *UpdateAppRequest

type UpdatePoolRequest

type UpdatePoolRequest struct {
	Name    string `json:"-"`
	Default bool   `json:"default"`
	Public  bool   `json:"public"`
	Force   bool   `json:"force"`
}

type UpdateTeamRequest

type UpdateTeamRequest struct {
	Name string   `json:"newname,omitempty"`
	Tags []string `json:"tags,omitempty"`
}

type User

type User struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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