Skip to main content

Module: lib/k8s/apiProxy

Interfaces

Type aliases

StreamErrCb

Ƭ StreamErrCb: (err: Error & { status?: number }, cancelStreamFunc?: () => void) => void

Type declaration

▸ (err, cancelStreamFunc?): void

The callback that's called when there's an error streaming the results.

Parameters
NameType
errError & { status?: number }
cancelStreamFunc?() => void
Returns

void

Defined in

lib/k8s/apiProxy.ts:457


StreamResultsCb

Ƭ StreamResultsCb: (...args: any[]) => void

Type declaration

▸ (...args): void

The callback that's called when some results are streamed in.

Parameters
NameType
...argsany[]
Returns

void

Defined in

lib/k8s/apiProxy.ts:455

Functions

apiFactory

apiFactory(...args): Object

Creates an API client for a single or multiple Kubernetes resources.

Parameters

NameTypeDescription
...args[group: string, version: string, resource: string] | [group: string, version: string, resource: string][]The arguments to pass to either singleApiFactory or multipleApiFactory.

Returns

Object

An API client for the specified Kubernetes resource(s).

NameType
apiInfo{ group: string ; resource: string ; version: string }[]
delete(name: string, queryParams?: QueryParameters, cluster?: string) => Promise<any>
get(name: string, cb: StreamResultsCb, errCb: StreamErrCb, queryParams?: QueryParameters, cluster?: string) => Promise<() => void>
isNamespacedboolean
list(cb: StreamResultsCb, errCb: StreamErrCb, queryParams?: QueryParameters, cluster?: string) => Promise<() => void>
patch(body: OpPatch[], name: string, queryParams?: QueryParameters, cluster?: string) => Promise<any>
post(body: KubeObjectInterface, queryParams?: QueryParameters, cluster?: string) => Promise<any>
put(body: KubeObjectInterface, queryParams?: QueryParameters, cluster?: string) => Promise<any>

Defined in

lib/k8s/apiProxy.ts:571


apiFactoryWithNamespace

apiFactoryWithNamespace(...args): Object

Parameters

NameType
...args[group: string, version: string, resource: string, includeScale: boolean] | [group: string, version: string, resource: string, includeScale: boolean][]

Returns

Object

NameType
scale?{ get: (namespace: string, name: string, clusterName?: string) => Promise<any> ; put: (body: { metadata: KubeMetadata ; spec: { replicas: number } }, clusterName?: string) => Promise<any> }
scale.get(namespace: string, name: string, clusterName?: string) => Promise<any>
scale.put(body: { metadata: KubeMetadata ; spec: { replicas: number } }, clusterName?: string) => Promise<any>

Defined in

lib/k8s/apiProxy.ts:700


apply

apply(body, clusterName?): Promise<JSON>

Applies the provided body to the Kubernetes API.

Tries to POST, and if there's a conflict it does a PUT to the api endpoint.

Parameters

NameTypeDescription
bodyKubeObjectInterfaceThe kubernetes object body to apply.
clusterName?stringThe cluster to apply the body to. By default uses the current cluster (URL defined).

Returns

Promise<JSON>

The response from the kubernetes API server.

Defined in

lib/k8s/apiProxy.ts:1521


clusterRequest

clusterRequest(path, params?, queryParams?): Promise<any>

Sends a request to the backend. If the cluster is required in the params parameter, it will be used as a request to the respective Kubernetes server.

throws An ApiError if the response status is not ok.

Parameters

NameTypeDescription
pathstringThe path to the API endpoint.
paramsClusterRequestParamsOptional parameters for the request.
queryParams?QueryParametersOptional query parameters for the k8s request.

Returns

Promise<any>

A Promise that resolves to the JSON response from the API server.

Defined in

lib/k8s/apiProxy.ts:339


deleteCluster

deleteCluster(cluster): Promise<any>

Parameters

NameType
clusterstring

Returns

Promise<any>

Defined in

lib/k8s/apiProxy.ts:1673


deletePlugin

deletePlugin(name): Promise<any>

Deletes the plugin with the specified name from the system.

This function sends a DELETE request to the server's plugin management endpoint, targeting the plugin identified by its name. The function handles the request asynchronously and returns a promise that resolves with the server's response to the DELETE operation.

throws — An ApiError if the response status is not ok.

