UNPKG

@archon-inc/sdk

Version:

Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk

21 lines (16 loc) 890 B
import { Archon } from "../Archon.js"; import { Resource, ResourceType, ResourceTypeName } from "../types/policy.js"; /** * Search for resources based on type and metadata. * @param resourceType - The type of the resource to search for. * @param metadata - Metadata key-value pairs to filter resources. * @returns A promise resolving to a list of resources matching the criteria. */ export default async function searchResources(resourceType: ResourceType | ResourceTypeName, metadata: Record<string, unknown> = {}): Promise<Resource[]> { const type = typeof resourceType === "string" ? resourceType : resourceType.name; const response = await Archon.request("/policy/resource/search", "POST", { type, metadata }); if (response.status !== 200) { throw new Error(`Failed to search resources of type ${type}: ${response.data}`); } return response.data; }