@archon-inc/sdk
Version:
Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk
17 lines (14 loc) • 722 B
text/typescript
import { Archon } from "../Archon.js";
import { ResourceType, ResourceTypeName } from "../types/policy.js";
/**
* Given a resource type name, return the resource type from the Archon policy service.
* @param resourceTypeName the name of the resource type to retrieve, found in the archon.yaml file.
* @returns The resource type from the Archon policy service.
*/
export default async function getResourceType(resourceTypeName: ResourceTypeName | string): Promise<ResourceType> {
const response = await Archon.request(`/policy/type/${resourceTypeName}`, "GET");
if (response.status !== 200) {
throw new Error(`Failed to retrieve resource type ${resourceTypeName}.`);
}
return response.data;
}