example // Call to delete a plugin named 'examplePlugin' deletePlugin('examplePlugin') .then(response => console.log('Plugin deleted successfully', response)) .catch(error => console.error('Failed to delete plugin', error));

Parameters

NameTypeDescription
namestringThe unique name of the plugin to delete. This identifier is used to construct the URL for the DELETE request.

Returns

Promise<any>

— A Promise that resolves to the JSON response from the API server.

Defined in

lib/k8s/apiProxy.ts:1925


drainNode

drainNode(cluster, nodeName): Promise<any>

Drain a node

throws {Error} if the request fails

throws {Error} if the response is not ok

This function is used to drain a node. It is used in the node detail page. As draining a node is a long running process, we get the request received message if the request is successful. And then we poll the drain node status endpoint to get the status of the drain node process.

Parameters

NameTypeDescription
clusterstringThe cluster to drain the node
nodeNamestringThe node name to drain

Returns

Promise<any>

Defined in

lib/k8s/apiProxy.ts:1810


drainNodeStatus

drainNodeStatus(cluster, nodeName): Promise<DrainNodeStatus>

Get the status of the drain node process.

It is used in the node detail page. As draining a node is a long running process, we poll this endpoint to get the status of the drain node process.

throws {Error} if the request fails

throws {Error} if the response is not ok

Parameters

NameTypeDescription
clusterstringThe cluster to get the status of the drain node process for.
nodeNamestringThe node name to get the status of the drain node process for.

Returns

Promise<DrainNodeStatus>

  • The response from the API. @todo: what response?

Defined in

lib/k8s/apiProxy.ts:1852


listPortForward

listPortForward(cluster): Promise<any>

Lists the port forwards for the specified cluster.

Parameters

NameTypeDescription
clusterstringThe cluster to list the port forwards.

Returns

Promise<any>

the list of port forwards for the cluster.

Defined in

lib/k8s/apiProxy.ts:1787


metrics

metrics(url, onMetrics, onError?, cluster?): Promise<() => void>

Gets the metrics for the specified resource. Gets new metrics every 10 seconds.

Parameters

NameTypeDescription
urlstringThe url of the resource to get metrics for.
onMetrics(arg: KubeMetrics[]) => voidThe function to call with the metrics.
onError?(err: ApiError) => voidThe function to call if there's an error.
cluster?stringThe cluster to get metrics for. By default uses the current cluster (URL defined).

Returns

Promise<() => void>

A function to cancel the metrics request.

Defined in

lib/k8s/apiProxy.ts:1583


patch

patch(url, json, autoLogoutOnAuthError?, options?): Promise<any>

Parameters

NameTypeDefault value
urlstringundefined
jsonanyundefined
autoLogoutOnAuthErrorbooleantrue
optionsClusterRequestParams{}

Returns

Promise<any>

Defined in

lib/k8s/apiProxy.ts:976


post

post(url, json, autoLogoutOnAuthError?, options?): Promise<any>

Parameters

NameTypeDefault value
urlstringundefined
jsonobject | KubeObjectInterface | JSONundefined
autoLogoutOnAuthErrorbooleantrue
optionsClusterRequestParams{}

Returns

Promise<any>

Defined in

lib/k8s/apiProxy.ts:957


put

put(url, json, autoLogoutOnAuthError?, requestOptions?): Promise<any>

Parameters

NameTypeDefault value
urlstringundefined
jsonPartial<KubeObjectInterface>undefined
autoLogoutOnAuthErrorbooleantrue
requestOptionsClusterRequestParams{}

Returns

Promise<any>

Defined in

lib/k8s/apiProxy.ts:996


remove

remove(url, requestOptions?): Promise<any>

Parameters

NameType
urlstring
requestOptionsClusterRequestParams

Returns

Promise<any>

Defined in

lib/k8s/apiProxy.ts:1015


request

request(path, params?, autoLogoutOnAuthError?, useCluster?, queryParams?): Promise<any>

Sends a request to the backend. If the useCluster parameter is true (which it is, by default), it will be treated as a request to the Kubernetes server of the currently defined (in the URL) cluster.

throws An ApiError if the response status is not ok.

Parameters

