UNPKG

@archon-inc/sdk

Version:

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

23 lines (22 loc) 989 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = addResource; const Archon_js_1 = require("../Archon.js"); /** * This function creates a new Archon-managed resource for some object your software maintains. * It returns an ARID that you can use to reference the resource in the future. You'll use the ARID to determine * access to the resource, so make sure you store it on your end. * @param options The options for the resource you're adding. * @returns The ARID of the newly created resource. */ async function addResource(options) { // If the type is a ResourceType object, convert it to a ResourceTypeName. if (typeof options.type !== "string") { options.type = options.type.name; } const response = await Archon_js_1.Archon.request("/policy/resource", "POST", options); if (response.status !== 200) { throw new Error(`Failed to add resource: ${response.data}`); } return response.data; }