@archon-inc/sdk
Version:
Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk
19 lines (18 loc) • 843 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = searchResources;
const Archon_js_1 = require("../Archon.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.
*/
async function searchResources(resourceType, metadata = {}) {
const type = typeof resourceType === "string" ? resourceType : resourceType.name;
const response = await Archon_js_1.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;
}