apiclient

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VPNDeviceType = "global_vpn_device"
	ClusterType   = "byok_cluster"
)
View Source
const (
	PublicEnvRoutingMode = "public"
	EnvironmentType      = "environment"
)
View Source
const (
	Default_GVPN = "default"
)

Variables

View Source
var PaginationDefault = map[string]any{
	"orderBy":       "updateTime",
	"sortDirection": "ASC",
	"first":         99999999,
}

Functions

func GetFromResp

func GetFromResp[T any](respData []byte) (*T, error)

func GetFromRespForEdge

func GetFromRespForEdge[T any](respData []byte) ([]T, error)

Types

type ApiClient

type ApiClient interface {
	ListTeams() ([]Team, error)
	GetHostDNSSuffix() (string, error)

	ListApps(teamName string, envName string) ([]App, error)
	InterceptApp(app *App, status bool, ports []AppPort, envName string, options ...fn.Option) (err error)

	CreateRemoteLogin() (loginId string, err error)
	GetCurrentUser() (*User, error)
	Login(loginId string) error

	ListConfigs(teamName string, envName string) ([]Config, error)
	GetConfig(teamName string, envName string, configName string) (*Config, error)

	GetVPNDevice(teamName string, devName string) (*Device, error)
	CheckDeviceStatus() bool
	GetAccVPNConfig(team string) (*fileclient.TeamVpnConfig, error)
	CreateVpnForTeam(team string) (*Device, error)
	CreateDevice(devName, displayName, team string) (*Device, error)

	GetClusterConfig(team string) (*fileclient.TeamClusterConfig, error)

	ListEnvs(teamName string) ([]Env, error)
	GetEnvironment(teamName, envName string) (*Env, error)
	EnsureEnv() (*fileclient.Env, error)
	CloneEnv(teamName, envName, newEnvName, clusterName string) (*Env, error)
	UpdateEnvironment(teamName string, env *Env, isSuspend bool) error
	CheckEnvName(teamName, envName string) (bool, error)
	GetLoadMaps() (map[string]string, MountMap, error)

	//ListBYOKClusters(teamName string) ([]BYOKCluster, error)
	GetClustersOfTeam(team string) ([]Cluster, error)
	DeleteCluster(team, clusterName string) error
	GetCluster(team, clusterName string) (*Cluster, error)
	ListMreses(teamName string, envName string) ([]Mres, error)
	ListMresKeys(teamName, envName, importedManagedResource string) ([]string, error)
	GetMresConfigValues(teamName string) (map[string]string, error)

	ListSecrets(teamName string, envName string) ([]Secret, error)
	GetSecret(teamName string, secretName string) (*Secret, error)

	RemoveAllIntercepts(options ...fn.Option) error
}

func New

func New() (ApiClient, error)

type App

type App struct {
	DisplayName string   `json:"displayName"`
	Metadata    Metadata `json:"metadata"`
	Spec        AppSpec  `json:"spec"`
	Status      Status   `json:"status"`
	IsMainApp   bool     `json:"mapp"`
}

type AppPort

type AppPort struct {
	AppPort    int `json:"appPort"`
	DevicePort int `json:"devicePort,omitempty"`
}

type AppSpec

type AppSpec struct {
	Services []struct {
		Port int `json:"port"`
	} `json:"services"`
	Intercept *struct {
		Enabled      bool      `json:"enabled"`
		PortMappings []AppPort `json:"portMappings"`
	} `json:"intercept"`
}

type CSResp

type CSResp map[string]map[string]*Kv

type CheckName

type CheckName struct {
	Result         bool     `json:"result"`
	SuggestedNames []string `json:"suggestedNames"`
}

type Cluster

type Cluster struct {
	DisplayName    string          `json:"displayName"`
	ClusterToken   string          `json:"clusterToken"`
	Name           string          `json:"name"`
	LastOnlineAt   time.Time       `json:"lastOnlineAt"`
	InstallCommand *InstallCommand `json:"installCommand"`
	Metadata       struct {
		Name   string            `json:"name"`
		Labels map[string]string `json:"labels"`
	} `json:"metadata"`
}

type Config

type Config struct {
	DisplayName string            `yaml:"displayName"`
	Metadata    Metadata          `yaml:"metadata"`
	Status      Status            `yaml:"status"`
	Data        map[string]string `yaml:"data"`
}

type ConfigEnv

type ConfigEnv struct {
	Key        string `json:"key"`
	ConfigName string `json:"configName"`
	Value      string `json:"value"`
}

type ConfigORSecret

type ConfigORSecret struct {
	Entries map[string]string `json:"entries"`
	Name    string            `json:"name"`
}

type Device

