api

package
v0.0.0-...-03b3356 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WorkspaceNone = ""
	ClusterNone   = ""
)

List of all resource kinds supported by the UI.

Variables

This section is empty.

Functions

func HandleBadRequest

func HandleBadRequest(response *restful.Response, req *restful.Request, err error)

HandleBadRequest writes http.StatusBadRequest and log error

func HandleConflict

func HandleConflict(response *restful.Response, req *restful.Request, err error)

func HandleError

func HandleError(response *restful.Response, req *restful.Request, err error)

func HandleForbidden

func HandleForbidden(response *restful.Response, req *restful.Request, err error)

func HandleInternalError

func HandleInternalError(response *restful.Response, req *restful.Request, err error)

func HandleNotFound

func HandleNotFound(response *restful.Response, req *restful.Request, err error)

func HandleTooManyRequests

func HandleTooManyRequests(response *restful.Response, req *restful.Request, err error)

func HandleUnauthorized

func HandleUnauthorized(response *restful.Response, req *restful.Request, err error)

Types

type ClientType

type ClientType string
const (
	ClientKubernetes  ClientType = "Kubernetes"
	ClientApplication ClientType = "Application"

	StatusOK = "ok"
)

type CommonListResult

type CommonListResult[T interface{}] struct {
	Result[T] `json:"inline"`
	Data      []T `json:"data"`
}

CommonListResult is the sub-result of the common one. This struct aims to get list items.

func ParseListResult

func ParseListResult[T interface{}](data []byte) (result *CommonListResult[T], err error)

ParseListResult parses the data to result object

func (*CommonListResult[T]) GetList

func (r *CommonListResult[T]) GetList() (items []T)

GetList returns the all items.

type CommonSingleResult

type CommonSingleResult[T interface{}] struct {
	Result[T] `json:"inline"`
	Data      T `json:"data"`
}

CommonSingleResultis the sub-result of the common one. This struct aims to get the single object.

func ParseResult

func ParseResult[T interface{}](data []byte) (result *CommonSingleResult[T], err error)

ParseResult parses the result with a single object

func (*CommonSingleResult[T]) GetData

func (r *CommonSingleResult[T]) GetData() T

GetData returns the data

type FakeQuerier

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

FakeQuerier is a fake querier that exists for unit test purpose

func NewFakeQuerier

func NewFakeQuerier(data map[string]string) *FakeQuerier

NewFakeQuerier returns the instance of FakeQuerier

func (*FakeQuerier) QueryParameter

func (q *FakeQuerier) QueryParameter(key string) string

QueryParameter is a fake function, return the pair value directly

type GitCredential

type GitCredential struct {
	RemoteUrl string                  `json:"remoteUrl" description:"git server url"`
	SecretRef *corev1.SecretReference `json:"secretRef,omitempty" description:"auth secret reference"`
}

type ListResult

type ListResult struct {
	Items      []interface{} `json:"items"`
	TotalItems int           `json:"totalItems"`
}

type NamespacedResourceQuota

type NamespacedResourceQuota struct {
	Namespace string `json:"namespace,omitempty"`

	Data struct {
		corev1.ResourceQuotaStatus

		// quota left status, do the math on the side, cause it's
		// a lot easier with go-client library
		Left corev1.ResourceList `json:"left,omitempty"`
	} `json:"data,omitempty"`
}

type Querier

type Querier interface {
	QueryParameter(string) string
}

Querier represents an interface for querying parameter

type RegistryCredential

type RegistryCredential struct {
	Username   string `json:"username" description:"username"`
	Password   string `json:"password" description:"password"`
	ServerHost string `json:"serverhost" description:"registry server host"`
}

type ResourceQuota

type ResourceQuota struct {
	Namespace string                     `json:"namespace" description:"namespace"`
	Data      corev1.ResourceQuotaStatus `json:"data" description:"resource quota status"`
}

type Result

type Result[T interface{}] struct {
	// Message is the hunman readable message for the front-end.
	// This message is 'OK' when code is '0', or is the error message.
	Message string `json:"message"`
	// Code represents the result, 0 means success, others mean failure
	Code int `json:"code"`
	// Data is the response from HTTP server.
	// Data could be slice or a single object.
	Data interface{} `json:"data,omitempty"`
	// Page carries the pagination of a list result
	Page *ResultPage `json:"page,omitempty"`
	// contains filtered or unexported fields
}

Result represents a HTTP response to front-end

func NewEmptyResult

func NewEmptyResult() *Result[string]

NewEmptyResult creates a non-data result

func NewResult

func NewResult[T interface{}]() *Result[T]

NewResult returns a list result

func NewStringResult

func NewStringResult() *Result[string]

NewStringResult creates a string result

func (*Result[T]) WithError

func (r *Result[T]) WithError(err error) *Result[T]

WithError sets the error message

func (*Result[T]) WithList

func (r *Result[T]) WithList(list []T) *Result[T]

WithList puts the object list into result

func (*Result[T]) WithListAndFilter

func (r *Result[T]) WithListAndFilter(list []T, querier Querier) *Result[T]

WithListAndFilter set and filter the list

func (*Result[T]) WithObject

func (r *Result[T]) WithObject(obj T) *Result[T]

WithObject puts a single object into result

func (*Result[T]) WithObjectAsJSONString

func (r *Result[T]) WithObjectAsJSONString(obj interface{}) *Result[T]

func (*Result[T]) WriteTo

func (r *Result[T]) WriteTo(resp *restful.Response)

WriteTo writes data to target Writer

type ResultPage

type ResultPage struct {
	Total int `json:"total"`
	Page  int `json:"page"`
	Limit int `json:"limit"`
}

ResultPage is the result pagination object

type Router

type Router struct {
	RouterType  string            `json:"type"`
	Annotations map[string]string `json:"annotations"`
}

type WebSocketHandler

type WebSocketHandler interface {
	WithRequest(*http.Request, http.ResponseWriter) WebSocketHandler
	WithWatchInterface(func() (watch.Interface, error)) WebSocketHandler
	WithUpgrader(websocket.Upgrader) WebSocketHandler
	Handle(<-chan struct{}) (bool, error)
}

func NewDefaultWebSocketHandler

func NewDefaultWebSocketHandler() WebSocketHandler

type Workloads

type Workloads struct {
	Namespace string                 `json:"namespace" description:"the name of the namespace"`
	Count     map[string]int         `json:"data" description:"the number of unhealthy workloads"`
	Items     map[string]interface{} `json:"items,omitempty" description:"unhealthy workloads"`
}

Directories

Path Synopsis
core.ai.io
v1
Package v1 contains API Schema definitions for the v1 API group +kubebuilder:object:generate=true +groupName=core.ai.io +k8s:openapi-gen=true
Package v1 contains API Schema definitions for the v1 API group +kubebuilder:object:generate=true +groupName=core.ai.io +k8s:openapi-gen=true
iam.ai.io
v1
Package v1 contains API Schema definitions for the v1 API group +kubebuilder:object:generate=true +groupName=iam.ai.io +k8s:openapi-gen=true
Package v1 contains API Schema definitions for the v1 API group +kubebuilder:object:generate=true +groupName=iam.ai.io +k8s:openapi-gen=true

Jump to

Keyboard shortcuts

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