ResourceInstanceApi
Instance-level operations available on resources returned by the Resources API.
These methods operate on a specific resource that has already been fetched.
Methods
delete()
delete(): Promise<void>;
Deletes a resource instance.
Requires delete permissions (canDelete).
Returns
Promise<void>
A promise that resolves when the resource has been deleted.
Example
import { useResources, K8S } from '@shell/apis';
const resources = useResources();
const pod = await resources.cluster.find(K8S.POD, 'default/my-pod-123');
await pod.delete();
replace()
replace(): Promise<ResourceInstanceApi>;
Performs a full replacement update of a resource using HTTP PUT.
Sends the entire current state of the resource to the server.
Requires edit permissions (canEdit).
Returns
Promise<ResourceInstanceApi>
a resource instance, updated with the server response.
Example
import { useResources, K8S } from '@shell/apis';
const resources = useResources();
const configMap = await resources.cluster.find(K8S.CONFIG_MAP, 'default/my-config');
configMap.data.myKey = 'updatedValue';
await configMap.replace();
update()
update(data): Promise<ResourceInstanceApi>;
Applies a partial update to a resource using HTTP PATCH
with merge-patch semantics (application/strategic-merge-patch+json).
Only the fields provided in data are sent to the server — the rest of the resource
remains unchanged. The server response is merged back into this instance.
Requires edit permissions (canEdit).
Parameters
data
Record<string, any>
An object containing only the fields to update.
Returns
Promise<ResourceInstanceApi>
a resource instance, updated with the server response.
Example
import { useResources, K8S } from '@shell/apis';
const resources = useResources();
const configMap = await resources.cluster.find(K8S.CONFIG_MAP, 'default/my-config');
await configMap.update({ newKey: 'newValue' });
const result = configMap.newKey === 'newValue' // true