type Device struct {
	TeamName          string `json:"accountName"`
	CreationTime      string `json:"creationTime"`
	CreatedBy         User   `json:"createdBy"`
	DisplayName       string `json:"displayName"`
	GlobalVPNName     string `json:"globalVPNName"`
	ID                string `json:"id"`
	IPAddress         string `json:"ipAddr"`
	LastUpdatedBy     User   `json:"lastUpdatedBy"`
	MarkedForDeletion bool   `json:"markedForDeletion"`
	Metadata          struct {
		Annotations       map[string]string `json:"annotations"`
		CreationTimestamp string            `json:"creationTimestamp"`
		DeletionTimestamp string            `json:"deletionTimestamp"`
		Labels            map[string]string `json:"labels"`
		Name              string            `json:"name"`
	} `json:"metadata"`
	PrivateKey      string `json:"privateKey"`
	PublicEndpoint  string `json:"publicEndpoint"`
	PublicKey       string `json:"publicKey"`
	UpdateTime      string `json:"updateTime"`
	WireguardConfig struct {
		Value    string `json:"value"`
		Encoding string `json:"encoding"`
	} `json:"wireguardConfig,omitempty"`
}

type DeviceList

type DeviceList struct {
	Edges Edges[Env] `json:"edges"`
}

type Edge

type Edge[T any] struct {
	Node T
}

type Edges

type Edges[T any] []Edge[T]

type Env

type Env struct {
	DisplayName string   `json:"displayName"`
	Metadata    Metadata `json:"metadata"`
	Status      Status   `json:"status"`
	ClusterName string   `json:"clusterName"`
	IsArchived  bool     `json:"isArchived"`
	Spec        struct {
		Suspend         bool   `json:"suspend"`
		TargetNamespace string `json:"targetNamespace"`
	} `json:"spec"`
}

type EnvList

type EnvList struct {
	Edges Edges[Env] `json:"edges"`
}

type EnvRsp

type EnvRsp struct {
	Secrets []SecretEnv `json:"secrets"`
	Configs []ConfigEnv `json:"configs"`
	Mreses  []MresEnv   `json:"mreses"`
}

type GeneratedEnvs

type GeneratedEnvs struct {
	EnvVars    map[string]string `json:"envVars"`
	MountFiles map[string]string `json:"mountFiles"`
}

type InstallCommand

type InstallCommand struct {
	ChartRepo    string `json:"chart-repo"`
	ChartVersion string `json:"chart-version"`
	CRDsURL      string `json:"crds-url"`
	HelmValues   struct {
		TeamName              string `json:"accountName"`
		ClusterName           string `json:"clusterName"`
		ClusterToken          string `json:"clusterToken"`
		KloudliteDNSSuffix    string `json:"kloudliteDNSSuffix"`
		MessageOfficeGRPCAddr string `json:"messageOfficeGRPCAddr"`
	} `json:"helm-values"`
	Gateway struct {
		IP          string `json:"IP"`
		ClusterCIDR string `json:"clusterCIDR"`
	}
}

type ItemList

type ItemList[T any] struct {
	Edges Edges[T] `json:"edges"`
}

type Kv

type Kv struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Metadata

type Metadata struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

type MountMap

type MountMap map[string]string

type Mres

type Mres struct {
	DisplayName   string   `json:"displayName"`
	Name          string   `json:"name"`
	SecretRefName Metadata `json:"secretRef"`
}

type MresEnv

type MresEnv struct {
	Key        string `json:"key"`
	SecretName string `json:"secretName"`
	Value      string `json:"value"`
}

type MresResp

type MresResp struct {
	Key      string `json:"key"`
	Value    string `json:"value"`
	MresName string `json:"mresName"`
}

type Response

type Response[T any] struct {
	Data   T       `json:"data"`
	Errors []error `json:"errors"`
}

type Secret

type Secret struct {
	DisplayName string            `yaml:"displayName" json:"displayName"`
	Metadata    Metadata          `yaml:"metadata" json:"metadata"`
	Status      Status            `yaml:"status" json:"status"`
	StringData  map[string]string `yaml:"stringData" json:"stringData"`
	IsReadyOnly bool              `yaml:"isReadyOnly" json:"isReadyOnly"`
}

type SecretEnv

type SecretEnv struct {
	Key        string `json:"key"`
	SecretName string `json:"secretName"`
	Value      string `json:"value"`
}

type Status

type Status struct {
	IsReady bool `json:"isReady"`
	Message struct {
		RawMessage json.RawMessage `json:",inline"`
	} `json:"message"`
}

type Team

type Team struct {
	Metadata    Metadata `json:"metadata"`
	DisplayName string   `json:"displayName"`
	Status      Status   `json:"status"`
}

type User

type User struct {
	UserId string `json:"id"`
	Email  string `json:"email"`
	Name   string `json:"name"`
}

Jump to

Keyboard shortcuts

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