@stolostron/multicluster-sdk
Version:
Provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management.
35 lines • 1.74 kB
TypeScript
import { UseFleetK8sWatchResource } from '../types';
/**
* A hook for watching Kubernetes resources with support for multi-cluster environments.
* It is equivalent to the [`useK8sWatchResource`](https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/api.md#usek8swatchresource)
* hook from the [OpenShift Console Dynamic Plugin SDK](https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk)
* but allows you to retrieve data from any cluster managed by Red Hat Advanced Cluster Management.
*
* It automatically detects the hub cluster and handles resource watching on both hub
* and remote clusters using WebSocket connections for real-time updates.
*
* @param initResource - The resource to watch. Can be null to disable the watch.
* @param initResource.cluster - The managed cluster on which the resource resides; null for the hub cluster
* @returns A tuple containing the watched resource data, a boolean indicating if the data is loaded,
* and any error that occurred. The hook returns live-updating data.
*
* @example
* ```typescript
* // Watch pods on a remote cluster
* const [pods, loaded, error] = useFleetK8sWatchResource({
* groupVersionKind: { version: 'v1', kind: 'Pod' },
* isList: true,
* cluster: 'remote-cluster',
* namespace: 'default'
* })
*
* // Watch a specific deployment on hub cluster
* const [deployment, loaded, error] = useFleetK8sWatchResource({
* groupVersionKind: { group: 'apps', version: 'v1', kind: 'Deployment' },
* name: 'my-app',
* namespace: 'default'
* })
* ```
*/
export declare const useFleetK8sWatchResource: UseFleetK8sWatchResource;
//# sourceMappingURL=useFleetK8sWatchResource.d.ts.map