NameTypeDefault valueDescription
pathstringundefinedThe path to the API endpoint.
paramsRequestParams{}Optional parameters for the request.
autoLogoutOnAuthErrorbooleantrueWhether to automatically log out the user if there is an authentication error.
useClusterbooleantrueWhether to use the current cluster for the request.
queryParams?QueryParametersundefinedOptional query parameters for the request.

Returns

Promise<any>

A Promise that resolves to the JSON response from the API server.

Defined in

lib/k8s/apiProxy.ts:303


setCluster

setCluster(clusterReq): Promise<any>

Parameters

NameType
clusterReqClusterRequest

Returns

Promise<any>

Defined in

lib/k8s/apiProxy.ts:1635


startPortForward

startPortForward(cluster, namespace, podname, containerPort, service, serviceNamespace, port?, address?, id?): Promise<any>

Starts a portforward with the given details.

throws {Error} if the request fails.

Parameters

NameTypeDefault valueDescription
clusterstringundefinedThe cluster to portforward for.
namespacestringundefinedThe namespace to portforward for.
podnamestringundefinedThe pod to portforward for.
containerPortstring | numberundefinedThe container port to portforward for.
servicestringundefinedThe service to portforward for.
serviceNamespacestringundefinedThe service namespace to portforward for.
port?stringundefinedThe port to portforward for.
addressstring''-
idstring''The id to portforward for.

Returns

Promise<any>

The response from the API.

Defined in

lib/k8s/apiProxy.ts:1710


stopOrDeletePortForward

stopOrDeletePortForward(cluster, id, stopOrDelete?): Promise<string>

Stops or deletes a portforward with the specified details.

throws {Error} if the request fails.

Parameters

NameTypeDefault valueDescription
clusterstringundefinedThe cluster to portforward for.
idstringundefinedThe id to portforward for.
stopOrDeletebooleantrueWhether to stop or delete the portforward. True for stop, false for delete.

Returns

Promise<string>

The response from the API.

Defined in

lib/k8s/apiProxy.ts:1760


stream

stream(url, cb, args): Object

Establishes a WebSocket connection to the specified URL and streams the results to the provided callback function.

Parameters

NameTypeDescription
urlstringThe URL to connect to.
cbStreamResultsCbThe callback function to receive the streamed results.
argsStreamArgsAdditional arguments to configure the stream.

Returns

Object

An object with two functions: cancel, which can be called to cancel the stream, and getSocket, which returns the WebSocket object.

NameType
cancel() => void
getSocket() => null | WebSocket

Defined in

lib/k8s/apiProxy.ts:1287


streamResult

streamResult(url, name, cb, errCb, queryParams?, cluster?): Promise<() => void>

Streams the results of a Kubernetes API request into a 'cb' callback.

Parameters

NameTypeDescription
urlstringThe URL of the Kubernetes API endpoint.
namestringThe name of the Kubernetes API resource.
cbStreamResultsCbThe callback function to execute when the stream receives data.
errCbStreamErrCbThe callback function to execute when an error occurs.
queryParams?QueryParametersThe query parameters to include in the API request.
cluster?string-

Returns

Promise<() => void>

A function to cancel the stream.

Defined in

lib/k8s/apiProxy.ts:1033


streamResults

streamResults(url, cb, errCb, queryParams): Promise<() => void>

Streams the results of a Kubernetes API request.

Parameters

NameTypeDescription
urlstringThe URL of the Kubernetes API endpoint.
cbStreamResultsCbThe callback function to execute when the stream receives data.
errCbStreamErrCbThe callback function to execute when an error occurs.
queryParamsundefined | QueryParametersThe query parameters to include in the API request.

Returns

Promise<() => void>

A function to cancel the stream.

Defined in

lib/k8s/apiProxy.ts:1100


streamResultsForCluster

streamResultsForCluster(url, params, queryParams): Promise<() => void>

Parameters

NameType
urlstring
paramsStreamResultsParams
queryParamsundefined | QueryParameters

Returns

Promise<() => void>

Defined in

lib/k8s/apiProxy.ts:1121


testAuth

testAuth(cluster?): Promise<any>

Parameters

NameTypeDefault value
clusterstring''

Returns

Promise<any>

Defined in

lib/k8s/apiProxy.ts:1620


testClusterHealth

testClusterHealth(cluster?): Promise<any>

Parameters

NameType
cluster?string

Returns

Promise<any>

Defined in

lib/k8s/apiProxy.ts:1630